@@ -41,7 +41,7 @@ which allocator is in use is done simply by linking to the desired allocator:
41
41
extern crate alloc_system;
42
42
43
43
fn main() {
44
- let a = Box::new(4); // allocates from the system allocator
44
+ let a = Box::new(4); // Allocates from the system allocator.
45
45
println!("{}", a);
46
46
}
47
47
```
@@ -57,7 +57,7 @@ uses jemalloc by default one would write:
57
57
extern crate alloc_jemalloc;
58
58
59
59
pub fn foo() {
60
- let a = Box::new(4); // allocates from jemalloc
60
+ let a = Box::new(4); // Allocates from jemalloc.
61
61
println!("{}", a);
62
62
}
63
63
# fn main() {}
@@ -72,11 +72,11 @@ crate which implements the allocator API (e.g. the same as `alloc_system` or
72
72
annotated version of ` alloc_system `
73
73
74
74
``` rust,no_run
75
- # // only needed for rustdoc --test down below
75
+ # // Only needed for rustdoc --test down below.
76
76
# #![feature(lang_items)]
77
77
// The compiler needs to be instructed that this crate is an allocator in order
78
78
// to realize that when this is linked in another allocator like jemalloc should
79
- // not be linked in
79
+ // not be linked in.
80
80
#![feature(allocator)]
81
81
#![allocator]
82
82
@@ -85,7 +85,7 @@ annotated version of `alloc_system`
85
85
// however, can use all of libcore.
86
86
#![no_std]
87
87
88
- // Let's give a unique name to our custom allocator
88
+ // Let's give a unique name to our custom allocator:
89
89
#![crate_name = "my_allocator"]
90
90
#![crate_type = "rlib"]
91
91
@@ -126,15 +126,15 @@ pub extern fn __rust_reallocate(ptr: *mut u8, _old_size: usize, size: usize,
126
126
#[no_mangle]
127
127
pub extern fn __rust_reallocate_inplace(_ptr: *mut u8, old_size: usize,
128
128
_size: usize, _align: usize) -> usize {
129
- old_size // this api is not supported by libc
129
+ old_size // This api is not supported by libc.
130
130
}
131
131
132
132
#[no_mangle]
133
133
pub extern fn __rust_usable_size(size: usize, _align: usize) -> usize {
134
134
size
135
135
}
136
136
137
- # // only needed to get rustdoc to test this
137
+ # // Only needed to get rustdoc to test this:
138
138
# fn main() {}
139
139
# #[lang = "panic_fmt"] fn panic_fmt() {}
140
140
# #[lang = "eh_personality"] fn eh_personality() {}
@@ -149,7 +149,7 @@ After we compile this crate, it can be used as follows:
149
149
extern crate my_allocator;
150
150
151
151
fn main() {
152
- let a = Box::new(8); // allocates memory via our custom allocator crate
152
+ let a = Box::new(8); // Allocates memory via our custom allocator crate.
153
153
println!("{}", a);
154
154
}
155
155
```
0 commit comments