liballoc: revert nested imports style changes.
This commit is contained in:
parent
285106a40e
commit
2396780cda
34 changed files with 294 additions and 395 deletions
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
#![stable(feature = "alloc_module", since = "1.28.0")]
|
#![stable(feature = "alloc_module", since = "1.28.0")]
|
||||||
|
|
||||||
use core::{
|
use core::intrinsics::{min_align_of_val, size_of_val};
|
||||||
intrinsics::{min_align_of_val, size_of_val},
|
use core::ptr::{NonNull, Unique};
|
||||||
ptr::{NonNull, Unique},
|
use core::usize;
|
||||||
usize,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[stable(feature = "alloc_module", since = "1.28.0")]
|
#[stable(feature = "alloc_module", since = "1.28.0")]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
@ -230,10 +228,8 @@ pub fn handle_alloc_error(layout: Layout) -> ! {
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate test;
|
extern crate test;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
use crate::{
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::alloc::{Global, Alloc, Layout, handle_alloc_error};
|
||||||
alloc::{Global, Alloc, Layout, handle_alloc_error},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn allocate_zeroed() {
|
fn allocate_zeroed() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::{
|
use std::iter::Iterator;
|
||||||
iter::Iterator,
|
use std::vec::Vec;
|
||||||
vec::Vec,
|
use std::collections::BTreeMap;
|
||||||
collections::BTreeMap,
|
|
||||||
};
|
|
||||||
use rand::{Rng, seq::SliceRandom, thread_rng};
|
use rand::{Rng, seq::SliceRandom, thread_rng};
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::{mem, ptr};
|
use std::{mem, ptr};
|
||||||
use rand::{
|
|
||||||
thread_rng, Rng, SeedableRng,
|
use rand::{thread_rng, Rng, SeedableRng};
|
||||||
distributions::{Standard, Alphanumeric},
|
use rand::distributions::{Standard, Alphanumeric};
|
||||||
};
|
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
use core::hash::{Hash, Hasher};
|
||||||
hash::{Hash, Hasher},
|
use core::ops::{Add, AddAssign, Deref};
|
||||||
ops::{Add, AddAssign, Deref},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use core::borrow::{Borrow, BorrowMut};
|
pub use core::borrow::{Borrow, BorrowMut};
|
||||||
|
|
||||||
use crate::{fmt, string::String};
|
use crate::fmt;
|
||||||
|
use crate::string::String;
|
||||||
|
|
||||||
use Cow::*;
|
use Cow::*;
|
||||||
|
|
||||||
|
|
|
@ -56,28 +56,26 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::any::Any;
|
||||||
any::Any,
|
use core::borrow;
|
||||||
borrow,
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
use core::convert::From;
|
||||||
convert::From,
|
use core::fmt;
|
||||||
fmt,
|
use core::future::Future;
|
||||||
future::Future,
|
use core::hash::{Hash, Hasher};
|
||||||
hash::{Hash, Hasher},
|
use core::iter::{Iterator, FromIterator, FusedIterator};
|
||||||
iter::{Iterator, FromIterator, FusedIterator},
|
use core::marker::{Unpin, Unsize};
|
||||||
marker::{Unpin, Unsize},
|
use core::mem;
|
||||||
mem,
|
use core::pin::Pin;
|
||||||
pin::Pin,
|
use core::ops::{
|
||||||
ops::{CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState},
|
CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState
|
||||||
ptr::{self, NonNull, Unique},
|
|
||||||
task::{LocalWaker, Poll},
|
|
||||||
};
|
};
|
||||||
|
use core::ptr::{self, NonNull, Unique};
|
||||||
|
use core::task::{LocalWaker, Poll};
|
||||||
|
|
||||||
use crate::{
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
use crate::raw_vec::RawVec;
|
||||||
raw_vec::RawVec,
|
use crate::str::from_boxed_utf8_unchecked;
|
||||||
str::from_boxed_utf8_unchecked,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A pointer type for heap allocation.
|
/// A pointer type for heap allocation.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
//! Test for `boxed` mod.
|
//! Test for `boxed` mod.
|
||||||
|
|
||||||
use core::{
|
use core::any::Any;
|
||||||
any::Any,
|
use core::ops::Deref;
|
||||||
ops::Deref,
|
use core::result::Result::{Err, Ok};
|
||||||
result::Result::{Err, Ok},
|
use core::clone::Clone;
|
||||||
clone::Clone,
|
use core::f64;
|
||||||
f64,
|
use core::i64;
|
||||||
i64,
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
|
|
||||||
|
|
|
@ -145,18 +145,14 @@
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::ops::{Deref, DerefMut};
|
||||||
ops::{Deref, DerefMut},
|
use core::iter::{FromIterator, FusedIterator};
|
||||||
iter::{FromIterator, FusedIterator},
|
use core::mem::{swap, size_of, ManuallyDrop};
|
||||||
mem::{swap, size_of, ManuallyDrop},
|
use core::ptr;
|
||||||
ptr,
|
use core::fmt;
|
||||||
fmt,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::slice;
|
||||||
slice,
|
use crate::vec::{self, Vec};
|
||||||
vec::{self, Vec},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::SpecExtend;
|
use super::SpecExtend;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
use core::{
|
use core::borrow::Borrow;
|
||||||
borrow::Borrow,
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
use core::fmt::Debug;
|
||||||
fmt::Debug,
|
use core::hash::{Hash, Hasher};
|
||||||
hash::{Hash, Hasher},
|
use core::iter::{FromIterator, Peekable, FusedIterator};
|
||||||
iter::{FromIterator, Peekable, FusedIterator},
|
use core::marker::PhantomData;
|
||||||
marker::PhantomData,
|
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||||
ops::{
|
use core::ops::{Index, RangeBounds};
|
||||||
Bound::{Excluded, Included, Unbounded},
|
use core::{fmt, intrinsics, mem, ptr};
|
||||||
Index, RangeBounds,
|
|
||||||
},
|
|
||||||
fmt, intrinsics, mem, ptr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*};
|
||||||
node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*},
|
use super::search::{self, SearchResult::*};
|
||||||
search::{self, SearchResult::*},
|
|
||||||
};
|
|
||||||
|
|
||||||
use UnderflowResult::*;
|
use UnderflowResult::*;
|
||||||
use Entry::*;
|
use Entry::*;
|
||||||
|
|
|
@ -31,17 +31,13 @@
|
||||||
// - A node of length `n` has `n` keys, `n` values, and (in an internal node) `n + 1` edges.
|
// - A node of length `n` has `n` keys, `n` values, and (in an internal node) `n + 1` edges.
|
||||||
// This implies that even an empty internal node has at least one edge.
|
// This implies that even an empty internal node has at least one edge.
|
||||||
|
|
||||||
use core::{
|
use core::marker::PhantomData;
|
||||||
marker::PhantomData,
|
use core::mem::{self, MaybeUninit};
|
||||||
mem::{self, MaybeUninit},
|
use core::ptr::{self, Unique, NonNull};
|
||||||
ptr::{self, Unique, NonNull},
|
use core::slice;
|
||||||
slice,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::alloc::{Global, Alloc, Layout};
|
||||||
alloc::{Global, Alloc, Layout},
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
|
||||||
};
|
|
||||||
|
|
||||||
const B: usize = 6;
|
const B: usize = 6;
|
||||||
pub const MIN_LEN: usize = B - 1;
|
pub const MIN_LEN: usize = B - 1;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use core::{
|
use core::borrow::Borrow;
|
||||||
borrow::Borrow,
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::node::{Handle, NodeRef, marker, ForceResult::*};
|
use super::node::{Handle, NodeRef, marker, ForceResult::*};
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
// This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface
|
// This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface
|
||||||
// to TreeMap
|
// to TreeMap
|
||||||
|
|
||||||
use core::{
|
use core::borrow::Borrow;
|
||||||
borrow::Borrow,
|
use core::cmp::Ordering::{self, Less, Greater, Equal};
|
||||||
cmp::{
|
use core::cmp::{min, max};
|
||||||
Ordering::{self, Less, Greater, Equal},
|
use core::fmt::{self, Debug};
|
||||||
min, max,
|
use core::iter::{Peekable, FromIterator, FusedIterator};
|
||||||
},
|
use core::ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds};
|
||||||
fmt::{self, Debug},
|
|
||||||
iter::{Peekable, FromIterator, FusedIterator},
|
|
||||||
ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::collections::btree_map::{self, BTreeMap, Keys};
|
use crate::collections::btree_map::{self, BTreeMap, Keys};
|
||||||
use super::Recover;
|
use super::Recover;
|
||||||
|
|
|
@ -12,15 +12,13 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
use core::fmt;
|
||||||
fmt,
|
use core::hash::{Hasher, Hash};
|
||||||
hash::{Hasher, Hash},
|
use core::iter::{FromIterator, FusedIterator};
|
||||||
iter::{FromIterator, FusedIterator},
|
use core::marker::PhantomData;
|
||||||
marker::PhantomData,
|
use core::mem;
|
||||||
mem,
|
use core::ptr::NonNull;
|
||||||
ptr::NonNull,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::boxed::Box;
|
use crate::boxed::Box;
|
||||||
use super::SpecExtend;
|
use super::SpecExtend;
|
||||||
|
@ -1215,8 +1213,11 @@ unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{thread, vec::Vec};
|
use std::thread;
|
||||||
|
use std::vec::Vec;
|
||||||
|
|
||||||
use rand::{thread_rng, RngCore};
|
use rand::{thread_rng, RngCore};
|
||||||
|
|
||||||
use super::{LinkedList, Node};
|
use super::{LinkedList, Node};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -7,25 +7,19 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::cmp::{self, Ordering};
|
||||||
cmp::{self, Ordering},
|
use core::fmt;
|
||||||
fmt,
|
use core::iter::{repeat_with, FromIterator, FusedIterator};
|
||||||
iter::{repeat_with, FromIterator, FusedIterator},
|
use core::mem;
|
||||||
mem,
|
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||||
ops::{
|
use core::ops::{Index, IndexMut, RangeBounds, Try};
|
||||||
Bound::{Excluded, Included, Unbounded},
|
use core::ptr::{self, NonNull};
|
||||||
Index, IndexMut, RangeBounds, Try,
|
use core::slice;
|
||||||
},
|
use core::hash::{Hash, Hasher};
|
||||||
ptr::{self, NonNull},
|
|
||||||
slice,
|
|
||||||
hash::{Hash, Hasher},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::collections::CollectionAllocErr;
|
||||||
collections::CollectionAllocErr,
|
use crate::raw_vec::RawVec;
|
||||||
raw_vec::RawVec,
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
|
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
|
||||||
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
|
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
|
||||||
|
|
|
@ -509,16 +509,21 @@
|
||||||
#[unstable(feature = "fmt_internals", issue = "0")]
|
#[unstable(feature = "fmt_internals", issue = "0")]
|
||||||
pub use core::fmt::rt;
|
pub use core::fmt::rt;
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use core::fmt::{
|
pub use core::fmt::{Formatter, Result, Write};
|
||||||
Formatter, Result, Write,
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
Binary, Octal,
|
pub use core::fmt::{Binary, Octal};
|
||||||
Debug, Display,
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
LowerHex, Pointer, UpperHex,
|
pub use core::fmt::{Debug, Display};
|
||||||
LowerExp, UpperExp,
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
Error,
|
pub use core::fmt::{LowerHex, Pointer, UpperHex};
|
||||||
write, ArgumentV1, Arguments,
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple
|
pub use core::fmt::{LowerExp, UpperExp};
|
||||||
};
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
pub use core::fmt::Error;
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
pub use core::fmt::{write, ArgumentV1, Arguments};
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
|
||||||
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
|
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
|
||||||
pub use core::fmt::{Alignment};
|
pub use core::fmt::{Alignment};
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,8 @@
|
||||||
|
|
||||||
#![unstable(feature = "alloc", issue = "27783")]
|
#![unstable(feature = "alloc", issue = "27783")]
|
||||||
|
|
||||||
#[unstable(feature = "alloc", issue = "27783")]
|
#[unstable(feature = "alloc", issue = "27783")] pub use crate::borrow::ToOwned;
|
||||||
pub use crate::{
|
#[unstable(feature = "alloc", issue = "27783")] pub use crate::boxed::Box;
|
||||||
borrow::ToOwned,
|
#[unstable(feature = "alloc", issue = "27783")] pub use crate::slice::SliceConcatExt;
|
||||||
boxed::Box,
|
#[unstable(feature = "alloc", issue = "27783")] pub use crate::string::{String, ToString};
|
||||||
slice::SliceConcatExt,
|
#[unstable(feature = "alloc", issue = "27783")] pub use crate::vec::Vec;
|
||||||
string::{String, ToString},
|
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
#![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "0")]
|
#![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "0")]
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
|
|
||||||
use core::{
|
use core::cmp;
|
||||||
cmp,
|
use core::mem;
|
||||||
mem,
|
use core::ops::Drop;
|
||||||
ops::Drop,
|
use core::ptr::{self, NonNull, Unique};
|
||||||
ptr::{self, NonNull, Unique},
|
use core::slice;
|
||||||
slice,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::alloc::{Alloc, Layout, Global, handle_alloc_error};
|
||||||
alloc::{Alloc, Layout, Global, handle_alloc_error},
|
use crate::collections::CollectionAllocErr::{self, *};
|
||||||
collections::CollectionAllocErr::{self, *},
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
|
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
|
||||||
/// a buffer of memory on the heap without having to worry about all the corner cases
|
/// a buffer of memory on the heap without having to worry about all the corner cases
|
||||||
|
|
|
@ -231,29 +231,25 @@ use crate::boxed::Box;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
|
|
||||||
use core::{
|
use core::any::Any;
|
||||||
any::Any,
|
use core::borrow;
|
||||||
borrow,
|
use core::cell::Cell;
|
||||||
cell::Cell,
|
use core::cmp::Ordering;
|
||||||
cmp::Ordering,
|
use core::fmt;
|
||||||
fmt,
|
use core::hash::{Hash, Hasher};
|
||||||
hash::{Hash, Hasher},
|
use core::intrinsics::abort;
|
||||||
intrinsics::abort,
|
use core::marker::{self, Unpin, Unsize, PhantomData};
|
||||||
marker::{self, Unpin, Unsize, PhantomData},
|
use core::mem::{self, align_of_val, forget, size_of_val};
|
||||||
mem::{self, align_of_val, forget, size_of_val},
|
use core::ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn};
|
||||||
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
|
use core::pin::Pin;
|
||||||
pin::Pin,
|
use core::ptr::{self, NonNull};
|
||||||
ptr::{self, NonNull},
|
use core::slice::from_raw_parts_mut;
|
||||||
slice::from_raw_parts_mut,
|
use core::convert::From;
|
||||||
convert::From,
|
use core::usize;
|
||||||
usize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
||||||
alloc::{Global, Alloc, Layout, box_free, handle_alloc_error},
|
use crate::string::String;
|
||||||
string::String,
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RcBox<T: ?Sized> {
|
struct RcBox<T: ?Sized> {
|
||||||
strong: Cell<usize>,
|
strong: Cell<usize>,
|
||||||
|
@ -1563,15 +1559,13 @@ impl<T: ?Sized> RcBoxPtr<T> for RcBox<T> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Rc, Weak};
|
use super::{Rc, Weak};
|
||||||
use std::{
|
use std::boxed::Box;
|
||||||
boxed::Box,
|
use std::cell::RefCell;
|
||||||
cell::RefCell,
|
use std::option::Option::{self, None, Some};
|
||||||
option::Option::{self, None, Some},
|
use std::result::Result::{Err, Ok};
|
||||||
result::Result::{Err, Ok},
|
use std::mem::drop;
|
||||||
mem::drop,
|
use std::clone::Clone;
|
||||||
clone::Clone,
|
use std::convert::From;
|
||||||
convert::From,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clone() {
|
fn test_clone() {
|
||||||
|
@ -1735,7 +1729,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_into_from_raw_unsized() {
|
fn test_into_from_raw_unsized() {
|
||||||
use std::{fmt::Display, string::ToString};
|
use std::fmt::Display;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
let rc: Rc<str> = Rc::from("foo");
|
let rc: Rc<str> = Rc::from("foo");
|
||||||
|
|
||||||
|
@ -1943,7 +1938,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_box_trait() {
|
fn test_from_box_trait() {
|
||||||
use std::{fmt::Display, string::ToString};
|
use std::fmt::Display;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
let b: Box<dyn Display> = box 123;
|
let b: Box<dyn Display> = box 123;
|
||||||
let r: Rc<dyn Display> = Rc::from(b);
|
let r: Rc<dyn Display> = Rc::from(b);
|
||||||
|
|
|
@ -87,19 +87,15 @@
|
||||||
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
||||||
#![cfg_attr(test, allow(unused_imports, dead_code))]
|
#![cfg_attr(test, allow(unused_imports, dead_code))]
|
||||||
|
|
||||||
use core::{
|
use core::borrow::{Borrow, BorrowMut};
|
||||||
borrow::{Borrow, BorrowMut},
|
use core::cmp::Ordering::{self, Less};
|
||||||
cmp::Ordering::{self, Less},
|
use core::mem::{self, size_of};
|
||||||
mem::{self, size_of},
|
use core::ptr;
|
||||||
ptr,
|
use core::{u8, u16, u32};
|
||||||
u8, u16, u32,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::borrow::ToOwned;
|
||||||
borrow::ToOwned,
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use core::slice::{Chunks, Windows};
|
pub use core::slice::{Chunks, Windows};
|
||||||
|
@ -142,8 +138,9 @@ pub use hack::to_vec;
|
||||||
// `test_permutations` test
|
// `test_permutations` test
|
||||||
mod hack {
|
mod hack {
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use crate::{boxed::Box, vec::Vec};
|
|
||||||
|
|
||||||
|
use crate::boxed::Box;
|
||||||
|
use crate::vec::Vec;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use crate::string::ToString;
|
use crate::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -28,26 +28,20 @@
|
||||||
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use core::{
|
use core::borrow::Borrow;
|
||||||
borrow::Borrow,
|
use core::fmt;
|
||||||
fmt,
|
use core::str as core_str;
|
||||||
str::{
|
use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
|
||||||
self as core_str,
|
use core::mem;
|
||||||
pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher},
|
use core::ptr;
|
||||||
},
|
use core::iter::FusedIterator;
|
||||||
mem,
|
use core::unicode::conversions;
|
||||||
ptr,
|
|
||||||
iter::FusedIterator,
|
|
||||||
unicode::conversions,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::borrow::ToOwned;
|
||||||
borrow::ToOwned,
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::slice::{SliceConcatExt, SliceIndex};
|
||||||
slice::{SliceConcatExt, SliceIndex},
|
use crate::string::String;
|
||||||
string::String,
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use core::str::{FromStr, Utf8Error};
|
pub use core::str::{FromStr, Utf8Error};
|
||||||
|
|
|
@ -46,30 +46,20 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::char::{decode_utf16, REPLACEMENT_CHARACTER};
|
||||||
char::{decode_utf16, REPLACEMENT_CHARACTER},
|
use core::fmt;
|
||||||
fmt,
|
use core::hash;
|
||||||
hash,
|
use core::iter::{FromIterator, FusedIterator};
|
||||||
iter::{FromIterator, FusedIterator},
|
use core::ops::{self, Add, AddAssign, Index, IndexMut, RangeBounds};
|
||||||
ops::{
|
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||||
self,
|
use core::ptr;
|
||||||
Bound::{Excluded, Included, Unbounded},
|
use core::str::{pattern::Pattern, lossy};
|
||||||
Add, AddAssign, Index, IndexMut, RangeBounds,
|
|
||||||
},
|
|
||||||
ptr,
|
|
||||||
str::{
|
|
||||||
pattern::Pattern,
|
|
||||||
lossy,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::borrow::{Cow, ToOwned};
|
||||||
borrow::{Cow, ToOwned},
|
use crate::collections::CollectionAllocErr;
|
||||||
collections::CollectionAllocErr,
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
|
||||||
str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars},
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A UTF-8 encoded, growable string.
|
/// A UTF-8 encoded, growable string.
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,34 +6,28 @@
|
||||||
//!
|
//!
|
||||||
//! [arc]: struct.Arc.html
|
//! [arc]: struct.Arc.html
|
||||||
|
|
||||||
use core::{
|
use core::any::Any;
|
||||||
any::Any,
|
use core::sync::atomic;
|
||||||
sync::atomic::{
|
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
|
||||||
self,
|
use core::borrow;
|
||||||
Ordering::{Acquire, Relaxed, Release, SeqCst}
|
use core::fmt;
|
||||||
},
|
use core::cmp::{self, Ordering};
|
||||||
borrow,
|
use core::intrinsics::abort;
|
||||||
fmt,
|
use core::mem::{self, align_of_val, size_of_val};
|
||||||
cmp::{self, Ordering},
|
use core::ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn};
|
||||||
intrinsics::abort,
|
use core::pin::Pin;
|
||||||
mem::{self, align_of_val, size_of_val},
|
use core::ptr::{self, NonNull};
|
||||||
ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn},
|
use core::marker::{Unpin, Unsize, PhantomData};
|
||||||
pin::Pin,
|
use core::hash::{Hash, Hasher};
|
||||||
ptr::{self, NonNull},
|
use core::{isize, usize};
|
||||||
marker::{Unpin, Unsize, PhantomData},
|
use core::convert::From;
|
||||||
hash::{Hash, Hasher},
|
use core::slice::from_raw_parts_mut;
|
||||||
isize, usize,
|
|
||||||
convert::From,
|
|
||||||
slice::from_raw_parts_mut,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
||||||
alloc::{Global, Alloc, Layout, box_free, handle_alloc_error},
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::rc::is_dangling;
|
||||||
rc::is_dangling,
|
use crate::string::String;
|
||||||
string::String,
|
use crate::vec::Vec;
|
||||||
vec::Vec,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A soft limit on the amount of references that may be made to an `Arc`.
|
/// A soft limit on the amount of references that may be made to an `Arc`.
|
||||||
///
|
///
|
||||||
|
@ -1654,18 +1648,16 @@ impl<T> From<Vec<T>> for Arc<[T]> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{
|
use std::boxed::Box;
|
||||||
boxed::Box,
|
use std::clone::Clone;
|
||||||
clone::Clone,
|
use std::sync::mpsc::channel;
|
||||||
sync::mpsc::channel,
|
use std::mem::drop;
|
||||||
mem::drop,
|
use std::ops::Drop;
|
||||||
ops::Drop,
|
use std::option::Option::{self, None, Some};
|
||||||
option::Option::{self, None, Some},
|
use std::sync::atomic::{self, Ordering::{Acquire, SeqCst}};
|
||||||
sync::atomic::{self, Ordering::{Acquire, SeqCst}},
|
use std::thread;
|
||||||
thread,
|
use std::sync::Mutex;
|
||||||
sync::Mutex,
|
use std::convert::From;
|
||||||
convert::From,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{Arc, Weak};
|
use super::{Arc, Weak};
|
||||||
use crate::vec::Vec;
|
use crate::vec::Vec;
|
||||||
|
@ -1774,7 +1766,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_into_from_raw_unsized() {
|
fn test_into_from_raw_unsized() {
|
||||||
use std::{fmt::Display, string::ToString};
|
use std::fmt::Display;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
let arc: Arc<str> = Arc::from("foo");
|
let arc: Arc<str> = Arc::from("foo");
|
||||||
|
|
||||||
|
@ -2086,7 +2079,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_box_trait() {
|
fn test_from_box_trait() {
|
||||||
use std::{fmt::Display, string::ToString};
|
use std::fmt::Display;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
let b: Box<dyn Display> = box 123;
|
let b: Box<dyn Display> = box 123;
|
||||||
let r: Arc<dyn Display> = Arc::from(b);
|
let r: Arc<dyn Display> = Arc::from(b);
|
||||||
|
|
|
@ -8,11 +8,9 @@ pub use if_arc::*;
|
||||||
#[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
|
#[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
|
||||||
mod if_arc {
|
mod if_arc {
|
||||||
use super::*;
|
use super::*;
|
||||||
use core::{
|
use core::marker::PhantomData;
|
||||||
marker::PhantomData,
|
use core::mem;
|
||||||
mem,
|
use core::ptr::{self, NonNull};
|
||||||
ptr::{self, NonNull},
|
|
||||||
};
|
|
||||||
use crate::sync::Arc;
|
use crate::sync::Arc;
|
||||||
|
|
||||||
/// A way of waking up a specific task.
|
/// A way of waking up a specific task.
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::{
|
use std::any::Any;
|
||||||
any::Any,
|
use std::sync::{Arc, Weak};
|
||||||
sync::{Arc, Weak},
|
use std::cell::RefCell;
|
||||||
cell::RefCell,
|
use std::cmp::PartialEq;
|
||||||
cmp::PartialEq,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uninhabited() {
|
fn uninhabited() {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::{
|
use std::cmp;
|
||||||
cmp,
|
use std::collections::BinaryHeap;
|
||||||
collections::{BinaryHeap, binary_heap::{Drain, PeekMut}},
|
use std::collections::binary_heap::{Drain, PeekMut};
|
||||||
panic::{self, AssertUnwindSafe},
|
use std::panic::{self, AssertUnwindSafe};
|
||||||
sync::atomic::{AtomicUsize, Ordering},
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
};
|
|
||||||
|
|
||||||
use rand::{thread_rng, seq::SliceRandom};
|
use rand::{thread_rng, seq::SliceRandom};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::{
|
use std::collections::BTreeMap;
|
||||||
collections::{BTreeMap, btree_map::Entry::{Occupied, Vacant}},
|
use std::collections::btree_map::Entry::{Occupied, Vacant};
|
||||||
ops::Bound::{self, Excluded, Included, Unbounded},
|
use std::ops::Bound::{self, Excluded, Included, Unbounded};
|
||||||
rc::Rc,
|
use std::rc::Rc;
|
||||||
iter::FromIterator,
|
use std::iter::FromIterator;
|
||||||
};
|
|
||||||
|
|
||||||
use super::DeterministicRng;
|
use super::DeterministicRng;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::{
|
use std::collections::BTreeSet;
|
||||||
collections::BTreeSet,
|
use std::iter::FromIterator;
|
||||||
iter::FromIterator
|
|
||||||
};
|
|
||||||
use super::DeterministicRng;
|
use super::DeterministicRng;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
extern crate core;
|
extern crate core;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
use std::{
|
use std::hash::{Hash, Hasher};
|
||||||
hash::{Hash, Hasher},
|
use std::collections::hash_map::DefaultHasher;
|
||||||
collections::hash_map::DefaultHasher,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod arc;
|
mod arc;
|
||||||
mod binary_heap;
|
mod binary_heap;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::{
|
use std::any::Any;
|
||||||
any::Any,
|
use std::rc::{Rc, Weak};
|
||||||
rc::{Rc, Weak},
|
use std::cell::RefCell;
|
||||||
cell::RefCell,
|
use std::cmp::PartialEq;
|
||||||
cmp::PartialEq,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uninhabited() {
|
fn uninhabited() {
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
use std::{
|
use std::cell::Cell;
|
||||||
cell::Cell,
|
use std::cmp::Ordering::{self, Equal, Greater, Less};
|
||||||
cmp::Ordering::{self, Equal, Greater, Less},
|
use std::mem;
|
||||||
mem,
|
use std::panic;
|
||||||
panic,
|
use std::rc::Rc;
|
||||||
rc::Rc,
|
use std::sync::atomic::{Ordering::Relaxed, AtomicUsize};
|
||||||
sync::atomic::{Ordering::Relaxed, AtomicUsize},
|
use std::thread;
|
||||||
thread,
|
|
||||||
};
|
|
||||||
|
|
||||||
use rand::{
|
use rand::{Rng, RngCore, thread_rng};
|
||||||
Rng, RngCore, thread_rng,
|
use rand::seq::SliceRandom;
|
||||||
seq::SliceRandom,
|
use rand::distributions::Standard;
|
||||||
distributions::Standard,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn square(n: usize) -> usize {
|
fn square(n: usize) -> usize {
|
||||||
n * n
|
n * n
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::{
|
use std::borrow::Cow;
|
||||||
borrow::Cow,
|
use std::cmp::Ordering::{Equal, Greater, Less};
|
||||||
cmp::Ordering::{Equal, Greater, Less},
|
use std::str::from_utf8;
|
||||||
str::from_utf8,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_le() {
|
fn test_le() {
|
||||||
|
@ -1601,10 +1599,8 @@ fn test_repeat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod pattern {
|
mod pattern {
|
||||||
use std::str::pattern::{
|
use std::str::pattern::{Pattern, Searcher, ReverseSearcher};
|
||||||
Pattern, Searcher, ReverseSearcher,
|
use std::str::pattern::SearchStep::{self, Match, Reject, Done};
|
||||||
SearchStep::{self, Match, Reject, Done},
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! make_test {
|
macro_rules! make_test {
|
||||||
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
|
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::{
|
use std::borrow::Cow;
|
||||||
borrow::Cow,
|
use std::collections::CollectionAllocErr::*;
|
||||||
collections::CollectionAllocErr::*,
|
use std::mem::size_of;
|
||||||
mem::size_of,
|
use std::{usize, isize};
|
||||||
usize, isize,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
|
pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
|
||||||
fn into_cow(self) -> Cow<'a, B>;
|
fn into_cow(self) -> Cow<'a, B>;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use std::{
|
use std::borrow::Cow;
|
||||||
borrow::Cow,
|
use std::mem::size_of;
|
||||||
mem::size_of,
|
use std::{usize, isize};
|
||||||
usize, isize,
|
use std::vec::{Drain, IntoIter};
|
||||||
vec::{Drain, IntoIter},
|
use std::collections::CollectionAllocErr::*;
|
||||||
collections::CollectionAllocErr::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DropCounter<'a> {
|
struct DropCounter<'a> {
|
||||||
count: &'a mut u32,
|
count: &'a mut u32,
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
use std::{
|
use std::fmt::Debug;
|
||||||
fmt::Debug,
|
use std::collections::{VecDeque, vec_deque::Drain};
|
||||||
collections::{
|
use std::collections::CollectionAllocErr::*;
|
||||||
VecDeque, vec_deque::Drain,
|
use std::mem::size_of;
|
||||||
CollectionAllocErr::*,
|
use std::{usize, isize};
|
||||||
},
|
|
||||||
mem::size_of,
|
|
||||||
usize, isize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::hash;
|
use crate::hash;
|
||||||
|
|
||||||
|
|
|
@ -56,29 +56,22 @@
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use core::{
|
use core::cmp::{self, Ordering};
|
||||||
cmp::{self, Ordering},
|
use core::fmt;
|
||||||
fmt,
|
use core::hash::{self, Hash};
|
||||||
hash::{self, Hash},
|
use core::intrinsics::{arith_offset, assume};
|
||||||
intrinsics::{arith_offset, assume},
|
use core::iter::{FromIterator, FusedIterator, TrustedLen};
|
||||||
iter::{FromIterator, FusedIterator, TrustedLen},
|
use core::marker::PhantomData;
|
||||||
marker::PhantomData,
|
use core::mem;
|
||||||
mem,
|
use core::ops::{self, Index, IndexMut, RangeBounds};
|
||||||
ops::{
|
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||||
self,
|
use core::ptr::{self, NonNull};
|
||||||
Bound::{Excluded, Included, Unbounded},
|
use core::slice::{self, SliceIndex};
|
||||||
Index, IndexMut, RangeBounds,
|
|
||||||
},
|
|
||||||
ptr::{self, NonNull},
|
|
||||||
slice::{self, SliceIndex},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::borrow::{ToOwned, Cow};
|
||||||
borrow::{ToOwned, Cow},
|
use crate::collections::CollectionAllocErr;
|
||||||
collections::CollectionAllocErr,
|
use crate::boxed::Box;
|
||||||
boxed::Box,
|
use crate::raw_vec::RawVec;
|
||||||
raw_vec::RawVec,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
|
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue