@@ -7,19 +7,19 @@ r[runtime.global_allocator]
7
7
## The ` global_allocator ` attribute
8
8
9
9
r[ runtime.global_allocator.intro]
10
- The * ` global_allocator ` [ attribute] [ attributes ] * is used to define a [ memory allocator] [ std::alloc ] .
10
+ The * ` global_allocator ` [ attribute] [ attributes ] * selects a [ memory allocator] [ std::alloc ] .
11
11
12
12
> [ !EXAMPLE]
13
13
> ``` rust
14
- > use std :: alloc :: {GlobalAlloc , System , Layout };
14
+ > use core :: alloc :: {GlobalAlloc , Layout };
15
+ > use std :: alloc :: System ;
15
16
>
16
17
> struct MyAllocator ;
17
18
>
18
19
> unsafe impl GlobalAlloc for MyAllocator {
19
20
> unsafe fn alloc (& self , layout : Layout ) -> * mut u8 {
20
21
> unsafe { System . alloc (layout ) }
21
22
> }
22
- >
23
23
> unsafe fn dealloc (& self , ptr : * mut u8 , layout : Layout ) {
24
24
> unsafe { System . dealloc (ptr , layout ) }
25
25
> }
@@ -30,19 +30,19 @@ The *`global_allocator` [attribute][attributes]* is used to define a [memory all
30
30
> ```
31
31
32
32
r [runtime . global_allocator. syntax]
33
- The `global_allocator ` attribute uses the [MetaWord ] syntax and thus does not take any inputs .
33
+ The `global_allocator ` attribute uses the [MetaWord ] syntax .
34
34
35
35
r [runtime . global_allocator. allowed- positions ]
36
- The `global_allocator ` attribute may only be applied to a [static item ] that implements the [`GlobalAlloc `] trait .
36
+ The `global_allocator ` attribute may only be applied to a [static item ] whose type implements the [`GlobalAlloc `] trait .
37
37
38
38
r [runtime . global_allocator. duplicates]
39
- The `global_allocator ` attribute may only be specified once on an item .
39
+ The `global_allocator ` attribute may only be used once on an item .
40
40
41
41
r [runtime . global_allocator. single]
42
- At most one `global_allocator ` may be specified in the crate graph .
42
+ The `global_allocator ` attribute may only be used once in the crate graph .
43
43
44
44
r [runtime . global_allocator. stdlib]
45
- The `global_allocator ` attribute is exported in the [standard library prelude ][core :: prelude :: v1 ].
45
+ The `global_allocator ` attribute is exported from the [standard library prelude ][core :: prelude :: v1 ].
46
46
47
47
r [runtime . windows_subsystem]
48
48
## The `windows_subsystem ` attribute
0 commit comments