diff options
| author | Jonathan Turner <jonathandturner@users.noreply.github.com> | 2016-09-28 10:33:56 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-28 10:33:56 -0700 |
| commit | 9a17da24705f92c432f5c7dfc12ccd925638e679 (patch) | |
| tree | 5ce40d4b5a5a70561069b6e26cf6a4af30a3c36a | |
| parent | 224e882878650238e0bf2aa1c5d943d83d14ecc0 (diff) | |
| parent | 2ba02a773e8e4f5bd5032a8305a8ba1eda7967c6 (diff) | |
| download | rust-9a17da24705f92c432f5c7dfc12ccd925638e679.tar.gz rust-9a17da24705f92c432f5c7dfc12ccd925638e679.zip | |
Rollup merge of #36765 - frewsxcv:ptr-write-bytes, r=steveklabnik
Add basic doc example for `core::ptr::write_bytes`. None
| -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); |
