Skip to content

Commit a551b25

Browse files
committed
Revise global_allocator text
1 parent 8b183dc commit a551b25

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/runtime.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ r[runtime.global_allocator]
77
## The `global_allocator` attribute
88

99
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].
1111

1212
> [!EXAMPLE]
1313
> ```rust
14-
> use std::alloc::{GlobalAlloc, System, Layout};
14+
> use core::alloc::{GlobalAlloc, Layout};
15+
> use std::alloc::System;
1516
>
1617
> struct MyAllocator;
1718
>
1819
> unsafe impl GlobalAlloc for MyAllocator {
1920
> unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
2021
> unsafe { System.alloc(layout) }
2122
> }
22-
>
2323
> unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
2424
> unsafe { System.dealloc(ptr, layout) }
2525
> }
@@ -30,19 +30,19 @@ The *`global_allocator` [attribute][attributes]* is used to define a [memory all
3030
> ```
3131
3232
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.
3434
3535
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.
3737
3838
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.
4040
4141
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.
4343
4444
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].
4646
4747
r[runtime.windows_subsystem]
4848
## The `windows_subsystem` attribute

0 commit comments

Comments
 (0)