Register new snapshots
This commit is contained in:
parent
912a9675c0
commit
8211539114
|
@ -116,9 +116,6 @@ pub mod slice;
|
||||||
pub mod str;
|
pub mod str;
|
||||||
pub mod tuple;
|
pub mod tuple;
|
||||||
|
|
||||||
#[cfg(stage0, not(test))]
|
|
||||||
pub mod owned;
|
|
||||||
|
|
||||||
// FIXME: this module should not exist. Once owned allocations are no longer a
|
// FIXME: this module should not exist. Once owned allocations are no longer a
|
||||||
// language type, this module can move outside to the owned allocation
|
// language type, this module can move outside to the owned allocation
|
||||||
// crate.
|
// crate.
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
//! Operations on unique pointer types
|
|
||||||
|
|
||||||
use any::{Any, AnyRefExt};
|
|
||||||
use clone::Clone;
|
|
||||||
use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
|
|
||||||
use default::Default;
|
|
||||||
use intrinsics;
|
|
||||||
use mem;
|
|
||||||
use raw::TraitObject;
|
|
||||||
use result::{Ok, Err, Result};
|
|
||||||
|
|
||||||
/// A value that represents the global exchange heap. This is the default
|
|
||||||
/// place that the `box` keyword allocates into when no place is supplied.
|
|
||||||
///
|
|
||||||
/// The following two examples are equivalent:
|
|
||||||
///
|
|
||||||
/// let foo = box(HEAP) Bar::new(...);
|
|
||||||
/// let foo = box Bar::new(...);
|
|
||||||
#[lang="exchange_heap"]
|
|
||||||
pub static HEAP: () = ();
|
|
||||||
|
|
||||||
/// A type that represents a uniquely-owned value.
|
|
||||||
#[lang="owned_box"]
|
|
||||||
pub struct Box<T>(*T);
|
|
||||||
|
|
||||||
impl<T: Default> Default for Box<T> {
|
|
||||||
fn default() -> Box<T> { box Default::default() }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Clone> Clone for Box<T> {
|
|
||||||
/// Return a copy of the owned box.
|
|
||||||
#[inline]
|
|
||||||
fn clone(&self) -> Box<T> { box {(**self).clone()} }
|
|
||||||
|
|
||||||
/// Perform copy-assignment from `source` by reusing the existing allocation.
|
|
||||||
#[inline]
|
|
||||||
fn clone_from(&mut self, source: &Box<T>) {
|
|
||||||
(**self).clone_from(&(**source));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// box pointers
|
|
||||||
impl<T:Eq> Eq for Box<T> {
|
|
||||||
#[inline]
|
|
||||||
fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
|
|
||||||
#[inline]
|
|
||||||
fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
|
|
||||||
}
|
|
||||||
impl<T:Ord> Ord for Box<T> {
|
|
||||||
#[inline]
|
|
||||||
fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
|
|
||||||
#[inline]
|
|
||||||
fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) }
|
|
||||||
#[inline]
|
|
||||||
fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) }
|
|
||||||
#[inline]
|
|
||||||
fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) }
|
|
||||||
}
|
|
||||||
impl<T: TotalOrd> TotalOrd for Box<T> {
|
|
||||||
#[inline]
|
|
||||||
fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) }
|
|
||||||
}
|
|
||||||
impl<T: TotalEq> TotalEq for Box<T> {}
|
|
||||||
|
|
||||||
/// Extension methods for an owning `Any` trait object
|
|
||||||
pub trait AnyOwnExt {
|
|
||||||
/// Returns the boxed value if it is of type `T`, or
|
|
||||||
/// `Err(Self)` if it isn't.
|
|
||||||
fn move<T: 'static>(self) -> Result<Box<T>, Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AnyOwnExt for Box<Any> {
|
|
||||||
#[inline]
|
|
||||||
fn move<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
|
|
||||||
if self.is::<T>() {
|
|
||||||
unsafe {
|
|
||||||
// Get the raw representation of the trait object
|
|
||||||
let to: TraitObject =
|
|
||||||
*mem::transmute::<&Box<Any>, &TraitObject>(&self);
|
|
||||||
|
|
||||||
// Prevent destructor on self being run
|
|
||||||
intrinsics::forget(self);
|
|
||||||
|
|
||||||
// Extract the data pointer
|
|
||||||
Ok(mem::transmute(to.data))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Err(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -133,16 +133,13 @@ extern crate core;
|
||||||
#[cfg(test)] pub use ops = realstd::ops;
|
#[cfg(test)] pub use ops = realstd::ops;
|
||||||
#[cfg(test)] pub use cmp = realstd::cmp;
|
#[cfg(test)] pub use cmp = realstd::cmp;
|
||||||
#[cfg(test)] pub use ty = realstd::ty;
|
#[cfg(test)] pub use ty = realstd::ty;
|
||||||
#[cfg(not(stage0), test)] pub use owned = realstd::owned;
|
#[cfg(test)] pub use owned = realstd::owned;
|
||||||
|
|
||||||
#[cfg(not(test))] pub use cmp = core::cmp;
|
#[cfg(not(test))] pub use cmp = core::cmp;
|
||||||
#[cfg(not(test))] pub use kinds = core::kinds;
|
#[cfg(not(test))] pub use kinds = core::kinds;
|
||||||
#[cfg(not(test))] pub use ops = core::ops;
|
#[cfg(not(test))] pub use ops = core::ops;
|
||||||
#[cfg(not(test))] pub use ty = core::ty;
|
#[cfg(not(test))] pub use ty = core::ty;
|
||||||
|
|
||||||
#[cfg(stage0, test)] pub use owned = realstd::owned;
|
|
||||||
#[cfg(stage0, not(test))] pub use owned = core::owned;
|
|
||||||
|
|
||||||
pub use core::any;
|
pub use core::any;
|
||||||
pub use core::bool;
|
pub use core::bool;
|
||||||
pub use core::cell;
|
pub use core::cell;
|
||||||
|
@ -209,7 +206,7 @@ pub mod ascii;
|
||||||
|
|
||||||
pub mod rc;
|
pub mod rc;
|
||||||
pub mod gc;
|
pub mod gc;
|
||||||
#[cfg(not(stage0), not(test))]
|
#[cfg(not(test))]
|
||||||
pub mod owned;
|
pub mod owned;
|
||||||
|
|
||||||
/* Common traits */
|
/* Common traits */
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
S 2014-05-15 6a2b3d1
|
||||||
|
freebsd-x86_64 afc98b59cb819025fecdb9d145ca4463f857a477
|
||||||
|
linux-i386 d6f7a404412ea34db3d19814ca21fe6fa662b02f
|
||||||
|
linux-x86_64 3dfb54406a7ea75565a7ea3071daad885cb91775
|
||||||
|
macos-i386 bebb937551d601ad908c9e4eaa196cc7a977c503
|
||||||
|
macos-x86_64 08346ed401ad2891c7d2ba0aac0960f6e77bb78b
|
||||||
|
winnt-i386 ad8e5b8292a00f60f1f7dc2e35bd18abeb5b858d
|
||||||
|
|
||||||
S 2014-05-11 72fc4a5
|
S 2014-05-11 72fc4a5
|
||||||
freebsd-x86_64 82db6355b0b7c8023c8845a74e2f224da2831b50
|
freebsd-x86_64 82db6355b0b7c8023c8845a74e2f224da2831b50
|
||||||
linux-i386 91901299d5f86f5b67377d940073908a1f0e4e82
|
linux-i386 91901299d5f86f5b67377d940073908a1f0e4e82
|
||||||
|
|
Loading…
Reference in New Issue