Skip to content

Commit fac8b81

Browse files
committed
---
yaml --- r: 275151 b: refs/heads/stable c: 16f218b h: refs/heads/master i: 275149: f64837a 275147: 8dddccc 275143: 3e775be 275135: 8982ae9
1 parent a9b9d2c commit fac8b81

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: a70ae2ffb9a5dd08d916b9938eeca820486ba7a0
32+
refs/heads/stable: 16f218b6006faa752925ca5934372c34f1eb2953
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libstd/ffi/c_str.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,16 @@ impl CStr {
449449
/// use std::ffi::CStr;
450450
///
451451
/// # fn main() {
452-
/// let cstr = CStr::from_bytes(b"hello\0");
452+
/// let cstr = CStr::from_bytes_with_nul(b"hello\0");
453453
/// assert!(cstr.is_some());
454454
/// # }
455455
/// ```
456456
#[unstable(feature = "cstr_from_bytes", reason = "recently added", issue = "0")]
457-
pub fn from_bytes<'a>(bytes: &'a [u8]) -> Option<&'a CStr> {
457+
pub fn from_bytes_with_nul<'a>(bytes: &'a [u8]) -> Option<&'a CStr> {
458458
if bytes.is_empty() || memchr::memchr(0, &bytes) != Some(bytes.len() - 1) {
459459
None
460460
} else {
461-
Some(unsafe { Self::from_bytes_unchecked(bytes) })
461+
Some(unsafe { Self::from_bytes_with_nul_unchecked(bytes) })
462462
}
463463
}
464464

@@ -477,13 +477,13 @@ impl CStr {
477477
/// # fn main() {
478478
/// unsafe {
479479
/// let cstring = CString::new("hello").unwrap();
480-
/// let cstr = CStr::from_bytes_unchecked(cstring.to_bytes_with_nul());
480+
/// let cstr = CStr::from_bytes_with_nul_unchecked(cstring.to_bytes_with_nul());
481481
/// assert_eq!(cstr, &*cstring);
482482
/// }
483483
/// # }
484484
/// ```
485485
#[unstable(feature = "cstr_from_bytes", reason = "recently added", issue = "0")]
486-
pub unsafe fn from_bytes_unchecked<'a>(bytes: &'a [u8]) -> &'a CStr {
486+
pub unsafe fn from_bytes_with_nul_unchecked<'a>(bytes: &'a [u8]) -> &'a CStr {
487487
mem::transmute(bytes)
488488
}
489489

0 commit comments

Comments
 (0)