Lines Matching defs:from
485 b.iter(|| String::from(s))
492 b.iter(|| String::from(s))
506 let mut x = String::from(s);
516 let mut x = String::from(s);
526 let mut x = String::from(s);
536 let mut x = String::from(s);
2040 // peculiar numbers to stop LLVM from optimising the summation
2497 let mut bheap = BinaryHeap::from(vec![42]);
2520 b.iter(|| BinaryHeap::from(vec.clone()))
3320 let b: Arc<[u32]> = Arc::from(&[3, 2, 1][..]); // Conversion
3538 let data = String::from("asdf");
3555 let mut data = String::from(string);
3816 // orthogonally from range types; therefore, it is worth testing
4439 let s = String::from("");
4458 let s1: String = String::from("All mimsy were the borogoves");
4461 let s2: String = String::from(from_utf8(&v).unwrap());
5191 let string = String::from("Some text goes here");
5197 let data = String::from("hello HELLO hello HELLO yes YES 5 中ä华!!!");
5206 let owned = String::from("owned");
5207 match (Cow::from(owned.clone()), Cow::from(borrowed)) {
5209 _ => panic!("invalid `Cow::from`"),
5651 assert_eq!(String::from(Cow::Borrowed("string")), "string");
5652 assert_eq!(String::from(Cow::Owned(String::from("string"))), "string");
5664 assert_eq!(String::from_utf8(xs).unwrap(), String::from("hello"));
5667 assert_eq!(String::from_utf8(xs).unwrap(), String::from("ศไทย中华Việt Nam"));
5691 String::from("Hello\u{FFFD} There\u{FFFD} Goodbye").into_cow()
5697 String::from("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye").into_cow()
5703 String::from("\u{FFFD}foo\u{FFFD}\u{FFFD}bar").into_cow()
5709 String::from("\u{FFFD}foo\u{FFFD}bar\u{FFFD}baz").into_cow()
5715 String::from("\u{FFFD}foo\u{FFFD}bar\u{FFFD}\u{FFFD}baz").into_cow()
5721 String::from("\u{FFFD}\u{FFFD}\u{FFFD}\u{FFFD}foo\u{10000}bar").into_cow()
5728 String::from("\u{FFFD}\u{FFFD}\u{FFFD}foo\u{FFFD}\u{FFFD}\u{FFFD}bar").into_cow()
5736 String::from("???????\n"),
5743 String::from("?????? ???\n"),
5750 String::from("??????·???????\n"),
5758 String::from("?????? ?? ??? ????? ??\n"),
5768 (String::from("\u{20000}"), vec![0xD840, 0xDC00]),
5806 assert_eq!(String::from_utf16_lossy(&[0xD800]), String::from("\u{FFFD}"));
5808 assert_eq!(String::from_utf16_lossy(&[0xD800, 0xD800]), String::from("\u{FFFD}\u{FFFD}"));
5811 assert_eq!(String::from_utf16_lossy(&[0x0061, 0xDC00]), String::from("a\u{FFFD}"));
5816 String::from("\u{FFFD}?\u{FFFD}")
5822 let mut s = String::from("ABC");
5854 let mut data = String::from("ประเทศไทย中");
5865 let mut data = String::from("ประเทศไทย中华b¢€?");
5877 let mut split = String::from(orig);
5886 let mut split = String::from(orig);
5893 let mut shan = String::from("山");
5899 let mut ab = String::from("ABCD");
5909 let mut nihon = String::from("日本語");
5919 let mut s = String::from("12345");
5927 let mut s = String::from("12345");
5937 let mut s = String::from("12345");
5945 let mut s = String::from("\u{FC}"); // ü
5951 let mut s = String::from("12345");
5959 let a = String::from("12345");
6011 let mut s = String::from("α_β_γ");
6028 let mut s = String::from("0è0");
6115 let mut s = String::from("αβγ");
6119 let mut t = String::from("abcd");
6133 let mut s = String::from("abc");
6140 let mut s = String::from("abc");
6160 let mut v = String::from("12345");
6170 let mut s = String::from("12345");
6177 let mut s = String::from("12345");
6184 let mut s = String::from("123");
6191 let mut s = String::from("456");
6197 let mut s = String::from("12345");
6204 let mut s = String::from("12345");
6227 let mut s = String::from("?");
6250 let mut s = String::from("?");
6265 let xs = String::from("hello my name is bob");
6357 let mut ten_bytes: String = String::from("0123456789");
6430 let mut ten_bytes: String = String::from("0123456789");
6458 assert_eq!(String::from('a'), 'a'.to_string());
6478 let borrowed = <$ty>::from(Cow::Borrowed($value));
6479 let owned = <$ty>::from(Cow::Owned($value.to_owned()));
7631 match (Cow::from(owned.clone()), Cow::from(borrowed)) {
7633 _ => panic!("invalid `Cow::from`"),
7641 assert_eq!(Vec::from(Cow::Borrowed(borrowed)), vec!["borrowed", "(slice)"]);
7642 assert_eq!(Vec::from(Cow::Owned(owned)), vec!["owned", "(vec)"]);
8191 /// Pull an element from the iterator, then drop it.
8323 // If the element size is 1, we jump from 0 to 8, then double.
8349 // If the element size is 2..=1024, we jump from 0 to 4, then double.
8392 // If the element size is > 1024, we jump from 0 to 1, then double.
8625 let mut v = vec![String::from("sssss"), String::from("12334567890"), String::from("c")];
8672 let mut v = vec![String::from("a"), String::from("b"), String::from("c")];
8919 let owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
8920 let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
8948 let owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
8972 let mut owned1: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
8973 let owned2: Cow<'_, str> = Cow::Owned(String::from("Rustaceans!"));
9013 let mut owned: Cow<'_, str> = Cow::Owned(String::from("Hi, "));
9077 let b: Rc<[u32]> = Rc::from(&[3, 2, 1][..]); // Conversion
11326 let deq = VecDeque::from(vec![1, 2, 3]);
11333 let deq = VecDeque::from(vec![1, 2, 3]);
12957 let queue = VecDeque::from(v);
13293 let heap = BinaryHeap::from(data);
13305 let pq = BinaryHeap::from(data);
13315 let pq = BinaryHeap::from(data);
13324 let pq = BinaryHeap::from(data);
13342 let pq = BinaryHeap::from(data);
13350 let heap = BinaryHeap::from(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
13358 let mut heap = BinaryHeap::from(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
13380 let heap = BinaryHeap::from(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
13402 let heap = BinaryHeap::from(vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]);
13412 let mut heap = BinaryHeap::from(data);
13422 let mut heap = BinaryHeap::from(data);
13434 let mut heap = BinaryHeap::from(data);
13446 let mut heap = BinaryHeap::from(vec![2, 4, 9]);
13468 let mut heap = BinaryHeap::<Box<_>>::from(vec![box 2, box 4, box 9]);
13489 let heap = BinaryHeap::from(data.clone());
13591 let mut q = BinaryHeap::from(vec![
13632 let mut a = BinaryHeap::from(vec![-10, 1, 2, 3, 3]);
13633 let mut b = BinaryHeap::from(vec![-20, 5, 43]);
13644 let mut b = BinaryHeap::from(vec![-20, 5, 43]);
13654 let mut a = BinaryHeap::from(vec![-10, 1, 2, 3, 3]);
13655 let b = BinaryHeap::from(vec![-20, 5, 43]);
13671 let mut a = BinaryHeap::from(vec![100, 10, 50, 1, 2, 20, 30]);
13744 let mut heap = BinaryHeap::from(panic_ords);
13889 /// - Create a [`Vec`] from a given element and size:
14461 /// * Uses the excess returned from the allocator to use the largest available capacity.
14518 /// Reconstitutes a `RawVec` from a pointer and capacity.
14525 /// If the `ptr` and `capacity` come from a `RawVec`, then this is guaranteed.
14633 /// Reconstitutes a `RawVec` from a pointer, capacity, and allocator.
14641 /// If the `ptr` and `capacity` come from a `RawVec` created via `alloc`, then this is
14737 // Therefore, we move all the resizing and error-handling logic from grow_amortized and
15216 /// `replace` creates a new [`String`], and copies the data from this string slice into it.
15240 pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String {
15243 for (start, part) in self.match_indices(from) {
15254 /// `replacen` creates a new [`String`], and copies the data from this string slice into it.
15358 fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) {
15362 let is_word_final = case_ignoreable_then_cased(from[..i].chars().rev())
15363 && !case_ignoreable_then_cased(from[i + 2..].chars());
15436 /// let string = String::from("birthday gift");
15444 let slice = Box::<[u8]>::from(self);
15459 /// assert_eq!("abc".repeat(4), String::from("abcabcabcabc"));
15677 let arc: Arc<str> = Arc::from("foo");
15717 let arc: Arc<str> = Arc::from("foo");
15912 let x: Arc<CStr> = Arc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
15927 let foo_arc = Arc::from(foo);
15972 let r: Arc<str> = Arc::from("foo");
15980 let r: Arc<[u32]> = Arc::from(s);
15991 let r: Arc<[X]> = Arc::from(s);
16016 let _r: Arc<[Fail]> = Arc::from(s);
16022 let r: Arc<u32> = Arc::from(b);
16031 let s = String::from("foo").into_boxed_str();
16032 let r: Arc<str> = Arc::from(s);
16040 let r: Arc<[u32]> = Arc::from(s);
16051 let r: Arc<dyn Display> = Arc::from(b);
16061 let r: Arc<dyn Debug> = Arc::from(b);
16069 let r: Arc<[u32]> = Arc::from(v);
16097 let r: Arc<[u32]> = Arc::from(v);
16175 //! converting to strings, and several error types that may result from
16180 //! There are multiple ways to create a new [`String`] from a string literal:
16185 //! let s = String::from("world");
16189 //! You can create a new [`String`] from an existing one by concatenating with
16240 /// You can create a `String` from [a literal string][`str`] with [`String::from`]:
16242 /// [`String::from`]: From::from
16245 /// let hello = String::from("Hello, world!");
16252 /// let mut hello = String::from("Hello, ");
16261 /// If you have a vector of UTF-8 bytes, you can create a `String` from it with
16309 /// let s = String::from("Hello");
16314 /// This will create a [`&str`] from the `String` and pass it in. This
16333 /// let example_string = String::from("example_string");
16363 /// let story = String::from("Once upon a time...");
16381 /// assert_eq!(String::from("Once upon a time..."), s);
16454 /// A possible error value when converting a `String` from a UTF-8 byte vector.
16466 /// an analogue to `FromUtf8Error`, and you can get one from a `FromUtf8Error`
16494 /// A possible error value when converting a `String` from a UTF-16 byte slice.
16753 /// assert_eq!(String::from("?music"),
16797 /// assert_eq!(String::from("?mus\u{FFFD}ic\u{FFFD}"),
16825 /// let s = String::from("hello");
16837 /// Creates a new `String` from a length, capacity, and pointer.
16867 /// let s = String::from("hello");
16879 /// assert_eq!(String::from("hello"), s);
16931 /// let s = String::from("hello");
16949 /// let s = String::from("foo");
16966 /// let mut s = String::from("foobar");
16986 /// let mut s = String::from("foo");
17192 /// let mut s = String::from("foo");
17217 /// let mut s = String::from("foo");
17240 /// let mut s = String::from("abc");
17268 /// let s = String::from("hello");
17295 /// let mut s = String::from("hello");
17310 /// Removes the last character from the string buffer and returns it.
17319 /// let mut s = String::from("foo");
17338 /// Removes a [`char`] from this `String` at a byte position and returns it.
17353 /// let mut s = String::from("foo");
17364 None => panic!("cannot remove a char from the end of a string"),
17382 /// let mut s = String::from("Trees are not green, the sky is not blue.");
17392 /// let mut s = String::from("banana");
17441 /// let mut s = String::from("f_o_ob_ar");
17451 /// let mut s = String::from("abcde");
17565 /// let mut s = String::from("bar");
17595 /// let mut s = String::from("hello");
17620 /// let a = String::from("foo");
17623 /// let fancy_f = String::from("ƒoo");
17670 /// let mut hello = String::from("Hello, World!");
17695 /// let mut s = String::from("foo");
17725 /// let mut s = String::from("α is alpha, β is beta");
17728 /// // Remove the range up until the β from the string
17775 /// let mut s = String::from("α is alpha, β is beta");
17778 /// // Replace the range up until the β from the string
17824 /// let s = String::from("hello");
17966 // one allocation by getting the first string from the iterator
18091 /// assert_eq!(String::from("Hello world").find("world"), Some(6));
18227 /// let a = String::from("hello");
18228 /// let b = String::from(" world");
18236 /// let a = String::from("hello");
18237 /// let b = String::from(" world");
18400 Ok(String::from(s))
18423 /// let five = String::from("5");
18441 // removing `#[inline]` from this method causes non-negligible regressions.
18458 String::from(self.encode_utf8(&mut [0; 4]))
18466 String::from(self)
18513 fn from(s: &str) -> String {
18524 fn from(s: &mut str) -> String {
18532 fn from(s: &String) -> String {
18549 /// let s1: String = String::from("hello world");
18551 /// let s3: String = String::from(s2);
18555 fn from(s: Box<str>) -> String {
18569 /// let s1: String = String::from("hello world");
18570 /// let s2: Box<str> = Box::from(s1);
18571 /// let s3: String = String::from(s2);
18575 fn from(s: String) -> Box<str> {
18582 fn from(s: Cow<'a, str>) -> String {
18597 /// assert_eq!(Cow::from("eggplant"), Cow::Borrowed("eggplant"));
18600 fn from(s: &'a str) -> Cow<'a, str> {
18617 /// assert_eq!(Cow::from(s), Cow::<'static, str>::Owned(s2));
18620 fn from(s: String) -> Cow<'a, str> {
18636 /// assert_eq!(Cow::from(&s), Cow::Borrowed("eggplant"));
18639 fn from(s: &'a String) -> Cow<'a, str> {
18674 /// let s1 = String::from("hello world");
18675 /// let v1 = Vec::from(s1);
18681 fn from(string: String) -> Vec<u8> {
18752 /// let mut s = String::from("abc");
18812 fn from(c: char) -> Self {
18845 /// Some types make it possible to go from borrowed to owned, usually by
18846 /// implementing the `Clone` trait. But `Clone` works only for going from `&T`
18848 /// from any borrow of a given type.
18856 /// Creates owned data from borrowed data, usually by cloning.
18944 /// let mut input = Cow::from(&slice[..]);
18949 /// let mut input = Cow::from(&slice[..]);
18953 /// let mut input = Cow::from(vec![-1, 0, 1]);
18972 /// // Creates a container from borrowed values of a slice
18981 /// // Mutates the data from slice into owned vec and pushes a new value on top
19083 /// Cow::Owned(String::from("FOO")) as Cow<str>
19117 /// String::from(s)
19127 /// let cow: Cow<str> = Cow::Owned(String::from(s));
19131 /// String::from(s)
19408 // from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
19465 // Need to conditionally define the mod from `boxed.rs` to avoid
19527 //! [`Rc`] pointers from parent nodes to children, and [`Weak`] pointers from
19574 //! The `Rc::clone(&from)` syntax is the most idiomatic because it conveys more explicitly
19638 //! If our requirements change, and we also need to be able to traverse from
19639 //! `Owner` to `Gadget`, we will run into problems. An [`Rc`] pointer from `Owner`
19772 // would interfere with otherwise safe [into|from]_raw() of transmutable
20305 /// Constructs an `Rc<T>` from a raw pointer.
20789 /// Copy elements from slice into newly allocated Rc<\[T\]>
20800 /// Constructs an `Rc<[T]>` from an iterator known to be of a certain size.
21210 fn from(t: T) -> Self {
21224 /// let shared: Rc<[i32]> = Rc::from(original);
21228 fn from(v: &[T]) -> Rc<[T]> {
21241 /// let shared: Rc<str> = Rc::from("statue");
21245 fn from(v: &str) -> Rc<str> {
21246 let rc = Rc::<[u8]>::from(v.as_bytes());
21260 /// let shared: Rc<str> = Rc::from(original);
21264 fn from(v: String) -> Rc<str> {
21265 Rc::from(&v[..])
21278 /// let shared: Rc<i32> = Rc::from(original);
21282 fn from(v: Box<T>) -> Rc<T> {
21296 /// let shared: Rc<Vec<i32>> = Rc::from(original);
21300 fn from(mut v: Vec<T>) -> Rc<[T]> {
21319 fn from(cow: Cow<'a, B>) -> Rc<B> {
21321 Cow::Borrowed(s) => Rc::from(s),
21322 Cow::Owned(s) => Rc::from(s),
21427 /// prevent the value stored in the allocation from being dropped, and `Weak` itself makes no
21430 /// itself (the backing store) from being deallocated.
21433 /// managed by [`Rc`] without preventing its inner value from being dropped. It is also used to
21436 /// have strong [`Rc`] pointers from parent nodes to children, and `Weak`
21437 /// pointers from children back to their parents.
21582 /// The pointer must have originated from the [`into_raw`] and must still own its potential
21622 // Otherwise, we're guaranteed the pointer came from a nondangling Weak.
21626 // SAFETY: the pointer originated from a Weak, so this offset is safe.
22532 // first `rem` repetitions from `buf` itself.
22827 // preceding it. Finally, copy data from the temporary variable into the remaining
22836 // 1. Protects integrity of `v` from panics in `is_less`.
22858 // When dropped, copies from `src` into `dest`.
22897 // 1. Protects integrity of `v` from panics in `is_less`.
22988 /// This merge sort borrows some (but not all) ideas from TimSort, which is described in detail
23189 /// println!("Hi from inside a future!");
23216 fn from(waker: Arc<W>) -> Waker {
23218 // a RawWaker from Arc<W>.
23228 fn from(waker: Arc<W>) -> RawWaker {
23382 /// strong `Arc` pointers from parent nodes to children, and [`Weak`]
23383 /// pointers from children back to their parents.
23387 /// Creating a new reference from an existing reference-counted pointer is done using the
23442 /// [`Arc::clone(&from)`]: Arc::clone
23526 /// prevent the value stored in the allocation from being dropped, and `Weak` itself makes no
23529 /// itself (the backing store) from being deallocated.
23532 /// managed by [`Arc`] without preventing its inner value from being dropped. It is also used to
23535 /// have strong [`Arc`] pointers from parent nodes to children, and `Weak`
23536 /// pointers from children back to their parents.
23570 // would interfere with otherwise safe [into|from]_raw() of transmutable
24076 /// Constructs an `Arc<T>` from a raw pointer.
24155 // synchronize with the write coming from `is_unique`, so that the
24439 /// Copy elements from slice into newly allocated Arc<\[T\]>
24452 /// Constructs an `Arc<[T]>` from an iterator known to be of a certain size.
24539 // original reference prevents other threads from erroneously deleting
24544 // references to an object can only be formed from an existing
24545 // reference, and passing an existing reference from one thread to
24588 /// Note that this differs from the behavior of [`Rc::make_mut`] which disassociates
24764 // effectively preventing the above read of `strong` from happening
24994 /// The pointer must have originated from the [`into_raw`] and must still own its potential
25034 // Otherwise, we're guaranteed the pointer came from a nondangling Weak.
25038 // SAFETY: the pointer originated from a Weak, so this offset is safe.
25075 // from zero to one.
25551 fn from(t: T) -> Self {
25565 /// let shared: Arc<[i32]> = Arc::from(original);
25569 fn from(v: &[T]) -> Arc<[T]> {
25582 /// let shared: Arc<str> = Arc::from("eggplant");
25586 fn from(v: &str) -> Arc<str> {
25587 let arc = Arc::<[u8]>::from(v.as_bytes());
25601 /// let shared: Arc<str> = Arc::from(unique);
25605 fn from(v: String) -> Arc<str> {
25606 Arc::from(&v[..])
25618 /// let unique: Box<str> = Box::from("eggplant");
25619 /// let shared: Arc<str> = Arc::from(unique);
25623 fn from(v: Box<T>) -> Arc<T> {
25637 /// let shared: Arc<[i32]> = Arc::from(unique);
25641 fn from(mut v: Vec<T>) -> Arc<[T]> {
25660 fn from(cow: Cow<'a, B>) -> Arc<B> {
25662 Cow::Borrowed(s) => Arc::from(s),
25663 Cow::Owned(s) => Arc::from(s),
25809 //! The [`format!`] macro is intended to be familiar to those coming from C's
26082 //! The syntax for the formatting language used is drawn from other languages,
26152 //! should ensure that they propagate errors from the [`Formatter`] (e.g., when
26220 //! Some examples of the output from both traits:
26559 let rc: Rc<str> = Rc::from("foo");
26599 let arc: Rc<str> = Rc::from("foo");
26709 let x: Rc<CStr> = Rc::from(CString::new("swordfish").unwrap().into_boxed_c_str());
26724 let foo_rc = Rc::from(foo);
26746 let r: Rc<str> = Rc::from("foo");
26754 let r: Rc<[u32]> = Rc::from(s);
26765 let r: Rc<[X]> = Rc::from(s);
26790 let _r: Rc<[Fail]> = Rc::from(s);
26796 let r: Rc<u32> = Rc::from(b);
26805 let s = String::from("foo").into_boxed_str();
26806 let r: Rc<str> = Rc::from(s);
26814 let r: Rc<[u32]> = Rc::from(s);
26825 let r: Rc<dyn Display> = Rc::from(b);
26835 let r: Rc<dyn Debug> = Rc::from(b);
26843 let r: Rc<[u32]> = Rc::from(v);
26871 let r: Rc<[u32]> = Rc::from(v);
27158 /// Unlinks the specified node from the current list.
27220 /// Detaches all nodes from a linked list as a series of nodes.
27340 /// Moves all elements from `other` to the end of the list.
27342 /// This reuses all the nodes from `other` and moves them into `self`. After
27389 /// Moves all elements from `other` to the begin of the list.
27548 /// Removes all elements from the `LinkedList`.
27756 /// Removes the last element from a list and returns it, or `None` if
27812 // Below, we iterate towards the `i-1`th node, either from the start or the end,
27824 // better off starting from the end
27862 // Below, we iterate towards the node at the given index, either from
28347 /// Removes the current element from the `LinkedList`.
28365 /// Removes the current element from the `LinkedList` without deallocating the list node.
28390 /// Inserts the elements from the given `LinkedList` after the current one.
28413 /// Inserts the elements from the given `LinkedList` before the current one.
28871 // Short cloned from long
28884 // Long cloned from short
29192 /// Appends all key-value pairs from the union of two ascending iterators,
29196 /// If both iterators produce the same key, this method drops the pair from
29197 /// the left iterator and appends the pair from the right iterator.
29211 // Meanwhile, we build a tree from the sorted sequence in linear time.
29282 /// If two keys are equal, returns the key-value pair from the right source.
29298 /// on anything defined in the crate, apart from the `Debug` trait.
29586 /// of the range is different from the edge matching the upper bound, i.e.,
29713 /// exists, or the edge index where the key belongs, starting from a particular index.
29854 /// The behavior resulting from such a logic error is not specified, but will not result in
30666 /// Removes a key from the map, returning the value at the key if the key
30694 /// Removes a key from the map, returning the stored key and value if the key
30752 /// Moves all elements from `other` into `Self`, leaving `other` empty.
30804 /// yield elements from min (inclusive) to max (exclusive).
30807 /// range from 4 to 10.
30847 /// yield elements from min (inclusive) to max (exclusive).
30850 /// range from 4 to 10.
30974 /// be removed. If the closure returns `true`, the element is removed from
31947 /// a.insert(1, String::from("hello"));
31948 /// a.insert(2, String::from("goodbye"));
31955 /// assert_eq!(values, [String::from("hello!"),
31956 /// String::from("goodbye!")]);
32017 /// and all its descendants (i.e., all pointers and references derived from it)
32039 let ptr = NonNull::from(t);
32051 /// all pointers and references derived from it, must not be used anymore.
32100 /// Calculates the length of both trees that result from splitting up
32167 // This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface
32191 /// The behavior resulting from such a logic error is not specified, but will not result in
32416 /// yield elements from min (inclusive) to max (exclusive).
32419 /// range from 4 to 10.
32860 /// Removes the first value from the set and returns it, if any.
32885 /// Removes the last value from the set and returns it, if any.
32961 /// Removes a value from the set. Returns whether the value was
33037 /// Moves all elements from `other` into `Self`, leaving `other` empty.
33909 // that overlaps references obtained from the root.
34043 /// Deallocates a pile of nodes from the leaf up to the root.
35058 /// This `enum` is constructed from the [`entry`] method on [`BTreeMap`].
35399 /// Take ownership of the key and value from the map.
35411 /// // We delete the entry from the map.
35583 // It's not the minimum size: removing an element from such a tree does not always reduce height.
35588 // It's not the minimum size: removing an element from such a tree does not always reduce height.
35591 // Gathers all references from a mutable iterator and makes sure Miri notices if
35653 String::from("not yet allocated")
36020 a.insert(1, String::from("hello"));
36021 a.insert(2, String::from("goodbye"));
36028 assert_eq!(values, [String::from("hello!"), String::from("goodbye!")]);
37093 map1_copy.clone_from(&map1); // small cloned from large
37096 map2_copy.clone_from(&map2); // large cloned from small
37724 let offset = 165; // more arbitrarily copied from above
37737 /// Removes a key-value pair from the tree, and returns that pair, as well as
37739 /// a root node that is internal, which the caller should pop from the map
37784 // SAFETY: `new_pos` is the leaf we started from or a sibling.
37809 // Remove an adjacent KV from its leaf and then put it back in place of
37816 // The internal node may have been stolen from or merged. Go back right
37870 /// Returns the next pair of items stemming from the pair of sources
37947 // - Trees must have uniform depth/height. This means that every path down to a leaf from a
38090 /// - We cannot get implicit coercion from say `Mut<'a>` to `Immut<'a>`.
38107 /// node, and derive every other node's height from it.
38142 NodeRef { height: 0, node: NonNull::from(Box::leak(leaf)), _marker: PhantomData }
38157 let node = NonNull::from(Box::leak(internal)).cast();
38198 unsafe { usize::from((*Self::as_leaf_ptr(self)).len) }
38247 idx: unsafe { usize::from((*leaf_ptr).parent_idx.assume_init()) },
38302 MaybeUninit::slice_assume_init_ref(leaf.keys.get_unchecked(..usize::from(leaf.len)))
38537 let idx = usize::from(*len);
38554 let idx = usize::from(*len);
39043 let new_len = usize::from(new_node.data.len);
39088 /// more than N elements in front. Stealing from the left sibling is also
39240 /// Removes a key-value pair from the left child and places it in the key-value storage
39252 /// Removes a key-value pair from the right child and places it in the key-value storage
39288 // Move elements from the left child to the right one.
39356 // Move elements from the right child to the left one.
39454 /// Move the suffix after `self` from one node to another one. `right` must be empty.
39580 /// Removes and returns a value from a slice of all initialized elements, leaving behind one
39618 /// Moves all values from a slice of initialized elements to a slice
39649 // picturing the tree growing sideways from its root on the left to its
39735 /// Stocks up a possibly underfull node by merging with or stealing from a
39977 fn from(_: LayoutError) -> Self {
40053 // values are !Drop, thus won't suffer from double drops.
40240 fn slice(self, from: usize, to: usize) -> Self;
40257 fn slice(self, from: usize, to: usize) -> Self {
40258 &self[from..to]
40266 fn slice(self, from: usize, to: usize) -> Self {
40267 &mut self[from..to]
40275 fn slice(self, from: usize, to: usize) -> Self {
40276 assert!(from <= to && to < self.len());
40278 let len = to - from;
40279 ptr::slice_from_raw_parts_mut(self.as_mut_ptr().wrapping_add(from), len)
40320 pub fn from(to: &'a mut VecDeque<T>, from: &'b VecDeque<T>) -> Self {
40322 let (b0, b1) = from.as_slices();
40360 //! This queue has *O*(1) amortized inserts and removals from both ends of the
40423 /// the queue, and [`pop_front`] to remove from the queue. [`extend`] and [`append`]
40460 let mut iter = PairSlices::from(self, other);
40578 /// Copies a contiguous block of memory len long from src to dst
40602 /// Copies a contiguous block of memory len long from src to dst
40626 /// Copies a potentially wrapping block of memory len long from src to dest.
41155 // Move elements from out of desired bounds (positions after target_cap)
41512 /// Note 2: It is unspecified how many elements are removed from the deque,
41544 // make sure no uninitialized or moved-from elements are accessible at
41576 deque: NonNull::from(&mut *self),
41582 // Crucially, we only create shared references from `self` here and read from
41748 /// Removes the last element from the `VecDeque` and returns it, or `None` if
41828 /// Removes an element from anywhere in the `VecDeque` and returns it,
41863 /// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
42048 // move elements from idx to end forward not including ^ element
42092 // move elements from idx-1 to end forward not including ^ element
42122 /// Removes and returns the element at `index` from the `VecDeque`.
42289 // move elements from tail to end forward, excluding the last one
42459 /// either by removing excess elements from the back or by appending
42569 // from: DEFGH....ABC
42591 // from: FGH....ABCDE
42606 // from: EFGHI...ABCD or HIJK.ABCDEFG
42961 /// either by removing excess elements from the back or by appending clones of `value`
43208 /// `Vec<T>` came from `From<VecDeque<T>>` and hasn't been reallocated.
43209 fn from(mut other: Vec<T>) -> Self {
43252 /// let vec = Vec::from(deque);
43261 /// let vec = Vec::from(deque);
43265 fn from(mut other: VecDeque<T>) -> Self {
43690 // Another test case for #79808, taken from #80293.
43915 let vd = VecDeque::from(vec.clone());
43922 let vec = Vec::from([(); MAXIMUM_ZST_CAPACITY - 1]);
43923 let vd = VecDeque::from(vec.clone());
43932 let vec = Vec::from([(); MAXIMUM_ZST_CAPACITY]);
43933 let vd = VecDeque::from(vec.clone()); // no room for +1
43950 let vec: Vec<_> = Vec::from(vd.clone());
44012 let mut v = VecDeque::from(vr.clone());
44016 let mut u = VecDeque::from(ur.clone());
44097 self.0 = Wrapping(31) * self.0 + Wrapping(u64::from(v));
44329 //! // dist[node] = current shortest distance from `start` to `node`
44368 //! // from one node to another.
44432 /// behavior resulting from such a logic error is not specified, but will
44573 /// Removes the peeked value from the heap and returns it.
44679 /// Removes the greatest item from the binary heap and returns it, or `None` if it
44688 /// let mut heap = BinaryHeap::from(vec![1, 3]);
44761 /// let mut heap = BinaryHeap::from(vec![1, 2, 4, 5, 7]);
44773 // SAFETY: `end` goes from `self.len() - 1` to 1 (both included),
44781 // SAFETY: `end` goes from `self.len() - 1` to 1 (both included) so:
44963 // SAFETY: n starts from self.len() / 2 and goes down to 0.
44980 /// let mut a = BinaryHeap::from(v);
44983 /// let mut b = BinaryHeap::from(v);
45004 /// The retrieved elements are removed from the original heap.
45019 /// let mut heap = BinaryHeap::from(vec![1, 2, 3, 4, 5]);
45044 /// let mut heap = BinaryHeap::from(vec![-10, -5, 1, 2, 4, 13]);
45080 /// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
45102 /// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5]);
45261 /// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
45279 /// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
45300 /// let heap = BinaryHeap::from(vec![1, 3]);
45343 /// let mut heap = BinaryHeap::from(vec![1, 3]);
45359 /// Drops all items from the binary heap.
45367 /// let mut heap = BinaryHeap::from(vec![1, 3]);
45382 /// (because it was moved from or duplicated).
45727 fn from(vec: Vec<T>) -> BinaryHeap<T> {
45740 fn from(heap: BinaryHeap<T>) -> Vec<T> {
45748 BinaryHeap::from(iter.into_iter().collect::<Vec<_>>())
45767 /// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
46021 // that `T: Copy` so reading elements from the buffer doesn't invalidate
46813 //! `O(1)` pop (from the end).
47150 /// and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements.
47152 /// `Vec` will not specifically overwrite any data that is removed from it,
47253 /// Creates a `Vec<T>` directly from the raw components of another vector.
47271 /// to build a `Vec<u8>` from a pointer to a C `char` array with length `size_t`.
47272 /// It's also not safe to build one from a `Vec<u16>` and its length, because
47391 /// Creates a `Vec<T, A>` directly from the raw components of another vector.
47409 /// to build a `Vec<u8>` from a pointer to a C `char` array with length `size_t`.
47410 /// It's also not safe to build one from a `Vec<u16>` and its length, because
47892 /// derived from it. If you need to mutate the contents of the slice, use [`as_mut_ptr`].
48049 /// Removes an element from the vector and returns it.
48174 // the place we are taking from.
48315 /// The `same_bucket` function is passed references to two elements from the vector and
48317 /// from their order in the slice, so if `same_bucket(a, b)` returns `true`, `a` is removed.
48453 /// Removes the last element from a vector and returns it, or [`None`] if it
48500 /// Appends elements to `Self` from other buffer.
48514 /// from the vector, even if the iterator was not fully consumed. If the
48543 // the source vector to make sure no uninitialized or moved-from elements
48563 vec: NonNull::from(self),
48680 /// calling the closure `f`. The return values from `f` will end up
48750 /// reading from a file) before marking the data as initialized using the
48794 /// (e.g. by reading from a file) before marking the data as initialized using
48930 /// Copies elements from `src` range to the end of the vector.
49105 // - Both pointers are created from unique slice references (`&mut [_]`)
49222 /// the vector (from start to end). The vector cannot be used after calling
49327 /// It is unspecified how many elements are removed from the vector
49531 /// assert_eq!(Vec::from(&[1, 2, 3][..]), vec![1, 2, 3]);
49534 fn from(s: &[T]) -> Vec<T> {
49538 fn from(s: &[T]) -> Vec<T> {
49550 /// assert_eq!(Vec::from(&mut [1, 2, 3][..]), vec![1, 2, 3]);
49553 fn from(s: &mut [T]) -> Vec<T> {
49557 fn from(s: &mut [T]) -> Vec<T> {
49565 fn from(s: [T; N]) -> Vec<T> {
49573 /// assert_eq!(Vec::from([1, 2, 3]), vec![1, 2, 3]);
49576 fn from(s: [T; N]) -> Vec<T> {
49598 /// assert_eq!(Vec::from(o), Vec::from(b));
49600 fn from(s: Cow<'a, [T]>) -> Vec<T> {
49616 /// assert_eq!(Vec::from(b), vec![1, 2, 3]);
49618 fn from(s: Box<[T], A>) -> Self {
49635 /// assert_eq!(Box::from(vec![1, 2, 3]), vec![1, 2, 3].into_boxed_slice());
49637 fn from(v: Vec<T, A>) -> Self {
49649 /// assert_eq!(Vec::from("123"), vec![b'1', b'2', b'3']);
49651 fn from(s: &str) -> Vec<u8> {
49652 From::from(s.as_bytes())
49682 /// let mut v = String::from("hello world").into_bytes();
49884 fn from(s: &'a [T]) -> Cow<'a, [T]> {
49891 fn from(v: Vec<T>) -> Cow<'a, [T]> {
49898 fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
50050 /// The range from `self.vec.len` to `self.tail_start` contains elements
50052 /// Fill that range as much as possible with new elements from the `replace_with` iterator.
50180 //! Move a value from the stack to the heap by creating a [`Box`]:
50187 //! Move a value from a [`Box`] back to the stack by [dereferencing]:
50232 //! T` obtained from [`Box::<T>::into_raw`] may be deallocated using the
50245 //! Rust functions that will be called from C, you can define those
50257 //! /* Takes ownership from the caller; no-op when invoked with NULL */
50262 //! `struct Foo*` type from C is translated to `Box<Foo>`, which captures
50285 //! is to only use `Box<T>` for pointers that originated from the global
50290 //! from Rust. In those cases, you should directly mirror the C types
50882 /// Constructs a box from a raw pointer.
50907 /// Manually create a `Box` from scratch by using the global allocator:
50931 /// Constructs a box from a raw pointer in the given allocator.
50959 /// Manually create a `Box` from scratch by using the system allocator:
51004 /// let x = Box::new(String::from("Hello"));
51014 /// let x = Box::new(String::from("Hello"));
51053 /// let x = Box::new_in(String::from("Hello"), System);
51065 /// let x = Box::new_in(String::from("Hello"), System);
51085 reason = "use `Box::leak(b).into()` or `Unique::from(Box::leak(b))` instead"
51096 (Unique::from(Box::leak(b)), alloc)
51360 /// from the stack into it.
51367 /// assert_eq!(Box::from(x), boxed);
51369 fn from(t: T) -> Self {
51382 fn from(boxed: Box<T, A>) -> Self {
51398 /// let boxed_slice: Box<[u8]> = Box::from(slice);
51402 fn from(slice: &[T]) -> Box<[T]> {
51415 fn from(cow: Cow<'_, [T]>) -> Box<[T]> {
51417 Cow::Borrowed(slice) => Box::from(slice),
51418 Cow::Owned(slice) => Box::from(slice),
51432 /// let boxed: Box<str> = Box::from("hello");
51436 fn from(s: &str) -> Box<str> {
51437 unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) }
51444 fn from(cow: Cow<'_, str>) -> Box<str> {
51446 Cow::Borrowed(s) => Box::from(s),
51447 Cow::Owned(s) => Box::from(s),
51461 /// let boxed: Box<str> = Box::from("hello");
51462 /// let boxed_str: Box<[u8]> = Box::from(boxed);
51466 /// let boxed_slice = Box::from(slice);
51471 fn from(s: Box<str, A>) -> Self {
51485 /// let boxed: Box<[u8]> = Box::from([4, 2]);
51488 fn from(array: [T; N]) -> Box<[T]> {
51620 // It's not possible to extract the inner Uniq directly from the Box,
51811 * could have a method to project a Pin<T> from it.
52059 let boxed: Box<[f64]> = Box::from(slice);
52066 let boxed: Box<[i64]> = Box::from(slice);
52073 let boxed: Box<str> = Box::from(s);