From 0e0042f16ec74bd9b219f4df65c5589636cacd15 Mon Sep 17 00:00:00 2001 From: George Bateman Date: Thu, 2 May 2024 21:29:13 +0100 Subject: [PATCH] Update based on review --- library/core/src/ffi/c_str.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 9d914d798eb..57cc0e4d612 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -46,9 +46,9 @@ use crate::str; /// use std::ffi::CStr; /// use std::os::raw::c_char; /// -/// # #[cfg(any())] // Extern functions are awkward in doc comments - fake it instead +/// # /* Extern functions are awkward in doc comments - fake it instead /// extern "C" { fn my_string() -> *const c_char; } -/// # unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() } +/// # */ unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() } /// /// unsafe { /// let slice = CStr::from_ptr(my_string()); @@ -63,9 +63,9 @@ use crate::str; /// use std::os::raw::c_char; /// /// fn work(data: &CStr) { -/// # #[cfg(any())] // Extern functions are awkward in doc comments - fake it instead +/// # /* Extern functions are awkward in doc comments - fake it instead /// extern "C" { fn work_with(data: *const c_char); } -/// # unsafe extern "C" fn work_with(s: *const c_char) {} +/// # */ unsafe extern "C" fn work_with(s: *const c_char) {} /// /// unsafe { work_with(data.as_ptr()) } /// } @@ -80,9 +80,9 @@ use crate::str; /// use std::ffi::CStr; /// use std::os::raw::c_char; /// -/// # #[cfg(any())] // Extern functions are awkward in doc comments - fake it instead +/// # /* Extern functions are awkward in doc comments - fake it instead /// extern "C" { fn my_string() -> *const c_char; } -/// # unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() } +/// # */ unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() } /// /// fn my_string_safe() -> String { /// let cstr = unsafe { CStr::from_ptr(my_string()) }; @@ -258,7 +258,7 @@ impl CStr { /// /// unsafe { /// let slice = CStr::from_ptr(my_string()); - /// println!("string returned: {}", slice.to_str().unwrap()); + /// assert_eq!(slice.to_str().unwrap(), "hello"); /// } /// ``` ///