Skip to content

Commit

Permalink
Rollup merge of rust-lang#35482 - frewsxcv:patch-31, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Remove unnecessary `main` functions in doc examples.
  • Loading branch information
Jonathan Turner authored Aug 11, 2016
2 parents b179042 + e28521e commit d423c25
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ pub struct CString {
///
/// extern { fn my_string() -> *const c_char; }
///
/// fn main() {
/// unsafe {
/// let slice = CStr::from_ptr(my_string());
/// println!("string length: {}", slice.to_bytes().len());
/// }
/// unsafe {
/// let slice = CStr::from_ptr(my_string());
/// println!("string length: {}", slice.to_bytes().len());
/// }
/// ```
///
Expand All @@ -119,10 +117,8 @@ pub struct CString {
/// unsafe { work_with(data.as_ptr()) }
/// }
///
/// fn main() {
/// let s = CString::new("data data data data").unwrap();
/// work(&s);
/// }
/// let s = CString::new("data data data data").unwrap();
/// work(&s);
/// ```
///
/// Converting a foreign C string into a Rust `String`
Expand All @@ -139,9 +135,7 @@ pub struct CString {
/// }
/// }
///
/// fn main() {
/// println!("string: {}", my_string_safe());
/// }
/// println!("string: {}", my_string_safe());
/// ```
#[derive(Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -188,11 +182,9 @@ impl CString {
///
/// extern { fn puts(s: *const c_char); }
///
/// fn main() {
/// let to_print = CString::new("Hello!").unwrap();
/// unsafe {
/// puts(to_print.as_ptr());
/// }
/// let to_print = CString::new("Hello!").unwrap();
/// unsafe {
/// puts(to_print.as_ptr());
/// }
/// ```
///
Expand Down

0 comments on commit d423c25

Please sign in to comment.