diff options
| author | Corey Farwell <coreyf@rwell.org> | 2016-09-26 23:11:47 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2016-09-26 23:11:47 -0400 |
| commit | 2ba02a773e8e4f5bd5032a8305a8ba1eda7967c6 (patch) | |
| tree | 3134b9d3df29c284f638b2e873616a5bd015fd2f | |
| parent | 388c3f25f95c55add63d436a8e8bb207d003c63b (diff) | |
| download | rust-2ba02a773e8e4f5bd5032a8305a8ba1eda7967c6.tar.gz rust-2ba02a773e8e4f5bd5032a8305a8ba1eda7967c6.zip | |
Add basic doc example for `core::ptr::write_bytes`.
| -rw-r--r-- | src/libcore/intrinsics.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 22abe7a99b1..6c4da2a8851 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -596,6 +596,19 @@ extern "rust-intrinsic" { /// Invokes memset on the specified pointer, setting `count * size_of::<T>()` /// bytes of memory starting at `dst` to `val`. + /// + /// # Examples + /// + /// ``` + /// use std::ptr; + /// + /// let mut vec = vec![0; 4]; + /// unsafe { + /// let vec_ptr = vec.as_mut_ptr(); + /// ptr::write_bytes(vec_ptr, b'a', 2); + /// } + /// assert_eq!(vec, [b'a', b'a', 0, 0]); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); |
