use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace};
use core::ptr::{self, Unique};
use core::raw::TraitObject;
+use core::convert::From;
/// A value that represents the heap. This is the default place that the `box`
/// keyword allocates into when no place is supplied.
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design",
issue = "27779")]
-pub const HEAP: ExchangeHeapSingleton =
- ExchangeHeapSingleton { _force_singleton: () };
+pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () };
/// This the singleton type used solely for `boxed::HEAP`.
#[unstable(feature = "box_heap",
/// See the [module-level documentation](../../std/boxed/index.html) for more.
#[lang = "owned_box"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[fundamental]
pub struct Box<T: ?Sized>(Unique<T>);
/// `IntermediateBox` represents uninitialized backing storage for `Box`.
marker: marker::PhantomData<*mut T>,
}
+#[unstable(feature = "placement_in",
+ reason = "placement box design is still being worked out.",
+ issue = "27779")]
impl<T> Place<T> for IntermediateBox<T> {
fn pointer(&mut self) -> *mut T {
self.ptr as *mut T
}
}
+#[unstable(feature = "placement_in",
+ reason = "placement box design is still being worked out.",
+ issue = "27779")]
impl<T> BoxPlace<T> for IntermediateBox<T> {
fn make_place() -> IntermediateBox<T> {
make_place()
}
}
+#[unstable(feature = "placement_in",
+ reason = "placement box design is still being worked out.",
+ issue = "27779")]
impl<T> InPlace<T> for IntermediateBox<T> {
type Owner = Box<T>;
unsafe fn finalize(self) -> Box<T> {
}
}
+#[unstable(feature = "placement_new_protocol", issue = "27779")]
impl<T> Boxed for Box<T> {
type Data = T;
type Place = IntermediateBox<T>;
}
}
+#[unstable(feature = "placement_in",
+ reason = "placement box design is still being worked out.",
+ issue = "27779")]
impl<T> Placer<T> for ExchangeHeapSingleton {
type Place = IntermediateBox<T>;
}
}
+#[unstable(feature = "placement_in",
+ reason = "placement box design is still being worked out.",
+ issue = "27779")]
impl<T: ?Sized> Drop for IntermediateBox<T> {
fn drop(&mut self) {
if self.size > 0 {
}
}
-impl<T : ?Sized> Box<T> {
+impl<T: ?Sized> Box<T> {
/// Constructs a box from the raw pointer.
///
/// After this function call, pointer is owned by resulting box.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default> Default for Box<T> {
- #[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Box<T> {
box Default::default()
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Box<[T]> {
- #[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Box<[T]> {
Box::<[T; 0]>::new([])
}
}
}
+#[stable(feature = "from_for_ptrs", since = "1.6.0")]
+impl<T> From<T> for Box<T> {
+ fn from(t: T) -> Self {
+ Box::new(t)
+ }
+}
+
impl Box<Any> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn call_box(self: Box<Self>, args: A) -> Self::Output;
}
-impl<A,F> FnBox<A> for F
- where F: FnOnce<A>
+#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
+impl<A, F> FnBox<A> for F where F: FnOnce<A>
{
type Output = F::Output;
}
}
-impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+'a> {
+#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
+impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
type Output = R;
extern "rust-call" fn call_once(self, args: A) -> R {
}
}
-impl<'a,A,R> FnOnce<A> for Box<FnBox<A,Output=R>+Send+'a> {
+#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
+impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
type Output = R;
extern "rust-call" fn call_once(self, args: A) -> R {
}
}
-impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
+#[unstable(feature = "coerce_unsized", issue = "27732")]
+impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
#[stable(feature = "box_slice_clone", since = "1.3.0")]
impl<T: Clone> Clone for Box<[T]> {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> borrow::Borrow<T> for Box<T> {
fn borrow(&self) -> &T {
&**self
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
fn borrow_mut(&mut self) -> &mut T {
&mut **self