Skip to content

Commit 7130fc5

Browse files
committed
Auto merge of #64972 - Centril:rollup-gcawast, r=Centril
Rollup of 7 pull requests Successful merges: - #63416 (apfloat: improve doc comments) - #64820 (BTreeSet intersection, is_subset & difference optimizations) - #64910 (syntax: cleanup param, method, and misc parsing) - #64912 (Remove unneeded `fn main` blocks from docs) - #64933 (Fixes #64919. Suggest fix based on operator precendence.) - #64943 (Add lower bound doctests for `saturating_{add,sub}` signed ints) - #64950 (Simplify interners) Failed merges: r? @ghost
2 parents 702b45e + adc0dc5 commit 7130fc5

36 files changed

+1093
-1092
lines changed

src/liballoc/boxed.rs

+21-33
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929
//! Nil,
3030
//! }
3131
//!
32-
//! fn main() {
33-
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
34-
//! println!("{:?}", list);
35-
//! }
32+
//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
33+
//! println!("{:?}", list);
3634
//! ```
3735
//!
3836
//! This will print `Cons(1, Cons(2, Nil))`.
@@ -375,14 +373,12 @@ impl<T: ?Sized> Box<T> {
375373
/// ```
376374
/// #![feature(box_into_raw_non_null)]
377375
///
378-
/// fn main() {
379-
/// let x = Box::new(5);
380-
/// let ptr = Box::into_raw_non_null(x);
376+
/// let x = Box::new(5);
377+
/// let ptr = Box::into_raw_non_null(x);
381378
///
382-
/// // Clean up the memory by converting the NonNull pointer back
383-
/// // into a Box and letting the Box be dropped.
384-
/// let x = unsafe { Box::from_raw(ptr.as_ptr()) };
385-
/// }
379+
/// // Clean up the memory by converting the NonNull pointer back
380+
/// // into a Box and letting the Box be dropped.
381+
/// let x = unsafe { Box::from_raw(ptr.as_ptr()) };
386382
/// ```
387383
#[unstable(feature = "box_into_raw_non_null", issue = "47336")]
388384
#[inline]
@@ -428,23 +424,19 @@ impl<T: ?Sized> Box<T> {
428424
/// Simple usage:
429425
///
430426
/// ```
431-
/// fn main() {
432-
/// let x = Box::new(41);
433-
/// let static_ref: &'static mut usize = Box::leak(x);
434-
/// *static_ref += 1;
435-
/// assert_eq!(*static_ref, 42);
436-
/// }
427+
/// let x = Box::new(41);
428+
/// let static_ref: &'static mut usize = Box::leak(x);
429+
/// *static_ref += 1;
430+
/// assert_eq!(*static_ref, 42);
437431
/// ```
438432
///
439433
/// Unsized data:
440434
///
441435
/// ```
442-
/// fn main() {
443-
/// let x = vec![1, 2, 3].into_boxed_slice();
444-
/// let static_ref = Box::leak(x);
445-
/// static_ref[0] = 4;
446-
/// assert_eq!(*static_ref, [4, 2, 3]);
447-
/// }
436+
/// let x = vec![1, 2, 3].into_boxed_slice();
437+
/// let static_ref = Box::leak(x);
438+
/// static_ref[0] = 4;
439+
/// assert_eq!(*static_ref, [4, 2, 3]);
448440
/// ```
449441
#[stable(feature = "box_leak", since = "1.26.0")]
450442
#[inline]
@@ -780,11 +772,9 @@ impl Box<dyn Any> {
780772
/// }
781773
/// }
782774
///
783-
/// fn main() {
784-
/// let my_string = "Hello World".to_string();
785-
/// print_if_string(Box::new(my_string));
786-
/// print_if_string(Box::new(0i8));
787-
/// }
775+
/// let my_string = "Hello World".to_string();
776+
/// print_if_string(Box::new(my_string));
777+
/// print_if_string(Box::new(0i8));
788778
/// ```
789779
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> {
790780
if self.is::<T>() {
@@ -814,11 +804,9 @@ impl Box<dyn Any + Send> {
814804
/// }
815805
/// }
816806
///
817-
/// fn main() {
818-
/// let my_string = "Hello World".to_string();
819-
/// print_if_string(Box::new(my_string));
820-
/// print_if_string(Box::new(0i8));
821-
/// }
807+
/// let my_string = "Hello World".to_string();
808+
/// print_if_string(Box::new(my_string));
809+
/// print_if_string(Box::new(0i8));
822810
/// ```
823811
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any + Send>> {
824812
<Box<dyn Any>>::downcast(self).map_err(|s| unsafe {

src/liballoc/collections/btree/map.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2226,14 +2226,12 @@ impl<'a, K: Ord, V: Default> Entry<'a, K, V> {
22262226
/// # Examples
22272227
///
22282228
/// ```
2229-
/// # fn main() {
22302229
/// use std::collections::BTreeMap;
22312230
///
22322231
/// let mut map: BTreeMap<&str, Option<usize>> = BTreeMap::new();
22332232
/// map.entry("poneyland").or_default();
22342233
///
22352234
/// assert_eq!(map["poneyland"], None);
2236-
/// # }
22372235
/// ```
22382236
pub fn or_default(self) -> &'a mut V {
22392237
match self {

0 commit comments

Comments
 (0)