Lines Matching defs:new

14     let mut m: LinkedList<_> = LinkedList::new();
22 let mut m: LinkedList<_> = LinkedList::new();
30 let mut m: LinkedList<_> = LinkedList::new();
39 let mut m: LinkedList<_> = LinkedList::new();
389 let mut r = String::new();
400 let mut r = String::new();
411 let mut r = String::new();
422 let mut r = String::new();
547 b.iter(|| Vec::<u32>::new())
754 let mut to_extend = black_box(Vec::new());
1147 let mut v = Vec::<u32>::new();
1167 let mut v = Vec::<u32>::new();
1308 let mut map = $map::new();
1332 let mut map = $map::new();
1355 let mut map = $map::new();
1383 let mut map = $map::new();
1415 let mut map = BTreeMap::<i32, i32>::new();
1445 let mut map = BTreeMap::<i32, i32>::new();
1812 let mut set = BTreeSet::new();
1834 let mut sets = [BTreeSet::new(), BTreeSet::new()];
2085 let mut vec = Vec::<i32>::new();
2419 let ring: VecDeque<i32> = VecDeque::new();
2427 let mut deq = VecDeque::new();
2597 let mut m = LinkedList::<Box<_>>::new();
2616 let mut n = LinkedList::new();
2647 let mut m = LinkedList::new();
2688 let mut m = LinkedList::new();
2705 let mut n = LinkedList::new();
2717 let mut n = LinkedList::new();
2731 let mut n = LinkedList::new();
2753 let mut n = LinkedList::new();
2772 let mut n = LinkedList::new();
2786 let mut n = LinkedList::new();
2808 let mut n = LinkedList::new();
2835 let mut x = LinkedList::new();
2836 let mut y = LinkedList::new();
2904 let mut a = LinkedList::new();
2912 let mut b = LinkedList::new();
2923 let mut a = LinkedList::new();
2939 let mut l = LinkedList::new();
2952 let mut list: LinkedList<i32> = LinkedList::new();
3143 let mut q = LinkedList::new();
3174 let mut q = LinkedList::new();
3205 let mut ring = LinkedList::new();
3227 let mut ring = LinkedList::new();
3253 let mut ring = LinkedList::new();
3283 let mut q = LinkedList::new();
3307 let mut a = Weak::<Void>::new();
3318 let a: Arc<[u32; 3]> = Arc::new([3, 2, 1]);
3331 let a: Arc<u32> = Arc::new(4);
3339 let mut b = Weak::<u32>::new();
3349 let x = Arc::new(f32::NAN);
3364 let x = Arc::new(TestPEq(RefCell::new(0)));
3381 let x = Arc::new(TestEq(RefCell::new(0)));
3401 let iter = (0..SHARED_ITER_MAX).filter(|x| x % 2 == 0).map(Box::new);
3422 let iter = (0..SHARED_ITER_MAX).map(Box::new);
3461 _ => Box::new(val),
3489 let vec = vec![Some(Box::new(42)), Some(Box::new(24)), None, Some(Box::new(12))];
3492 assert_eq!(&[Box::new(42), Box::new(24)], &*iter.collect::<Rc<[_]>>());
3666 WeirdBorrow { state: Cell::new(false) }
3694 let mut rs = String::new();
3703 let mut rs = String::new();
4007 let mut rs = String::new();
4016 let mut rs = String::new();
5602 let mut x = BTreeSet::new();
5603 let mut y = BTreeSet::new();
5832 let mut s = String::new();
5843 let mut s = String::new();
6228 s.replace_range(EvilRange(Cell::new(false)), "");
6251 s.replace_range(EvilRange(Cell::new(false)), "");
6274 let mut s = String::new();
6317 let mut empty_string: String = String::new();
6397 let mut empty_string: String = String::new();
6508 let string = OsStr::new("hello");
6514 let path = Path::new("hello");
6566 let mut tv = TwoVec { x: Vec::new(), y: Vec::new() };
6584 let mut v = Vec::new();
6606 assert_eq!(Vec::<()>::new().capacity(), usize::MAX);
6647 let mut v = Vec::new();
6648 let mut w = Vec::new();
6674 let mut a = Vec::new();
6683 let mut x = Vec::new();
6822 let v = (0..5).map(Rc::new).collect::<Vec<_>>();
6839 let v = (0..5).map(Rc::new).collect::<Vec<_>>();
6864 let v = (0..5).map(|x| Rc::new(x)).collect::<Vec<_>>();
6947 let mut v = Vec::new();
7108 let mut vec = Vec::<i32>::new();
7224 assert_eq!(v, Vec::<String>::new());
7536 .map(|e| if e != usize::MAX { Ok(std::num::NonZeroUsize::new(e)) } else { Err(()) });
7545 let drop_count: Vec<_> = (0..=2).map(|_| Rc::new(())).collect();
7560 let drop_count: Vec<_> = (0..=2).map(|_| Rc::new(())).collect();
7614 let mut v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop];
7647 fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
7650 fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> {
7858 let drop_counts = Rc::new(Mutex::new(vec![0_usize; check_count]));
7910 let drop_counts = Rc::new(Mutex::new(vec![0_usize; check_count]));
7953 let mut v = Vec::new();
7996 let mut empty_bytes: Vec<u8> = Vec::new();
8104 let mut empty_bytes: Vec<u8> = Vec::new();
8496 fn new() -> C<'a> {
8497 C { v: Vec::new() }
8501 let mut c1 = C::new();
8502 let mut c2 = C::new();
8503 let mut c3 = C::new();
8506 c1.v.push(Cell::new(None));
8507 c1.v.push(Cell::new(None));
8509 c2.v.push(Cell::new(None));
8510 c2.v.push(Cell::new(None));
8512 c3.v.push(Cell::new(None));
8513 c3.v.push(Cell::new(None));
8537 fn new() -> Refs<'a> {
8538 Refs { v: Vec::new() }
8543 fn new() -> C<'a> {
8544 C { refs: Refs::new() }
8548 let mut c1 = C::new();
8549 let mut c2 = C::new();
8550 let mut c3 = C::new();
8552 c1.refs.v.push(Cell::new(None));
8553 c1.refs.v.push(Cell::new(None));
8554 c2.refs.v.push(Cell::new(None));
8555 c2.refs.v.push(Cell::new(None));
8556 c3.refs.v.push(Cell::new(None));
8557 c3.refs.v.push(Cell::new(None));
8592 let el = Box::new(1);
8594 assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]);
8664 let mut v = Vec::<i32>::new();
8690 let mut vec: Vec<i32> = Vec::new();
8774 static DROP_COUNTER: AtomicU32 = AtomicU32::new(0);
8829 let count = core::sync::atomic::AtomicU32::new(0);
8890 let mut s = DefaultHasher::new();
8902 let mut hasher_1 = Box::new(DefaultHasher::new());
8906 let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
8921 let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
8949 let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
8974 let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
9014 let owned_empty: Cow<'_, str> = Cow::Owned(String::new());
9064 let mut a = Weak::<Void>::new();
9075 let a: Rc<[u32; 3]> = Rc::new([3, 2, 1]);
9088 let a: Rc<u32> = Rc::new(4);
9096 let mut b = Weak::<u32>::new();
9106 let x = Rc::new(f32::NAN);
9121 let x = Rc::new(TestPEq(RefCell::new(0)));
9138 let x = Rc::new(TestEq(RefCell::new(0)));
9154 let iter = (0..SHARED_ITER_MAX).filter(|x| x % 2 == 0).map(Box::new);
9175 let iter = (0..SHARED_ITER_MAX).map(Box::new);
9214 _ => Box::new(val),
9242 let vec = vec![Some(Box::new(42)), Some(Box::new(24)), None, Some(Box::new(12))];
9245 assert_eq!(&[Box::new(42), Box::new(24)], &*iter.collect::<Rc<[_]>>());
9515 let mut v: Vec<Box<_>> = Vec::new();
9621 let mut v3 = Vec::<i32>::new();
9756 let mut v = Vec::new();
9791 let mut v = Vec::new();
10376 let empty = Vec::<i32>::new();
10417 let mut v = vec![Rc::new(1)];
10419 v.push(Rc::new(2));
10754 let drop_count = Arc::new(AtomicUsize::new(0));
10800 AtomicUsize::new(0),
10801 AtomicUsize::new(0),
10802 AtomicUsize::new(0),
10803 AtomicUsize::new(0),
10804 AtomicUsize::new(0),
10805 AtomicUsize::new(0),
10806 AtomicUsize::new(0),
10807 AtomicUsize::new(0),
10808 AtomicUsize::new(0),
10809 AtomicUsize::new(0),
10810 AtomicUsize::new(0),
10811 AtomicUsize::new(0),
10812 AtomicUsize::new(0),
10813 AtomicUsize::new(0),
10814 AtomicUsize::new(0),
10815 AtomicUsize::new(0),
10816 AtomicUsize::new(0),
10817 AtomicUsize::new(0),
10818 AtomicUsize::new(0),
10819 AtomicUsize::new(0),
10820 AtomicUsize::new(0),
10821 AtomicUsize::new(0),
10822 AtomicUsize::new(0),
10823 AtomicUsize::new(0),
10824 AtomicUsize::new(0),
10825 AtomicUsize::new(0),
10826 AtomicUsize::new(0),
10827 AtomicUsize::new(0),
10828 AtomicUsize::new(0),
10829 AtomicUsize::new(0),
10830 AtomicUsize::new(0),
10831 AtomicUsize::new(0),
10832 AtomicUsize::new(0),
10833 AtomicUsize::new(0),
10834 AtomicUsize::new(0),
10835 AtomicUsize::new(0),
10836 AtomicUsize::new(0),
10837 AtomicUsize::new(0),
10838 AtomicUsize::new(0),
10839 AtomicUsize::new(0),
10840 AtomicUsize::new(0),
10841 AtomicUsize::new(0),
10842 AtomicUsize::new(0),
10843 AtomicUsize::new(0),
10844 AtomicUsize::new(0),
10845 AtomicUsize::new(0),
10846 AtomicUsize::new(0),
10847 AtomicUsize::new(0),
10848 AtomicUsize::new(0),
10849 AtomicUsize::new(0),
10850 AtomicUsize::new(0),
10851 AtomicUsize::new(0),
10852 AtomicUsize::new(0),
10853 AtomicUsize::new(0),
10854 AtomicUsize::new(0),
10855 AtomicUsize::new(0),
10856 AtomicUsize::new(0),
10857 AtomicUsize::new(0),
10858 AtomicUsize::new(0),
10859 AtomicUsize::new(0),
10860 AtomicUsize::new(0),
10861 AtomicUsize::new(0),
10862 AtomicUsize::new(0),
10863 AtomicUsize::new(0),
10864 AtomicUsize::new(0),
10865 AtomicUsize::new(0),
10866 AtomicUsize::new(0),
10867 AtomicUsize::new(0),
10868 AtomicUsize::new(0),
10869 AtomicUsize::new(0),
10870 AtomicUsize::new(0),
10871 AtomicUsize::new(0),
10872 AtomicUsize::new(0),
10873 AtomicUsize::new(0),
10874 AtomicUsize::new(0),
10875 AtomicUsize::new(0),
10876 AtomicUsize::new(0),
10877 AtomicUsize::new(0),
10878 AtomicUsize::new(0),
10879 AtomicUsize::new(0),
10882 static VERSIONS: AtomicUsize = AtomicUsize::new(0);
10966 thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
10972 panic::set_hook(Box::new(move |info| {
10991 version: Cell::new(0),
11219 let mut d = VecDeque::new();
11253 let mut deq = VecDeque::new();
11284 let mut deq = VecDeque::new();
11294 let mut deq = VecDeque::new();
11306 let mut deq = VecDeque::new();
11316 let mut deq = VecDeque::new();
11440 let mut d = VecDeque::new();
11448 let mut d = VecDeque::new();
11464 let mut d = VecDeque::new();
11499 let mut d = VecDeque::new();
11533 let mut d = VecDeque::new();
11556 let mut d = VecDeque::new();
11581 let d: VecDeque<i32> = VecDeque::new();
11591 let mut d = VecDeque::new();
11602 let mut d = VecDeque::new();
11616 let mut d = VecDeque::new();
11639 let mut d: VecDeque<i32> = VecDeque::new();
11654 let mut d = VecDeque::new();
11665 let mut d = VecDeque::new();
11679 let mut d: VecDeque<_> = VecDeque::new();
11718 let mut d = VecDeque::new();
11735 let mut d = VecDeque::new();
11751 assert!(e == VecDeque::new());
11756 let d = VecDeque::<char>::new();
11759 let mut d = VecDeque::new();
11763 let mut d = VecDeque::new();
11767 let mut d = VecDeque::new();
11775 let mut x = VecDeque::new();
11776 let mut y = VecDeque::new();
11839 let x = VecDeque::new();
11840 let mut y = VecDeque::new();
11871 let mut ring = VecDeque::new();
11893 let mut ring = VecDeque::new();
11919 let mut ring = VecDeque::new();
11949 let mut q = VecDeque::new();
12010 let mut ring = VecDeque::new();
12042 let mut ring = VecDeque::new();
12065 let mut ring = VecDeque::new();
12160 let mut out = VecDeque::new();
12242 let mut a = VecDeque::new();
12243 let mut b = VecDeque::new();
12255 let mut buf = VecDeque::new();
12264 let mut v = VecDeque::new();
12274 let mut w = VecDeque::new();
12290 let mut v = VecDeque::new();
12303 fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
12310 let mut v = VecDeque::<i32>::new();
12333 let mut v = VecDeque::new();
12375 let mut empty_bytes: VecDeque<u8> = VecDeque::new();
12480 let mut empty_bytes: VecDeque<u8> = VecDeque::new();
12698 assert_eq!(Some(0), VecDeque::<u32>::new().iter().try_fold(0, |_, _| None));
12813 let mut q = VecDeque::new();
12847 let mut v = VecDeque::new();
13177 let a = Box::new(3);
13197 let mut buf = String::new();
13227 let mut buf = String::new();
13276 let refcell = RefCell::new(5);
13529 let mut heap = BinaryHeap::<i32>::new();
13535 let empty = BinaryHeap::<i32>::new();
13541 let mut empty = BinaryHeap::<i32>::new();
13576 static DROPS: AtomicU32 = AtomicU32::new(0);
13607 let mut a = BinaryHeap::new();
13616 let mut a = BinaryHeap::new();
13619 let mut b = BinaryHeap::new();
13643 let mut a = BinaryHeap::new();
13664 fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
13705 static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
13827 let x = Box::new(Cell::new(5));
13902 /// example, `vec![Rc::new(1); 5]` will create a vector of five references
13919 $crate::__rust_force_expr!($crate::vec::Vec::new())
13936 $crate::vec::Vec::new()
14074 /// let layout = Layout::new::<u16>();
14144 /// let layout = Layout::new::<u16>();
14167 let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
14199 let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
14207 // both the old and new memory allocation are valid for reads and writes for `old_size`
14290 let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
14295 // both the old and new memory allocation are valid for reads and writes for `new_size`
14442 /// The contents of the new memory are uninitialized.
14444 /// The new memory is guaranteed to be zeroed.
14479 /// they cannot call `Self::new()`.
14481 /// If you change `RawVec<T>::new` or dependencies, please take care to not introduce anything
14483 pub const NEW: Self = Self::new();
14490 pub const fn new() -> Self {
14496 /// equivalent to calling `RawVec::new` when `capacity` is `0` or `T` is
14546 /// Like `new`, but parameterized over the choice of allocator for
14595 let me = ManuallyDrop::new(self);
14698 /// Panics if the new capacity exceeds `isize::MAX` bytes.
14730 /// # let mut vector = MyVec { buf: RawVec::new(), len: 0 };
14775 /// Panics if the new capacity exceeds `isize::MAX` bytes.
15216 /// `replace` creates a new [`String`], and copies the data from this string slice into it.
15227 /// assert_eq!("this is new", s.replace("old", "new"));
15236 #[must_use = "this returns the replaced string as a new allocation, \
15241 let mut result = String::new();
15254 /// `replacen` creates a new [`String`], and copies the data from this string slice into it.
15264 /// assert_eq!("new new 123 foo", s.replacen("foo", "new", 2));
15266 /// assert_eq!("foo foo new23 foo", s.replacen(char::is_numeric, "new", 1));
15275 #[must_use = "this returns the replaced string as a new allocation, \
15291 /// Returns the lowercase equivalent of this string slice, as a new [`String`].
15376 /// Returns the uppercase equivalent of this string slice, as a new [`String`].
15448 /// Creates a new [`String`] by repeating a string `n` times.
15542 /// let smile_utf8 = Box::new([226, 152, 186]);
15588 let arc_v = Arc::new(v);
15605 let mut x = Arc::new(3);
15618 assert_eq!(Weak::weak_count(&Weak::<u64>::new()), 0);
15619 assert_eq!(Weak::strong_count(&Weak::<u64>::new()), 0);
15621 let a = Arc::new(0);
15645 let x = Arc::new(3);
15647 let x = Arc::new(4);
15649 assert_eq!(Arc::try_unwrap(x), Err(Arc::new(4)));
15650 let x = Arc::new(5);
15657 let x = Arc::new(box "hello");
15685 let arc: Arc<dyn Display> = Arc::new(123);
15696 let x = Arc::new(box "hello");
15726 let arc: Arc<dyn Display> = Arc::new(123);
15738 let mut cow0 = Arc::new(75);
15762 let mut cow0 = Arc::new(75);
15784 let mut cow0 = Arc::new(75);
15798 let x = Arc::new(5);
15805 let x = Arc::new(5);
15817 let a = Arc::new(Cycle { x: Mutex::new(None) });
15826 let mut canary = atomic::AtomicUsize::new(0);
15827 let x = Arc::new(Canary(&mut canary as *mut atomic::AtomicUsize));
15834 let mut canary = atomic::AtomicUsize::new(0);
15835 let arc = Arc::new(Canary(&mut canary as *mut atomic::AtomicUsize));
15845 let a = Arc::new(0);
15862 let a = Arc::new(0);
15888 let a = Arc::new(5);
15900 let x: Arc<[i32]> = Arc::new([1, 2, 3]);
15912 let x: Arc<CStr> = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
15933 let foo: Weak<usize> = Weak::new();
15939 let five = Arc::new(5);
15941 let other_five = Arc::new(5);
15950 let mut a = Arc::new(atomic::AtomicBool::new(false));
16078 let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::MAX);
16079 let r2: Arc<dyn Any + Send + Sync> = Arc::new("abc");
16085 assert_eq!(r1i32.unwrap(), Arc::new(i32::MAX));
16091 assert_eq!(r2str.unwrap(), Arc::new("abc"));
16114 ZeroRefs { inner: Weak::new() }
16180 //! There are multiple ways to create a new [`String`] from a string literal:
16189 //! You can create a new [`String`] from an existing one by concatenating with
16367 /// let mut story = mem::ManuallyDrop::new(story);
16392 /// let mut s = String::new();
16515 /// Creates a new empty `String`.
16531 /// let s = String::new();
16536 pub const fn new() -> String {
16537 String { vec: Vec::new() }
16540 /// Creates a new empty `String` with a particular capacity.
16552 /// is identical to the [`new`] method.
16554 /// [`new`]: String::new
16682 /// it's already valid UTF-8, we don't need a new allocation. This return
16832 #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
16837 /// Creates a new `String` from a length, capacity, and pointer.
16871 /// let mut s = mem::ManuallyDrop::new(s);
17026 /// Panics if the new capacity overflows [`usize`].
17035 /// let mut s = String::new();
17075 /// Panics if the new capacity overflows `usize`.
17082 /// let mut s = String::new();
17130 /// let mut output = String::new();
17142 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
17168 /// let mut output = String::new();
17180 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
17228 #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
17396 #[unstable(feature = "string_remove_matches", reason = "new API", issue = "72826")]
17405 let mut matches = Vec::new();
17641 /// let mut v = String::new();
17936 let mut buf = String::new();
17945 let mut buf = String::new();
17954 let mut buf = String::new();
17969 None => String::new(),
17981 let mut buf = String::new();
17996 None => String::new(),
18184 String::new()
18215 /// necessary). This is done to avoid allocating a new `String` and copying the entire contents on
18447 let mut buf = String::new();
18883 /// let mut s: String = String::new();
18886 /// let mut v: Vec<i32> = Vec::new();
18967 /// fn new(v: Cow<'a, [X]>) -> Self {
18974 /// let borrowed = Items::new((&readonly[..]).into());
18981 /// // Mutates the data from slice into owned vec and pushes a new value on top
19500 //! allocated in the heap. Invoking [`clone`][clone] on [`Rc`] produces a new
19538 //! let my_rc = Rc::new(());
19549 //! let rc = Rc::new(());
19561 //! Creating a new reference to the same allocation as an existing reference counted pointer
19567 //! let foo = Rc::new(vec![1.0, 2.0, 3.0]);
19576 //! this code is creating a new reference rather than copying the whole content of foo.
19602 //! let gadget_owner: Rc<Owner> = Rc::new(
19609 //! // gives us a new pointer to the same `Owner` allocation, incrementing
19675 //! let gadget_owner: Rc<Owner> = Rc::new(
19678 //! gadgets: RefCell::new(vec![]),
19683 //! let gadget1 = Rc::new(
19689 //! let gadget2 = Rc::new(
19827 /// Constructs a new `Rc<T>`.
19834 /// let five = Rc::new(5);
19837 pub fn new(value: T) -> Rc<T> {
19843 Box::leak(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value }).into(),
19847 /// Constructs a new `Rc<T>` using a weak reference to itself. Attempting
19864 /// pub fn new() -> Rc<Self> {
19876 strong: Cell::new(0),
19877 weak: Cell::new(1),
19911 /// Constructs a new `Rc` with uninitialized contents.
19936 Layout::new::<T>(),
19943 /// Constructs a new `Rc` with uninitialized contents, with the memory
19967 Layout::new::<T>(),
19974 /// Constructs a new `Rc<T>`, returning an error if the allocation fails
19992 Box::leak(Box::try_new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value })?)
19997 /// Constructs a new `Rc` with uninitialized contents, returning an error if the allocation fails
20024 Layout::new::<T>(),
20031 /// Constructs a new `Rc` with uninitialized contents, with the memory
20057 Layout::new::<T>(),
20063 /// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
20067 unsafe { Pin::new_unchecked(Rc::new(value)) }
20082 /// let x = Rc::new(3);
20085 /// let x = Rc::new(4);
20112 /// Constructs a new reference-counted slice with uninitialized contents.
20140 /// Constructs a new reference-counted slice with uninitialized contents, with the memory being
20210 Rc::from_inner(mem::ManuallyDrop::new(self).ptr.cast())
20251 unsafe { Rc::from_ptr(mem::ManuallyDrop::new(self).ptr.as_ptr() as _) }
20268 /// let x = Rc::new("hello".to_owned());
20289 /// let x = Rc::new("hello".to_owned());
20329 /// let x = Rc::new("hello".to_owned());
20353 /// Creates a new [`Weak`] pointer to this allocation.
20360 /// let five = Rc::new(5);
20379 /// let five = Rc::new(5);
20397 /// let five = Rc::new(5);
20422 /// let five = Rc::new(5);
20436 let rc = unsafe { mem::ManuallyDrop::new(Rc::<T>::from_raw(ptr)) };
20437 // Now increase refcount, but don't drop new refcount either
20457 /// let five = Rc::new(5);
20499 /// let mut x = Rc::new(3);
20524 /// for example immediately after `Rc::new`.
20533 /// let mut x = Rc::new(String::new());
20557 /// let five = Rc::new(5);
20559 /// let other_five = Rc::new(5);
20575 /// [`clone`] the inner value to a new allocation to ensure unique ownership. This is also
20591 /// let mut data = Rc::new(5);
20609 /// let mut data = Rc::new(75);
20673 /// print_if_string(Rc::new(my_string));
20674 /// print_if_string(Rc::new(0i8));
20702 let layout = Layout::new::<RcBox<()>>().extend(value_layout).unwrap().0.pad_to_align();
20725 let layout = Layout::new::<RcBox<()>>().extend(value_layout).unwrap().0.pad_to_align();
20735 ptr::write(&mut (*inner).strong, Cell::new(1));
20736 ptr::write(&mut (*inner).weak, Cell::new(1));
20806 // into the new RcBox will be dropped, then the memory freed.
20841 // All clear. Forget the guard so it doesn't free the new RcBox.
20902 /// let foo = Rc::new(Foo);
20939 /// let five = Rc::new(5);
20952 /// Creates a new `Rc<T>`, with the `Default` value for `T`.
20964 Rc::new(Default::default())
21029 /// let five = Rc::new(5);
21031 /// assert!(five == Rc::new(5));
21051 /// let five = Rc::new(5);
21053 /// assert!(five != Rc::new(6));
21076 /// let five = Rc::new(5);
21078 /// assert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
21094 /// let five = Rc::new(5);
21096 /// assert!(five < Rc::new(6));
21112 /// let five = Rc::new(5);
21114 /// assert!(five <= Rc::new(5));
21130 /// let five = Rc::new(5);
21132 /// assert!(five > Rc::new(4));
21148 /// let five = Rc::new(5);
21150 /// assert!(five >= Rc::new(5));
21170 /// let five = Rc::new(5);
21172 /// assert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
21211 Rc::new(t)
21271 /// Move a boxed object to a new, reference counted, allocation.
21277 /// let original: Box<i32> = Box::new(1);
21295 /// let original: Box<Vec<i32>> = Box::new(vec![1, 2, 3]);
21446 // `Weak::new` sets this to `usize::MAX` so that it doesn’t need
21465 /// Constructs a new `Weak<T>`, without allocating any memory.
21475 /// let empty: Weak<i64> = Weak::new();
21479 pub fn new() -> Weak<T> {
21480 Weak { ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0") }
21508 /// let strong = Rc::new("hello".to_owned());
21552 /// let strong = Rc::new("hello".to_owned());
21577 /// It takes ownership of one weak reference (with the exception of pointers created by [`new`],
21595 /// let strong = Rc::new("hello".to_owned());
21613 /// [`new`]: Weak::new
21644 /// let five = Rc::new(5);
21670 /// If `self` was created using [`Weak::new`], this will return 0.
21693 /// (i.e., when this `Weak` was created by `Weak::new`).
21711 /// (because they were created with `Weak::new()`).
21715 /// Since this compares pointers it means that `Weak::new()` will equal each
21723 /// let first_rc = Rc::new(5);
21729 /// let third_rc = Rc::new(5);
21735 /// Comparing `Weak::new`.
21740 /// let first = Weak::new();
21741 /// let second = Weak::new();
21744 /// let third_rc = Rc::new(());
21774 /// let foo = Rc::new(Foo);
21806 /// let weak_five = Rc::downgrade(&Rc::new(5));
21828 /// Constructs a new `Weak<T>`, without allocating any memory.
21843 Weak::new()
21969 let layout = Layout::new::<RcBox<()>>();
22408 /// Copies `self` into a new `Vec`.
22427 /// Copies `self` into a new `Vec` with an allocator.
22458 /// let s: Box<[i32]> = Box::new([10, 40, 30]);
22497 return Vec::new();
22832 let mut tmp = mem::ManuallyDrop::new(ptr::read(&v[0]));
23091 // algorithm should continue building a new run instead, `None` is returned.
23174 /// // Create a new context to be passed to the future.
23176 /// let waker = Arc::new(ThreadWaker(t)).into();
23243 RawWaker::new(
23245 &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
23257 let waker = unsafe { ManuallyDrop::new(Arc::from_raw(waker as *const W)) };
23266 RawWaker::new(
23268 &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
23335 /// a new `Arc` instance, which points to the same allocation on the heap as the
23387 /// Creating a new reference from an existing reference-counted pointer is done using the
23392 /// let foo = Arc::new(vec![1.0, 2.0, 3.0]);
23409 /// let my_arc = Arc::new(());
23420 /// let arc = Arc::new(());
23457 /// let five = Arc::new(5);
23477 /// let val = Arc::new(AtomicUsize::new(5));
23545 // `Weak::new` sets this to `usize::MAX` so that it doesn’t need
23588 /// Constructs a new `Arc<T>`.
23595 /// let five = Arc::new(5);
23599 pub fn new(data: T) -> Arc<T> {
23603 strong: atomic::AtomicUsize::new(1),
23604 weak: atomic::AtomicUsize::new(1),
23610 /// Constructs a new `Arc<T>` using a weak reference to itself. Attempting
23636 strong: atomic::AtomicUsize::new(0),
23637 weak: atomic::AtomicUsize::new(1),
23683 /// Constructs a new `Arc` with uninitialized contents.
23708 Layout::new::<T>(),
23715 /// Constructs a new `Arc` with uninitialized contents, with the memory
23739 Layout::new::<T>(),
23746 /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
23750 unsafe { Pin::new_unchecked(Arc::new(data)) }
23753 /// Constructs a new `Arc<T>`, returning an error if allocation fails.
23770 strong: atomic::AtomicUsize::new(1),
23771 weak: atomic::AtomicUsize::new(1),
23777 /// Constructs a new `Arc` with uninitialized contents, returning an error
23805 Layout::new::<T>(),
23812 /// Constructs a new `Arc` with uninitialized contents, with the memory
23838 Layout::new::<T>(),
23856 /// let x = Arc::new(3);
23859 /// let x = Arc::new(4);
23885 /// Constructs a new atomically reference-counted slice with uninitialized contents.
23913 /// Constructs a new atomically reference-counted slice with uninitialized contents, with the memory being
23983 Arc::from_inner(mem::ManuallyDrop::new(self).ptr.cast())
24024 unsafe { Arc::from_ptr(mem::ManuallyDrop::new(self).ptr.as_ptr() as _) }
24039 /// let x = Arc::new("hello".to_owned());
24060 /// let x = Arc::new("hello".to_owned());
24100 /// let x = Arc::new("hello".to_owned());
24125 /// Creates a new [`Weak`] pointer to this allocation.
24132 /// let five = Arc::new(5);
24181 /// let five = Arc::new(5);
24210 /// let five = Arc::new(5);
24237 /// let five = Arc::new(5);
24253 let arc = unsafe { mem::ManuallyDrop::new(Arc::<T>::from_raw(ptr)) };
24254 // Now increase refcount, but don't drop new refcount either
24274 /// let five = Arc::new(5);
24325 /// let five = Arc::new(5);
24327 /// let other_five = Arc::new(5);
24354 let layout = Layout::new::<ArcInner<()>>().extend(value_layout).unwrap().0.pad_to_align();
24376 let layout = Layout::new::<ArcInner<()>>().extend(value_layout).unwrap().0.pad_to_align();
24385 ptr::write(&mut (*inner).strong, atomic::AtomicUsize::new(1));
24386 ptr::write(&mut (*inner).weak, atomic::AtomicUsize::new(1));
24458 // into the new ArcInner will be dropped, then the memory freed.
24493 // All clear. Forget the guard so it doesn't free the new ArcInner.
24532 /// let five = Arc::new(5);
24585 /// then `make_mut` will create a new allocation and invoke [`clone`][clone] on the inner value
24602 /// let mut data = Arc::new(5);
24637 // dropped. Worst case, we end up allocated a new Arc unnecessarily.
24640 // refs remaining. We'll move the contents to a new Arc, and
24688 /// let mut x = Arc::new(3);
24722 /// for example immediately after `Arc::new`.
24731 /// let mut x = Arc::new(String::new());
24795 /// let foo = Arc::new(Foo);
24864 /// print_if_string(Arc::new(my_string));
24865 /// print_if_string(Arc::new(0i8));
24882 /// Constructs a new `Weak<T>`, without allocating any memory.
24892 /// let empty: Weak<i64> = Weak::new();
24896 pub fn new() -> Weak<T> {
24897 Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0") }
24920 /// let strong = Arc::new("hello".to_owned());
24964 /// let strong = Arc::new("hello".to_owned());
24989 /// It takes ownership of one weak reference (with the exception of pointers created by [`new`],
25006 /// let strong = Arc::new("hello".to_owned());
25022 /// [`new`]: Weak::new
25058 /// let five = Arc::new(5);
25094 // Relaxed is fine for the failure case because we don't have any expectations about the new state.
25107 /// If `self` was created using [`Weak::new`], this will return 0.
25116 /// If `self` was created using [`Weak::new`], or if there are no remaining
25145 /// (i.e., when this `Weak` was created by `Weak::new`).
25163 /// (because they were created with `Weak::new()`).
25167 /// Since this compares pointers it means that `Weak::new()` will equal each
25175 /// let first_rc = Arc::new(5);
25181 /// let third_rc = Arc::new(5);
25187 /// Comparing `Weak::new`.
25192 /// let first = Weak::new();
25193 /// let second = Weak::new();
25196 /// let third_rc = Arc::new(());
25218 /// let weak_five = Arc::downgrade(&Arc::new(5));
25246 /// Constructs a new `Weak<T>`, without allocating memory.
25261 Weak::new()
25282 /// let foo = Arc::new(Foo);
25362 /// let five = Arc::new(5);
25364 /// assert!(five == Arc::new(5));
25383 /// let five = Arc::new(5);
25385 /// assert!(five != Arc::new(6));
25405 /// let five = Arc::new(5);
25407 /// assert_eq!(Some(Ordering::Less), five.partial_cmp(&Arc::new(6)));
25422 /// let five = Arc::new(5);
25424 /// assert!(five < Arc::new(6));
25439 /// let five = Arc::new(5);
25441 /// assert!(five <= Arc::new(5));
25456 /// let five = Arc::new(5);
25458 /// assert!(five > Arc::new(4));
25473 /// let five = Arc::new(5);
25475 /// assert!(five >= Arc::new(5));
25493 /// let five = Arc::new(5);
25495 /// assert_eq!(Ordering::Less, five.cmp(&Arc::new(6)));
25527 /// Creates a new `Arc<T>`, with the `Default` value for `T`.
25538 Arc::new(Default::default())
25552 Arc::new(t)
25612 /// Move a boxed object to a new, reference-counted allocation.
25798 let layout = Layout::new::<ArcInner<()>>();
26255 //! let mut w = Vec::new();
26396 let x = Rc::new(RefCell::new(5));
26404 let x = Rc::new(5);
26410 let x = Rc::new(5);
26418 let x: Rc<Box<_>> = Rc::new(box 5);
26424 let x = Rc::new(5);
26431 let x = Rc::new(5);
26443 let a = Rc::new(Cycle { x: RefCell::new(None) });
26452 let x = Rc::new(3);
26466 let a = Rc::new(0);
26483 let a = Rc::new(0);
26500 assert_eq!(Weak::weak_count(&Weak::<u64>::new()), 0);
26501 assert_eq!(Weak::strong_count(&Weak::<u64>::new()), 0);
26503 let a = Rc::new(0);
26527 let x = Rc::new(3);
26529 let x = Rc::new(4);
26531 assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
26532 let x = Rc::new(5);
26539 let x = Rc::new(box "hello");
26567 let rc: Rc<dyn Display> = Rc::new(123);
26578 let x = Rc::new(box "hello");
26608 let arc: Rc<dyn Display> = Rc::new(123);
26620 let mut x = Rc::new(3);
26633 let mut cow0 = Rc::new(75);
26657 let mut cow0 = Rc::new(75);
26680 let mut cow0 = Rc::new(75);
26694 let foo = Rc::new(75);
26700 let foo: Rc<[i32]> = Rc::new([1, 2, 3]);
26709 let x: Rc<CStr> = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
26730 let foo: Weak<usize> = Weak::new();
26736 let five = Rc::new(5);
26738 let other_five = Rc::new(5);
26852 let r1: Rc<dyn Any> = Rc::new(i32::MAX);
26853 let r2: Rc<dyn Any> = Rc::new("abc");
26859 assert_eq!(r1i32.unwrap(), Rc::new(i32::MAX));
26865 assert_eq!(r2str.unwrap(), Rc::new("abc"));
26889 ZeroRefs { inner: Weak::new() }
27065 fn new(element: T) -> Self {
27088 // Not creating new mutable (unique!) references overlapping `element`.
27108 // Not creating new mutable (unique!) references overlapping `element`.
27129 // Not creating new mutable (unique!) references overlapping `element`.
27149 // Not creating new mutable (unique!) references overlapping `element`.
27168 // Not creating new mutable (unique!) references overlapping `element`.
27240 // The split node is the new head node of the second part
27269 mem::replace(self, LinkedList::new())
27279 // The split node is the new tail node of the first part and owns
27309 mem::replace(self, LinkedList::new())
27319 Self::new()
27331 /// let list: LinkedList<u32> = LinkedList::new();
27336 pub const fn new() -> Self {
27352 /// let mut list1 = LinkedList::new();
27355 /// let mut list2 = LinkedList::new();
27417 /// let mut list: LinkedList<u32> = LinkedList::new();
27442 /// let mut list: LinkedList<u32> = LinkedList::new();
27509 /// let mut dl = LinkedList::new();
27530 /// let mut dl = LinkedList::new();
27557 /// let mut dl = LinkedList::new();
27571 *self = Self::new();
27582 /// let mut list: LinkedList<u32> = LinkedList::new();
27607 /// let mut dl = LinkedList::new();
27627 /// let mut dl = LinkedList::new();
27653 /// let mut dl = LinkedList::new();
27673 /// let mut dl = LinkedList::new();
27700 /// let mut dl = LinkedList::new();
27710 self.push_front_node(box Node::new(elt));
27723 /// let mut d = LinkedList::new();
27746 /// let mut d = LinkedList::new();
27753 self.push_back_node(box Node::new(elt));
27766 /// let mut d = LinkedList::new();
27791 /// let mut d = LinkedList::new();
27809 return Self::new();
27816 // instead of skipping using .skip() (which creates a new struct),
27847 /// let mut d = LinkedList::new();
27897 /// let mut numbers: LinkedList<u32> = LinkedList::new();
28310 /// Inserts a new element into the `LinkedList` after the current one.
28312 /// If the cursor is pointing at the "ghost" non-element then the new element is
28317 let spliced_node = Box::leak(Box::new(Node::new(item))).into();
28330 /// Inserts a new element into the `LinkedList` before the current one.
28332 /// If the cursor is pointing at the "ghost" non-element then the new element is
28337 let spliced_node = Box::leak(Box::new(Node::new(item))).into();
28367 /// The node that was removed is returned as a new `LinkedList` containing only this node.
28392 /// If the cursor is pointing at the "ghost" non-element then the new elements are
28415 /// If the cursor is pointing at the "ghost" non-element then the new elements are
28434 /// new list consisting of everything after the cursor, with the original
28450 /// new list consisting of everything before the cursor, with the original
28574 let mut list = Self::new();
28816 let mut m = LinkedList::<i32>::new();
28817 let mut n = LinkedList::new();
28825 let mut m = LinkedList::new();
28826 let mut n = LinkedList::new();
28837 let mut m = LinkedList::new();
28838 let mut n = LinkedList::new();
28943 let mut v1 = LinkedList::new();
28957 let mut v1 = LinkedList::new();
28975 let mut m: LinkedList<_> = LinkedList::new();
29014 let mut m: LinkedList<u32> = LinkedList::new();
29026 let mut m: LinkedList<u32> = LinkedList::new();
29038 let mut m: LinkedList<u32> = LinkedList::new();
29074 let mut m: LinkedList<u32> = LinkedList::new();
29101 let mut m: LinkedList<u32> = LinkedList::new();
29131 let mut m: LinkedList<u32> = LinkedList::new();
29159 let mut p: LinkedList<u32> = LinkedList::new();
29161 let mut q: LinkedList<u32> = LinkedList::new();
29209 let iter = MergeIter(MergeIterInner::new(left, right));
29246 // We are at the top, create a new root node and push there.
29253 // Push key-value pair and new right subtree.
29255 let mut right_tree = Root::new();
29309 pub fn new(id: usize) -> CrashTestDummy {
29312 cloned: AtomicUsize::new(0),
29313 dropped: AtomicUsize::new(0),
29314 queried: AtomicUsize::new(0),
29417 pub fn new() -> Self {
29479 pub fn new() -> Self {
29480 Governor { flipped: Cell::new(false) }
29869 /// let mut movie_reviews = BTreeMap::new();
29914 /// let mut player_stats = BTreeMap::new();
29925 /// // insert a key using a function that provides a new value only if it
29961 let mut out_tree = BTreeMap { root: Some(Root::new()), length: 0 };
30000 let subtree = ManuallyDrop::new(subtree);
30006 out_node.push(k, v, subroot.unwrap_or_else(Root::new));
30017 // Ideally we'd call `BTreeMap::new` here, but that has the `K:
30042 let (map, dormant_map) = DormantMutRef::new(self);
30053 let (map, dormant_map) = DormantMutRef::new(self);
30264 /// Makes a new, empty `BTreeMap`.
30275 /// let mut map = BTreeMap::new();
30282 pub const fn new() -> BTreeMap<K, V>
30298 /// let mut a = BTreeMap::new();
30320 /// let mut map = BTreeMap::new();
30348 /// let mut map = BTreeMap::new();
30377 /// let mut map = BTreeMap::new();
30401 /// let mut map = BTreeMap::new();
30417 let (map, dormant_map) = DormantMutRef::new(self);
30434 /// let mut map = BTreeMap::new();
30461 /// let mut map = BTreeMap::new();
30484 /// let mut map = BTreeMap::new();
30500 let (map, dormant_map) = DormantMutRef::new(self);
30517 /// let mut map = BTreeMap::new();
30545 /// let mut map = BTreeMap::new();
30571 /// let mut map = BTreeMap::new();
30610 /// let mut map = BTreeMap::new();
30647 /// let mut map = BTreeMap::new();
30679 /// let mut map = BTreeMap::new();
30707 /// let mut map = BTreeMap::new();
30718 let (map, dormant_map) = DormantMutRef::new(self);
30759 /// let mut a = BTreeMap::new();
30764 /// let mut b = BTreeMap::new();
30822 /// let mut map = BTreeMap::new();
30898 /// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
30913 let (map, dormant_map) = DormantMutRef::new(self);
30933 /// let mut a = BTreeMap::new();
30958 return Self::new();
31018 let (root, dormant_root) = DormantMutRef::new(root);
31040 /// let mut a = BTreeMap::new();
31063 /// let mut a = BTreeMap::new();
31222 let mut me = ManuallyDrop::new(self);
31487 self.dormant_root = Some(DormantMutRef::new(root).1);
31722 let mut map = BTreeMap::new();
31768 BTreeMap::new()
31834 /// let mut map = BTreeMap::new();
31866 /// let mut map = BTreeMap::new();
31904 /// let mut a = BTreeMap::new();
31925 /// let mut a = BTreeMap::new();
31946 /// let mut a = BTreeMap::new();
31972 /// let mut a = BTreeMap::new();
31993 /// let mut a = BTreeMap::new();
32007 root.get_or_insert_with(Root::new)
32036 /// the lifetime of the new reference is the same as the lifetime of the
32038 pub fn new(t: &'a mut T) -> (&'a mut T, Self) {
32050 /// The reborrow must have ended, i.e., the reference returned by `new` and
32160 let mut root = Root::new();
32206 /// let mut books = BTreeSet::new();
32393 /// Makes a new, empty `BTreeSet`.
32403 /// let mut set: BTreeSet<i32> = BTreeSet::new();
32407 pub const fn new() -> BTreeSet<T>
32411 BTreeSet { map: BTreeMap::new() }
32427 /// let mut set = BTreeSet::new();
32455 /// let mut a = BTreeSet::new();
32459 /// let mut b = BTreeSet::new();
32516 /// let mut a = BTreeSet::new();
32520 /// let mut b = BTreeSet::new();
32532 SymmetricDifference(MergeIterInner::new(self.iter(), other.iter()))
32544 /// let mut a = BTreeSet::new();
32548 /// let mut b = BTreeSet::new();
32597 /// let mut a = BTreeSet::new();
32600 /// let mut b = BTreeSet::new();
32611 Union(MergeIterInner::new(self.iter(), other.iter()))
32621 /// let mut v = BTreeSet::new();
32688 /// let mut b = BTreeSet::new();
32713 /// let mut set = BTreeSet::new();
32789 /// let mut set = BTreeSet::new();
32819 /// let mut set = BTreeSet::new();
32845 /// let mut set = BTreeSet::new();
32869 /// let mut set = BTreeSet::new();
32894 /// let mut set = BTreeSet::new();
32924 /// let mut set = BTreeSet::new();
32946 /// let mut set = BTreeSet::new();
32947 /// set.insert(Vec::<i32>::new());
32973 /// let mut set = BTreeSet::new();
33044 /// let mut a = BTreeSet::new();
33049 /// let mut b = BTreeSet::new();
33083 /// let mut a = BTreeSet::new();
33185 /// let mut v = BTreeSet::new();
33204 /// let mut v = BTreeSet::new();
33219 let mut set = BTreeSet::new();
33341 BTreeSet::new()
33349 /// Returns the difference of `self` and `rhs` as a new `BTreeSet<T>`.
33372 /// Returns the symmetric difference of `self` and `rhs` as a new `BTreeSet<T>`.
33395 /// Returns the intersection of `self` and `rhs` as a new `BTreeSet<T>`.
33418 /// Returns the union of `self` and `rhs` as a new `BTreeSet<T>`.
34297 let mut m = BTreeSet::new();
34307 const SET: &'static BTreeSet<()> = &BTreeSet::new();
34314 let mut a = BTreeSet::new();
34319 assert_eq!(a.difference(&BTreeSet::new()).min(), None);
34320 assert_eq!(a.difference(&BTreeSet::new()).max(), None);
34323 assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), None);
34324 assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), None);
34333 assert_eq!(a.difference(&BTreeSet::new()).min(), Some(&1));
34334 assert_eq!(a.difference(&BTreeSet::new()).max(), Some(&2));
34337 assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), Some(&1));
34338 assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), Some(&2));
34347 let mut set_a = BTreeSet::new();
34348 let mut set_b = BTreeSet::new();
34638 let a = CrashTestDummy::new(0);
34639 let b = CrashTestDummy::new(1);
34640 let c = CrashTestDummy::new(2);
34641 let mut set = BTreeSet::new();
34658 let a = CrashTestDummy::new(0);
34659 let b = CrashTestDummy::new(1);
34660 let c = CrashTestDummy::new(2);
34661 let mut set = BTreeSet::new();
34681 let mut x = BTreeSet::new();
34690 let mut x = BTreeSet::new();
34695 let mut y = BTreeSet::new();
34721 let mut set = BTreeSet::new();
34722 let empty = BTreeSet::<i32>::new();
34735 let mut a = BTreeSet::new();
34746 let mut b = BTreeSet::new();
34786 let mut s = BTreeSet::new();
34810 fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> {
34813 fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> {
34816 fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> {
34819 fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> {
34926 let mut a = BTreeSet::new();
34931 let mut b = BTreeSet::new();
34950 let mut a = BTreeSet::new();
34985 let mut rng = DeterministicRng::new();
35035 let (r, dormant_r) = DormantMutRef::new(rr);
35163 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35184 /// let mut map: BTreeMap<&str, String> = BTreeMap::new();
35211 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35236 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35255 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35292 /// let mut map: BTreeMap<&str, Option<usize>> = BTreeMap::new();
35314 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35330 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35350 /// let mut map: BTreeMap<&str, u32> = BTreeMap::new();
35390 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35407 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35431 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35456 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35486 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35509 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35530 /// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
35701 let mut map = BTreeMap::new();
35739 let gov = Governor::new();
35748 let gov = Governor::new();
35756 let mut map = BTreeMap::new();
35809 let mut map = BTreeMap::new();
36019 let mut a = BTreeMap::new();
36094 let mut a = BTreeMap::new();
36337 let mut map = BTreeMap::new();
36358 static COMPARES: AtomicUsize = AtomicUsize::new(0);
36413 let mut map = BTreeMap::new();
36484 let mut map: BTreeMap<i32, i32> = BTreeMap::new();
36694 let a = CrashTestDummy::new(0);
36695 let b = CrashTestDummy::new(1);
36696 let c = CrashTestDummy::new(2);
36697 let mut map = BTreeMap::new();
36714 let a = CrashTestDummy::new(0);
36715 let b = CrashTestDummy::new(1);
36716 let c = CrashTestDummy::new(2);
36717 let mut map = BTreeMap::new();
36740 let a = CrashTestDummy::new(0);
36741 let b = CrashTestDummy::new(1);
36742 let c = CrashTestDummy::new(2);
36743 let mut map = BTreeMap::new();
36774 let mut map = BTreeMap::new();
36780 let mut map = BTreeMap::new();
36781 map.insert(Box::new(0), 1);
36786 let mut map = BTreeMap::new();
36787 map.insert(Box::new([0, 1]) as Box<[i32]>, 1);
36792 let mut map = BTreeMap::new();
36793 map.insert(Rc::new(0), 1);
36897 let mut a = BTreeMap::new();
36899 let mut b = BTreeMap::new();
36914 let mut m = BTreeMap::new();
36964 let mut m = BTreeMap::new();
36974 let mut map = BTreeMap::new();
36988 let a = CrashTestDummy::new(0);
36989 let b = CrashTestDummy::new(1);
36990 let c = CrashTestDummy::new(2);
36992 let mut map = BTreeMap::new();
37011 let mut map = BTreeMap::new();
37056 let a = CrashTestDummy::new(0);
37057 let b = CrashTestDummy::new(1);
37058 let c = CrashTestDummy::new(2);
37060 let mut map = BTreeMap::new();
37085 let mut map1 = BTreeMap::new();
37090 let mut map2 = BTreeMap::new();
37110 fn map_key<'new>(v: BTreeMap<&'static str, ()>) -> BTreeMap<&'new str, ()> {
37113 fn map_val<'new>(v: BTreeMap<(), &'static str>) -> BTreeMap<(), &'new str> {
37117 fn iter_key<'a, 'new>(v: Iter<'a, &'static str, ()>) -> Iter<'a, &'new str, ()> {
37120 fn iter_val<'a, 'new>(v: Iter<'a, (), &'static str>) -> Iter<'a, (), &'new str> {
37124 fn into_iter_key<'new>(v: IntoIter<&'static str, ()>) -> IntoIter<&'new str, ()> {
37127 fn into_iter_val<'new>(v: IntoIter<(), &'static str>) -> IntoIter<(), &'new str> {
37131 fn into_keys_key<'new>(v: IntoKeys<&'static str, ()>) -> IntoKeys<&'new str, ()> {
37134 fn into_keys_val<'new>(v: IntoKeys<(), &'static str>) -> IntoKeys<(), &'new str> {
37138 fn into_values_key<'new>(v: IntoValues<&'static str, ()>) -> IntoValues<&'new str, ()> {
37141 fn into_values_val<'new>(v: IntoValues<(), &'static str>) -> IntoValues<(), &'new str> {
37145 fn range_key<'a, 'new>(v: Range<'a, &'static str, ()>) -> Range<'a, &'new str, ()> {
37148 fn range_val<'a, 'new>(v: Range<'a, (), &'static str>) -> Range<'a, (), &'new str> {
37152 fn keys_key<'a, 'new>(v: Keys<'a, &'static str, ()>) -> Keys<'a, &'new str, ()> {
37155 fn keys_val<'a, 'new>(v: Keys<'a, (), &'static str>) -> Keys<'a, (), &'new str> {
37159 fn values_key<'a, 'new>(v: Values<'a, &'static str, ()>) -> Values<'a, &'new str, ()> {
37162 fn values_val<'a, 'new>(v: Values<'a, (), &'static str>) -> Values<'a, (), &'new str> {
37348 const MAP: &'static BTreeMap<(), ()> = &BTreeMap::new();
37355 let mut a = BTreeMap::new();
37374 let mut a = BTreeMap::new();
37393 let mut a = BTreeMap::new();
37446 let mut a = BTreeMap::new();
37451 let mut b = BTreeMap::new();
37500 let a = CrashTestDummy::new(0);
37501 let b = CrashTestDummy::new(1);
37502 let c = CrashTestDummy::new(2);
37503 let mut left = BTreeMap::new();
37504 let mut right = BTreeMap::new();
37519 let mut map1 = BTreeMap::new();
37522 let mut map2 = BTreeMap::new();
37539 let mut rng = DeterministicRng::new();
37605 let mut rng = DeterministicRng::new();
37641 let a = CrashTestDummy::new(0);
37642 let b = CrashTestDummy::new(1);
37643 let c = CrashTestDummy::new(2);
37644 let d = CrashTestDummy::new(3);
37645 let e = CrashTestDummy::new(4);
37646 let mut map = BTreeMap::new();
37666 let dummies: Vec<_> = (0..size).map(|i| CrashTestDummy::new(i)).collect();
37707 let mut map = BTreeMap::new();
37721 let gov = Governor::new();
37722 let mut map = BTreeMap::new();
37865 /// Creates a new core for an iterator merging a pair of sources.
37866 pub fn new(a: I, b: I) -> Self {
37990 /// Initializes a new `LeafNode` in-place.
38001 /// Creates a new boxed `LeafNode`.
38002 fn new() -> Box<Self> {
38028 /// Creates a new boxed `InternalNode`.
38034 unsafe fn new() -> Box<Self> {
38138 Self::from_new_leaf(LeafNode::new())
38148 let mut new_node = unsafe { InternalNode::new() };
38321 Layout::new::<InternalNode<K, V>>()
38323 Layout::new::<LeafNode<K, V>>()
38469 /// Returns a new owned tree, with its own root node that is initially empty.
38470 pub fn new() -> Self {
38474 /// Adds a new internal node with a single edge pointing to the previous root node,
38475 /// make that new node the root node, and return it. This increases the height by 1
38484 /// Removes the internal root node, using its first child as the new root node.
38508 Global.deallocate(top.cast(), Layout::new::<InternalNode<K, V>>());
38654 /// Creates a new handle to a key-value pair in `node`.
38705 /// Creates a new handle to an edge in `node`.
38752 /// Inserts a new key-value pair between the key-value pairs to the right and left of
38753 /// this edge. This method assumes that there is enough space in the node for the new
38772 /// Inserts a new key-value pair between the key-value pairs to the right and left of
38812 /// Inserts a new key-value pair and an edge that will go to the right of that new pair
38814 /// that there is enough space in the node for the new pair to fit.
38830 /// Inserts a new key-value pair and an edge that will go to the right of that new pair
38864 /// Inserts a new key-value pair between the key-value pairs to the right and left of
39007 let mut new_node = LeafNode::new();
39041 let mut new_node = InternalNode::new();
39193 Global.deallocate(right_node.node.cast(), Layout::new::<InternalNode<K, V>>());
39195 Global.deallocate(right_node.node.cast(), Layout::new::<LeafNode<K, V>>());
39510 // Owned, unattached, new node with elements and edges that belong to the right of `kv`.
39551 // By disabling traversal, and only creating new references to roots,
39655 let mut result = String::new();
39702 let root2 = Root::new();
39950 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
39974 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
39982 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
40331 array::IntoIter::new([self.b0, self.b1])
40503 VecDeque::new()
40815 /// let vector: VecDeque<u32> = VecDeque::new();
40818 pub fn new() -> VecDeque<T> {
40849 /// let mut buf = VecDeque::new();
40874 /// let mut buf = VecDeque::new();
40909 /// let mut buf = VecDeque::new();
40952 /// Panics if the new capacity overflows `usize`.
40975 /// Panics if the new capacity overflows `usize`.
41025 /// let mut output = VecDeque::new();
41039 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
41063 /// let mut output = VecDeque::new();
41077 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
41137 #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
41211 /// let mut buf = VecDeque::new();
41271 /// let mut buf = VecDeque::new();
41291 /// let mut buf = VecDeque::new();
41326 /// let mut vector = VecDeque::new();
41361 /// let mut vector = VecDeque::new();
41391 /// let mut v = VecDeque::new();
41409 /// let mut v = VecDeque::new();
41597 /// let mut v = VecDeque::new();
41616 /// let mut vector: VecDeque<u32> = VecDeque::new();
41641 /// let mut d = VecDeque::new();
41661 /// let mut d = VecDeque::new();
41685 /// let mut d = VecDeque::new();
41705 /// let mut d = VecDeque::new();
41729 /// let mut d = VecDeque::new();
41756 /// let mut buf = VecDeque::new();
41780 /// let mut d = VecDeque::new();
41805 /// let mut buf = VecDeque::new();
41842 /// let mut buf = VecDeque::new();
41877 /// let mut buf = VecDeque::new();
41912 /// let mut vec_deque = VecDeque::new();
42042 // copy elements up to new head
42066 // copy elements up to new tail
42086 // copy elements up to new tail
42124 /// room, and all the affected elements will be moved to new positions.
42134 /// let mut buf = VecDeque::new();
42374 /// Panics if the new number of elements in self overflows a `usize`.
42405 /// let mut buf = VecDeque::new();
42416 /// let mut buf = VecDeque::new();
42467 /// let mut buf = VecDeque::new();
42535 /// let mut buf = VecDeque::new();
42615 // - then restart the algorithm with a new (smaller) store
42969 /// let mut buf = VecDeque::new();
43269 let other = ManuallyDrop::new(other);
44066 let mut dst = VecDeque::new();
44067 dst.push_front(Box::new(1));
44068 dst.push_front(Box::new(2));
44071 let mut src = VecDeque::new();
44072 src.push_front(Box::new(2));
44332 //! let mut heap = BinaryHeap::new();
44443 /// let mut heap = BinaryHeap::new();
44489 /// let mut heap = BinaryHeap::new();
44598 BinaryHeap::new()
44618 /// let mut heap = BinaryHeap::new();
44622 pub fn new() -> BinaryHeap<T> {
44657 /// let mut heap = BinaryHeap::new();
44718 /// let mut heap = BinaryHeap::new();
44746 // SAFETY: Since we pushed a new item it means that
44804 let mut hole = unsafe { Hole::new(&mut self.data, pos) };
44832 let mut hole = unsafe { Hole::new(&mut self.data, pos) };
44891 let mut hole = unsafe { Hole::new(&mut self.data, pos) };
45119 /// let mut heap = BinaryHeap::new();
45163 /// Panics if the new capacity overflows `usize`.
45171 /// let mut heap = BinaryHeap::new();
45188 /// Panics if the new capacity overflows `usize`.
45196 /// let mut heap = BinaryHeap::new();
45244 #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
45318 /// let mut heap = BinaryHeap::new();
45392 /// Create a new `Hole` at index `pos`.
45396 unsafe fn new(data: &'a mut [T], pos: usize) -> Self {
45400 Hole { data, elt: ManuallyDrop::new(elt), pos }
45424 /// Move hole to new location
45941 /// unsafe { core::ptr::write(&mut into_iter, Vec::new().into_iter()); }
45946 // overwrite the individual fields instead of creating a new
46175 let mut local_len = SetLenOnDrop::new(&mut self.len);
46399 // memmove back untouched tail, update to new length
46460 None => return Vec::new(),
46619 let it = ManuallyDrop::new(iterator);
46627 let mut vec = Vec::new();
46782 unsafe { ManuallyDrop::new(sink).dst.offset_from(dst_buf) as usize }
46819 //! You can explicitly create a [`Vec`] with [`Vec::new`]:
46822 //! let v: Vec<i32> = Vec::new();
46942 /// let mut vec = Vec::new();
46991 /// let mut stack = Vec::new();
47079 /// if you construct a `Vec` with capacity 0 via [`Vec::new`], [`vec![]`][`vec!`],
47192 /// Constructs a new, empty `Vec<T>`.
47200 /// let mut vec: Vec<i32> = Vec::new();
47205 pub const fn new() -> Self {
47209 /// Constructs a new, empty `Vec<T>` with the specified capacity.
47223 /// Panics if the new capacity exceeds `isize::MAX` bytes.
47297 /// let mut v = mem::ManuallyDrop::new(v);
47323 /// Constructs a new, empty `Vec<T, A>`.
47343 /// Constructs a new, empty `Vec<T, A>` with the specified capacity with the provided
47358 /// Panics if the new capacity exceeds `isize::MAX` bytes.
47442 /// let mut v = mem::ManuallyDrop::new(v);
47499 #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
47501 let mut me = ManuallyDrop::new(self);
47543 // #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
47545 let mut me = ManuallyDrop::new(self);
47576 /// Panics if the new capacity exceeds `isize::MAX` bytes.
47602 /// Panics if the new capacity overflows `usize`.
47635 /// let mut output = Vec::new();
47650 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
47677 /// let mut output = Vec::new();
47692 #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
47742 #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
47777 let me = ManuallyDrop::new(self);
48123 // space for the new element
48130 // The spot to put the new value
48429 /// Panics if the new capacity exceeds `isize::MAX` bytes.
48548 // the hole, and the vector length is restored to the new length.
48609 /// let mut v = Vec::new();
48656 // the new vector can take over the original buffer and avoid the copy
48685 /// This method uses a closure to create new values on every push. If
49008 let mut local_len = SetLenOnDrop::new(&mut self.len);
49237 let mut me = ManuallyDrop::new(self);
49349 /// let new = [7, 8];
49350 /// let u: Vec<_> = v.splice(..2, new.iter().cloned()).collect();
49485 Vec::new()
49589 /// If `s` is borrowing a slice, a new `Vec<T>` will be allocated and
49668 /// assert_eq!(<Vec<i32>>::new().try_into(), Ok([]));
49718 pub(super) fn new(len: &'a mut usize) -> Self {
49970 /// let new = [7, 8];
49971 /// let iter: std::vec::Splice<_> = v.splice(1.., new.iter().cloned());
50052 /// Fill that range as much as possible with new elements from the `replace_with` iterator.
50184 //! let boxed: Box<u8> = Box::new(val);
50190 //! let boxed: Box<u8> = Box::new(5);
50203 //! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
50239 //! not valid. The recommended way to build a Box to a ZST if `Box::new` cannot
50273 //! Box::new(Foo)
50348 /// let five = Box::new(5);
50354 pub fn new(x: T) -> Self {
50358 /// Constructs a new box with uninitialized contents.
50382 /// Constructs a new `Box` with uninitialized contents, with the memory
50407 /// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
50434 /// Constructs a new box with uninitialized contents on the heap,
50461 /// Constructs a new `Box` with uninitialized contents, with the memory
50537 /// Constructs a new box with uninitialized contents in the provided allocator.
50560 let layout = Layout::new::<mem::MaybeUninit<T>>();
50569 /// Constructs a new box with uninitialized contents in the provided allocator,
50594 let layout = Layout::new::<mem::MaybeUninit<T>>();
50599 /// Constructs a new `Box` with uninitialized contents, with the memory
50622 let layout = Layout::new::<mem::MaybeUninit<T>>();
50631 /// Constructs a new `Box` with uninitialized contents, with the memory
50656 let layout = Layout::new::<mem::MaybeUninit<T>>();
50661 /// Constructs a new `Pin<Box<T, A>>`. If `T` does not implement `Unpin`, then
50688 /// let c = Box::new(5);
50700 /// Constructs a new boxed slice with uninitialized contents.
50725 /// Constructs a new boxed slice with uninitialized contents, with the memory
50750 /// Constructs a new boxed slice with uninitialized contents in the provided allocator.
50778 /// Constructs a new boxed slice with uninitialized contents in the provided allocator,
50903 /// let x = Box::new(5);
50912 /// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
50966 /// let ptr = System.allocate(Layout::new::<i32>())?.as_mut_ptr() as *mut i32;
51004 /// let x = Box::new(String::from("Hello"));
51014 /// let x = Box::new(String::from("Hello"));
51018 /// dealloc(p as *mut u8, Layout::new::<String>());
51070 /// alloc.deallocate(non_null.cast(), Layout::new::<String>());
51131 /// let x = Box::new(41);
51151 unsafe { &mut *mem::ManuallyDrop::new(b).0.as_ptr() }
51189 Box::<[T; 0]>::new([])
51202 /// Returns a new box with a `clone()` of this box's contents.
51207 /// let x = Box::new(5);
51226 /// Copies `source`'s contents into `self` without creating a new allocation.
51231 /// let x = Box::new(5);
51232 /// let mut y = Box::new(10);
51365 /// let boxed = Box::new(5);
51370 Box::new(t)
51523 /// print_if_string(Box::new(my_string));
51524 /// print_if_string(Box::new(0i8));
51555 /// print_if_string(Box::new(my_string));
51556 /// print_if_string(Box::new(0i8));
51587 /// print_if_string(Box::new(my_string));
51588 /// print_if_string(Box::new(0i8));
51825 G::resume(Pin::new(&mut *self), arg)
51850 F::poll(Pin::new(&mut *self), cx)
51859 Pin::new(&mut **self).poll_next(cx)
51907 let a = BoundedAlloc { fuel: Cell::new(500) };
51917 let mut v: RawVec<u32> = RawVec::new();
51924 let mut v: RawVec<u32> = RawVec::new();
51934 let mut v: RawVec<u32> = RawVec::new();
51940 // factor is 2, so new capacity is 24, however, grow factor
51957 let a = Box::new(5);
51967 let a = Box::new(8) as Box<dyn Any>;
51968 let b = Box::new(Test) as Box<dyn Any>;
51972 assert!(a == Box::new(8));
51978 assert!(a == Box::new(Test));
51983 let a = Box::new(8) as Box<dyn Any>;
51984 let b = Box::new(Test) as Box<dyn Any>;
51992 let a = Box::new(8) as Box<dyn Any>;
51993 let b = Box::new(Test) as Box<dyn Any>;
52012 homura(Box::new(765));
52017 let x = Box::new(17);
52046 let x: Box<dyn Foo> = Box::new(Bar(17));