File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -65,28 +65,31 @@ pub use intrinsics::transmute;
65
65
///
66
66
/// # Example
67
67
///
68
+ /// Leak some heap memory by never deallocating it.
69
+ ///
68
70
/// ```rust
69
71
/// use std::mem;
70
72
///
71
- /// // Leak some heap memory by never deallocating it
72
73
/// let heap_memory = Box::new(3);
73
74
/// mem::forget(heap_memory);
74
- ///```
75
+ /// ```
76
+ ///
77
+ /// Leak an I/O object, never closing the file.
75
78
///
76
79
/// ```rust,no_run
77
80
/// use std::mem;
78
81
/// use std::fs::File;
79
82
///
80
- /// // Leak an I/O object, never closing the file
81
83
/// let file = File::open("foo.txt").unwrap();
82
84
/// mem::forget(file);
83
- ///```
85
+ /// ```
86
+ ///
87
+ /// The swap function uses forget to good effect.
84
88
///
85
- ///```rust
89
+ /// ```rust
86
90
/// use std::mem;
87
91
/// use std::ptr;
88
92
///
89
- /// // The swap function uses forget
90
93
/// pub fn swap<T>(x: &mut T, y: &mut T) {
91
94
/// unsafe {
92
95
/// // Give ourselves some scratch space to work with
You can’t perform that action at this time.
0 commit comments