//! This library provides smart pointers and collections for managing
//! heap-allocated values.
//!
-//! This library, like libcore, is not intended for general usage, but rather as
-//! a building block of other libraries. The types and interfaces in this
-//! library are re-exported through the [standard library](../std/index.html),
-//! and should not be used through this library.
+//! This library, like libcore, normally doesn’t need to be used directly
+//! since its contents are re-exported in the [`std` crate](../std/index.html).
+//! Crates that use the `#![no_std]` attribute however will typically
+//! not depend on `std`, so they’d use this crate instead.
//!
//! ## Boxed values
//!
//!
//! ## Atomically reference counted pointers
//!
-//! The [`Arc`](arc/index.html) type is the threadsafe equivalent of the `Rc`
+//! The [`Arc`](sync/index.html) type is the threadsafe equivalent of the `Rc`
//! type. It provides all the same functionality of `Rc`, except it requires
//! that the contained type `T` is shareable. Additionally, `Arc<T>` is itself
//! sendable while `Rc<T>` is not.
#![feature(pin)]
#![feature(ptr_internals)]
#![feature(ptr_offset_from)]
- #![cfg_attr(stage0, feature(repr_transparent))]
#![feature(rustc_attrs)]
#![feature(specialization)]
#![feature(split_ascii_whitespace)]
#[macro_use]
mod macros;
-#[rustc_deprecated(since = "1.27.0", reason = "use the heap module in core, alloc, or std instead")]
-#[unstable(feature = "allocator_api", issue = "32838")]
-/// Use the `alloc` module instead.
-pub mod allocator {
- pub use alloc::*;
-}
-
// Heaps provided for low-level allocation strategies
pub mod alloc;
}
#[cfg(test)]
mod boxed_test;
+pub mod collections;
#[cfg(target_has_atomic = "ptr")]
-pub mod arc;
+pub mod sync;
pub mod rc;
pub mod raw_vec;
-// collections modules
-pub mod binary_heap;
-mod btree;
pub mod borrow;
pub mod fmt;
-pub mod linked_list;
pub mod slice;
pub mod str;
pub mod string;
pub mod vec;
-pub mod vec_deque;
-
-#[stable(feature = "rust1", since = "1.0.0")]
-pub mod btree_map {
- //! A map based on a B-Tree.
- #[stable(feature = "rust1", since = "1.0.0")]
- pub use btree::map::*;
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-pub mod btree_set {
- //! A set based on a B-Tree.
- #[stable(feature = "rust1", since = "1.0.0")]
- pub use btree::set::*;
-}
#[cfg(not(test))]
mod std {
pub use core::ops; // RangeFull
}
-
-/// An intermediate trait for specialization of `Extend`.
-#[doc(hidden)]
-trait SpecExtend<I: IntoIterator> {
- /// Extends `self` with the contents of the given iterator.
- fn spec_extend(&mut self, iter: I);
-}
-
-#[doc(no_inline)]
-pub use binary_heap::BinaryHeap;
-#[doc(no_inline)]
-pub use btree_map::BTreeMap;
-#[doc(no_inline)]
-pub use btree_set::BTreeSet;
-#[doc(no_inline)]
-pub use linked_list::LinkedList;
-#[doc(no_inline)]
-pub use vec_deque::VecDeque;
-#[doc(no_inline)]
-pub use string::String;
-#[doc(no_inline)]
-pub use vec::Vec;
/// [`split_at_mut`]: #method.split_at_mut
#[stable(feature = "copy_from_slice", since = "1.9.0")]
pub fn copy_from_slice(&mut self, src: &[T]) where T: Copy {
- assert!(self.len() == src.len(),
- "destination and source slices have different lengths");
+ assert_eq!(self.len(), src.len(),
+ "destination and source slices have different lengths");
unsafe {
ptr::copy_nonoverlapping(
src.as_ptr(), self.as_mut_ptr(), self.len());
}
/// Function to calculate lenghts of the middle and trailing slice for `align_to{,_mut}`.
- #[cfg(not(stage0))]
fn align_to_offsets<U>(&self) -> (usize, usize) {
// What we gonna do about `rest` is figure out what multiple of `U`s we can put in a
// lowest number of `T`s. And how many `T`s we need for each such "multiple".
/// }
/// ```
#[unstable(feature = "slice_align_to", issue = "44488")]
- #[cfg(not(stage0))]
pub unsafe fn align_to<U>(&self) -> (&[T], &[U], &[T]) {
// Note that most of this function will be constant-evaluated,
if ::mem::size_of::<U>() == 0 || ::mem::size_of::<T>() == 0 {
/// }
/// ```
#[unstable(feature = "slice_align_to", issue = "44488")]
- #[cfg(not(stage0))]
pub unsafe fn align_to_mut<U>(&mut self) -> (&mut [T], &mut [U], &mut [T]) {
// Note that most of this function will be constant-evaluated,
if ::mem::size_of::<U>() == 0 || ::mem::size_of::<T>() == 0 {
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(custom_attribute)]
- #![cfg_attr(stage0, feature(macro_lifetime_matcher))]
#![allow(unused_attributes)]
#![recursion_limit="256"]
// Helper function to determine if a span came from a
// macro expansion or syntax extension.
fn generated_code(span: Span) -> bool {
- span.ctxt() != NO_EXPANSION || span == DUMMY_SP
+ span.ctxt() != NO_EXPANSION || span.is_dummy()
}
// DefId::index is a newtype and so the JSON serialisation is ugly. Therefore