Skip to content
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

Remove unneeded fn main blocks from docs #64912

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
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
12 changes: 0 additions & 12 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
//! Nil,
//! }
//!
//! fn main() {
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
//! println!("{:?}", list);
//! }
//! ```
//!
//! This will print `Cons(1, Cons(2, Nil))`.
Expand Down Expand Up @@ -375,14 +373,12 @@ impl<T: ?Sized> Box<T> {
/// ```
/// #![feature(box_into_raw_non_null)]
///
/// fn main() {
/// let x = Box::new(5);
/// let ptr = Box::into_raw_non_null(x);
///
/// // Clean up the memory by converting the NonNull pointer back
/// // into a Box and letting the Box be dropped.
/// let x = unsafe { Box::from_raw(ptr.as_ptr()) };
/// }
/// ```
#[unstable(feature = "box_into_raw_non_null", issue = "47336")]
#[inline]
Expand Down Expand Up @@ -428,23 +424,19 @@ impl<T: ?Sized> Box<T> {
/// Simple usage:
///
/// ```
/// fn main() {
/// let x = Box::new(41);
/// let static_ref: &'static mut usize = Box::leak(x);
/// *static_ref += 1;
/// assert_eq!(*static_ref, 42);
/// }
/// ```
///
/// Unsized data:
///
/// ```
/// fn main() {
/// let x = vec![1, 2, 3].into_boxed_slice();
/// let static_ref = Box::leak(x);
/// static_ref[0] = 4;
/// assert_eq!(*static_ref, [4, 2, 3]);
/// }
/// ```
#[stable(feature = "box_leak", since = "1.26.0")]
#[inline]
Expand Down Expand Up @@ -780,11 +772,9 @@ impl Box<dyn Any> {
/// }
/// }
///
/// fn main() {
/// let my_string = "Hello World".to_string();
/// print_if_string(Box::new(my_string));
/// print_if_string(Box::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> {
if self.is::<T>() {
Expand Down Expand Up @@ -814,11 +804,9 @@ impl Box<dyn Any + Send> {
/// }
/// }
///
/// fn main() {
/// let my_string = "Hello World".to_string();
/// print_if_string(Box::new(my_string));
/// print_if_string(Box::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any + Send>> {
<Box<dyn Any>>::downcast(self).map_err(|s| unsafe {
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,14 +2226,12 @@ impl<'a, K: Ord, V: Default> Entry<'a, K, V> {
/// # Examples
///
/// ```
/// # fn main() {
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, Option<usize>> = BTreeMap::new();
/// map.entry("poneyland").or_default();
///
/// assert_eq!(map["poneyland"], None);
/// # }
/// ```
pub fn or_default(self) -> &'a mut V {
match self {
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,9 @@ impl Rc<dyn Any> {
/// }
/// }
///
/// fn main() {
/// let my_string = "Hello World".to_string();
/// print_if_string(Rc::new(my_string));
/// print_if_string(Rc::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<dyn Any>> {
if (*self).is::<T>() {
Expand Down
5 changes: 0 additions & 5 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,15 @@ impl<T> [T] {
///
/// ```
/// #![feature(repeat_generic_slice)]
///
/// fn main() {
/// assert_eq!([1, 2].repeat(3), vec![1, 2, 1, 2, 1, 2]);
/// }
/// ```
///
/// A panic upon overflow:
///
/// ```should_panic
/// #![feature(repeat_generic_slice)]
/// fn main() {
/// // this will panic at runtime
/// b"0123456789abcdef".repeat(usize::max_value());
/// }
/// ```
#[unstable(feature = "repeat_generic_slice",
reason = "it's on str, why not on slice?",
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,8 @@ impl str {
/// A panic upon overflow:
///
/// ```should_panic
/// fn main() {
/// // this will panic at runtime
/// "0123456789abcdef".repeat(usize::max_value());
/// }
/// ```
#[stable(feature = "repeat_str", since = "1.16.0")]
pub fn repeat(&self, n: usize) -> String {
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@ use crate::vec::Vec;
///
/// fn example_func<A: TraitExample>(example_arg: A) {}
///
/// fn main() {
/// let example_string = String::from("example_string");
/// example_func(&example_string);
/// }
/// ```
///
/// There are two options that would work instead. The first would be to
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,9 @@ impl Arc<dyn Any + Send + Sync> {
/// }
/// }
///
/// fn main() {
/// let my_string = "Hello World".to_string();
/// print_if_string(Arc::new(my_string));
/// print_if_string(Arc::new(0i8));
/// }
/// ```
pub fn downcast<T>(self) -> Result<Arc<T>, Self>
where
Expand Down
4 changes: 0 additions & 4 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ impl<T> Vec<T> {
/// use std::ptr;
/// use std::mem;
///
/// fn main() {
/// let mut v = vec![1, 2, 3];
///
/// // Pull out the various important pieces of information about `v`
Expand All @@ -411,7 +410,6 @@ impl<T> Vec<T> {
/// let rebuilt = Vec::from_raw_parts(p, len, cap);
/// assert_eq!(rebuilt, [4, 5, 6]);
/// }
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec<T> {
Expand Down Expand Up @@ -1391,12 +1389,10 @@ impl<T> Vec<T> {
/// ```
/// #![feature(vec_leak)]
///
/// fn main() {
/// let x = vec![1, 2, 3];
/// let static_ref: &'static mut [usize] = Vec::leak(x);
/// static_ref[0] += 1;
/// assert_eq!(static_ref, &[2, 2, 3]);
/// }
/// ```
#[unstable(feature = "vec_leak", issue = "62195")]
#[inline]
Expand Down
22 changes: 0 additions & 22 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ pub trait Any: 'static {
/// TypeId::of::<String>() == s.type_id()
/// }
///
/// fn main() {
/// assert_eq!(is_string(&0), false);
/// assert_eq!(is_string(&"cookie monster".to_string()), true);
/// }
/// ```
#[stable(feature = "get_type_id", since = "1.34.0")]
fn type_id(&self) -> TypeId;
Expand Down Expand Up @@ -145,10 +143,8 @@ impl dyn Any {
/// }
/// }
///
/// fn main() {
/// is_string(&0);
/// is_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -179,10 +175,8 @@ impl dyn Any {
/// }
/// }
///
/// fn main() {
/// print_if_string(&0);
/// print_if_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -210,7 +204,6 @@ impl dyn Any {
/// }
/// }
///
/// fn main() {
/// let mut x = 10u32;
/// let mut s = "starlord".to_string();
///
Expand All @@ -219,7 +212,6 @@ impl dyn Any {
///
/// assert_eq!(x, 42);
/// assert_eq!(&s, "starlord");
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -250,10 +242,8 @@ impl dyn Any+Send {
/// }
/// }
///
/// fn main() {
/// is_string(&0);
/// is_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand All @@ -276,10 +266,8 @@ impl dyn Any+Send {
/// }
/// }
///
/// fn main() {
/// print_if_string(&0);
/// print_if_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand All @@ -300,7 +288,6 @@ impl dyn Any+Send {
/// }
/// }
///
/// fn main() {
/// let mut x = 10u32;
/// let mut s = "starlord".to_string();
///
Expand All @@ -309,7 +296,6 @@ impl dyn Any+Send {
///
/// assert_eq!(x, 42);
/// assert_eq!(&s, "starlord");
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand All @@ -334,10 +320,8 @@ impl dyn Any+Send+Sync {
/// }
/// }
///
/// fn main() {
/// is_string(&0);
/// is_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
Expand All @@ -360,10 +344,8 @@ impl dyn Any+Send+Sync {
/// }
/// }
///
/// fn main() {
/// print_if_string(&0);
/// print_if_string(&"cookie monster".to_string());
/// }
/// ```
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
Expand All @@ -384,7 +366,6 @@ impl dyn Any+Send+Sync {
/// }
/// }
///
/// fn main() {
/// let mut x = 10u32;
/// let mut s = "starlord".to_string();
///
Expand All @@ -393,7 +374,6 @@ impl dyn Any+Send+Sync {
///
/// assert_eq!(x, 42);
/// assert_eq!(&s, "starlord");
/// }
/// ```
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
Expand Down Expand Up @@ -437,10 +417,8 @@ impl TypeId {
/// TypeId::of::<String>() == TypeId::of::<T>()
/// }
///
/// fn main() {
/// assert_eq!(is_string(&0), false);
/// assert_eq!(is_string(&"cookie monster".to_string()), true);
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature="const_type_id")]
Expand Down
4 changes: 0 additions & 4 deletions src/libcore/char/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ impl From<char> for u32 {
/// ```
/// use std::mem;
///
/// fn main() {
/// let c = 'c';
/// let u = u32::from(c);
/// assert!(4 == mem::size_of_val(&u))
/// }
/// ```
#[inline]
fn from(c: char) -> Self {
Expand Down Expand Up @@ -150,11 +148,9 @@ impl From<u8> for char {
/// ```
/// use std::mem;
///
/// fn main() {
/// let u = 32 as u8;
/// let c = char::from(u);
/// assert!(4 == mem::size_of_val(&c))
/// }
/// ```
#[inline]
fn from(i: u8) -> Self {
Expand Down
Loading