Skip to content

Remove unnecessary main functions in doc examples. #35482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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