mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Register new snapshots
This does not yet start the movement to rustc-serialize. That detail is left to a future PR.
This commit is contained in:
parent
bd90b936d7
commit
84086c464f
@ -448,30 +448,6 @@ impl<T: Ord> Default for BTreeSet<T> {
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<T: Ord + Clone> Sub<BTreeSet<T>,BTreeSet<T>> for BTreeSet<T> {
|
||||
/// Returns the difference of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let a: BTreeSet<int> = vec![1,2,3].into_iter().collect();
|
||||
/// let b: BTreeSet<int> = vec![3,4,5].into_iter().collect();
|
||||
///
|
||||
/// let result: BTreeSet<int> = a - b;
|
||||
/// let result_vec: Vec<int> = result.into_iter().collect();
|
||||
/// assert_eq!(result_vec, vec![1,2]);
|
||||
/// ```
|
||||
fn sub(&self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
|
||||
self.difference(rhs).cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeSet<T> {
|
||||
/// Returns the difference of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
@ -493,30 +469,6 @@ impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeSet<
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<T: Ord + Clone> BitXor<BTreeSet<T>,BTreeSet<T>> for BTreeSet<T> {
|
||||
/// Returns the symmetric difference of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let a: BTreeSet<int> = vec![1,2,3].into_iter().collect();
|
||||
/// let b: BTreeSet<int> = vec![2,3,4].into_iter().collect();
|
||||
///
|
||||
/// let result: BTreeSet<int> = a ^ b;
|
||||
/// let result_vec: Vec<int> = result.into_iter().collect();
|
||||
/// assert_eq!(result_vec, vec![1,4]);
|
||||
/// ```
|
||||
fn bitxor(&self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
|
||||
self.symmetric_difference(rhs).cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a, 'b, T: Ord + Clone> BitXor<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeSet<T> {
|
||||
/// Returns the symmetric difference of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
@ -538,30 +490,6 @@ impl<'a, 'b, T: Ord + Clone> BitXor<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeS
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<T: Ord + Clone> BitAnd<BTreeSet<T>,BTreeSet<T>> for BTreeSet<T> {
|
||||
/// Returns the intersection of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let a: BTreeSet<int> = vec![1,2,3].into_iter().collect();
|
||||
/// let b: BTreeSet<int> = vec![2,3,4].into_iter().collect();
|
||||
///
|
||||
/// let result: BTreeSet<int> = a & b;
|
||||
/// let result_vec: Vec<int> = result.into_iter().collect();
|
||||
/// assert_eq!(result_vec, vec![2,3]);
|
||||
/// ```
|
||||
fn bitand(&self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
|
||||
self.intersection(rhs).cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a, 'b, T: Ord + Clone> BitAnd<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeSet<T> {
|
||||
/// Returns the intersection of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
@ -583,30 +511,6 @@ impl<'a, 'b, T: Ord + Clone> BitAnd<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeS
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<T: Ord + Clone> BitOr<BTreeSet<T>,BTreeSet<T>> for BTreeSet<T> {
|
||||
/// Returns the union of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
/// let a: BTreeSet<int> = vec![1,2,3].into_iter().collect();
|
||||
/// let b: BTreeSet<int> = vec![3,4,5].into_iter().collect();
|
||||
///
|
||||
/// let result: BTreeSet<int> = a | b;
|
||||
/// let result_vec: Vec<int> = result.into_iter().collect();
|
||||
/// assert_eq!(result_vec, vec![1,2,3,4,5]);
|
||||
/// ```
|
||||
fn bitor(&self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
|
||||
self.union(rhs).cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a, 'b, T: Ord + Clone> BitOr<&'b BTreeSet<T>, BTreeSet<T>> for &'a BTreeSet<T> {
|
||||
/// Returns the union of `self` and `rhs` as a new `BTreeSet<T>`.
|
||||
///
|
||||
|
@ -183,60 +183,24 @@ impl<E:CLike> EnumSet<E> {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<E:CLike> Sub<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn sub(&self, e: &EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits & !e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<E:CLike> Sub<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn sub(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits & !e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<E:CLike> BitOr<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitor(&self, e: &EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits | e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<E:CLike> BitOr<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitor(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits | e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<E:CLike> BitAnd<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitand(&self, e: &EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits & e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<E:CLike> BitAnd<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitand(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits & e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitxor(&self, e: &EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits ^ e.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
|
||||
fn bitxor(self, e: EnumSet<E>) -> EnumSet<E> {
|
||||
EnumSet {bits: self.bits ^ e.bits}
|
||||
|
@ -856,28 +856,7 @@ impl<'a, S: Str> Equiv<S> for String {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[experimental = "waiting on Add stabilization"]
|
||||
impl<S: Str> Add<S, String> for String {
|
||||
/// Concatenates `self` and `other` as a new mutable `String`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let string1 = "foo".to_string();
|
||||
/// let string2 = "bar".to_string();
|
||||
/// let string3 = string1 + string2;
|
||||
/// assert_eq!(string3, "foobar".to_string());
|
||||
/// ```
|
||||
fn add(&self, other: &S) -> String {
|
||||
let mut s = String::from_str(self.as_slice());
|
||||
s.push_str(other.as_slice());
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a> Add<&'a str, String> for String {
|
||||
fn add(mut self, other: &str) -> String {
|
||||
self.push_str(other);
|
||||
@ -885,7 +864,6 @@ impl<'a> Add<&'a str, String> for String {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl<'a> Add<String, String> for &'a str {
|
||||
fn add(self, mut other: String) -> String {
|
||||
other.push_str(self);
|
||||
|
@ -1313,20 +1313,6 @@ impl<T> AsSlice<T> for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<T: Clone, Sized? V: AsSlice<T>> Add<V, Vec<T>> for Vec<T> {
|
||||
#[inline]
|
||||
fn add(&self, rhs: &V) -> Vec<T> {
|
||||
let mut res = Vec::with_capacity(self.len() + rhs.as_slice().len());
|
||||
res.push_all(self.as_slice());
|
||||
res.push_all(rhs.as_slice());
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove impl after a snapshot
|
||||
impl<'a, T: Clone> Add<&'a [T], Vec<T>> for Vec<T> {
|
||||
#[inline]
|
||||
fn add(mut self, rhs: &[T]) -> Vec<T> {
|
||||
@ -1335,7 +1321,6 @@ impl<'a, T: Clone> Add<&'a [T], Vec<T>> for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove impl after a snapshot
|
||||
impl<'a, T: Clone> Add<Vec<T>, Vec<T>> for &'a [T] {
|
||||
#[inline]
|
||||
fn add(self, mut rhs: Vec<T>) -> Vec<T> {
|
||||
|
@ -93,46 +93,6 @@ pub trait Drop {
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Add<Foo, Foo> for Foo {
|
||||
/// fn add(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Adding!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo + Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="add"]
|
||||
pub trait Add<Sized? RHS,Result> for Sized? {
|
||||
/// The method for the `+` operator
|
||||
fn add(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! add_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Add<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn add(&self, other: &$t) -> $t { (*self) + (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Add` trait is used to specify the functionality of `+`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up
|
||||
/// calling `add`, and therefore, `main` prints `Adding!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Add<Foo, Foo> for Foo {
|
||||
/// fn add(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Adding!");
|
||||
/// self
|
||||
@ -143,14 +103,12 @@ macro_rules! add_impl {
|
||||
/// Foo + Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="add"]
|
||||
pub trait Add<RHS, Result> {
|
||||
/// The method for the `+` operator
|
||||
fn add(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! add_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Add<$t, $t> for $t {
|
||||
@ -175,46 +133,6 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Sub<Foo, Foo> for Foo {
|
||||
/// fn sub(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Subtracting!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo - Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="sub"]
|
||||
pub trait Sub<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `-` operator
|
||||
fn sub(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! sub_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Sub<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn sub(&self, other: &$t) -> $t { (*self) - (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Sub` trait is used to specify the functionality of `-`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Sub`. When `Foo - Foo` happens, it ends up
|
||||
/// calling `sub`, and therefore, `main` prints `Subtracting!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Sub<Foo, Foo> for Foo {
|
||||
/// fn sub(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Subtracting!");
|
||||
/// self
|
||||
@ -225,14 +143,12 @@ macro_rules! sub_impl {
|
||||
/// Foo - Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="sub"]
|
||||
pub trait Sub<RHS, Result> {
|
||||
/// The method for the `-` operator
|
||||
fn sub(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! sub_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Sub<$t, $t> for $t {
|
||||
@ -257,46 +173,6 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Mul<Foo, Foo> for Foo {
|
||||
/// fn mul(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Multiplying!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo * Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="mul"]
|
||||
pub trait Mul<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `*` operator
|
||||
fn mul(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! mul_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Mul<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn mul(&self, other: &$t) -> $t { (*self) * (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Mul` trait is used to specify the functionality of `*`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up
|
||||
/// calling `mul`, and therefore, `main` prints `Multiplying!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Mul<Foo, Foo> for Foo {
|
||||
/// fn mul(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Multiplying!");
|
||||
/// self
|
||||
@ -307,14 +183,12 @@ macro_rules! mul_impl {
|
||||
/// Foo * Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="mul"]
|
||||
pub trait Mul<RHS, Result> {
|
||||
/// The method for the `*` operator
|
||||
fn mul(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! mul_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Mul<$t, $t> for $t {
|
||||
@ -339,46 +213,6 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Div<Foo, Foo> for Foo {
|
||||
/// fn div(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Dividing!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo / Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="div"]
|
||||
pub trait Div<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `/` operator
|
||||
fn div(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! div_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Div<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn div(&self, other: &$t) -> $t { (*self) / (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Div` trait is used to specify the functionality of `/`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up
|
||||
/// calling `div`, and therefore, `main` prints `Dividing!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Div<Foo, Foo> for Foo {
|
||||
/// fn div(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Dividing!");
|
||||
/// self
|
||||
@ -389,14 +223,12 @@ macro_rules! div_impl {
|
||||
/// Foo / Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="div"]
|
||||
pub trait Div<RHS, Result> {
|
||||
/// The method for the `/` operator
|
||||
fn div(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! div_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Div<$t, $t> for $t {
|
||||
@ -421,60 +253,6 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Rem<Foo, Foo> for Foo {
|
||||
/// fn rem(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Remainder-ing!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo % Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="rem"]
|
||||
pub trait Rem<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `%` operator
|
||||
fn rem(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! rem_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Rem<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn rem(&self, other: &$t) -> $t { (*self) % (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! rem_float_impl {
|
||||
($t:ty, $fmod:ident) => {
|
||||
impl Rem<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn rem(&self, other: &$t) -> $t {
|
||||
extern { fn $fmod(a: $t, b: $t) -> $t; }
|
||||
unsafe { $fmod(*self, *other) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The `Rem` trait is used to specify the functionality of `%`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up
|
||||
/// calling `rem`, and therefore, `main` prints `Remainder-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Rem<Foo, Foo> for Foo {
|
||||
/// fn rem(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Remainder-ing!");
|
||||
/// self
|
||||
@ -485,14 +263,12 @@ macro_rules! rem_float_impl {
|
||||
/// Foo % Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="rem"]
|
||||
pub trait Rem<RHS, Result> {
|
||||
/// The method for the `%` operator
|
||||
fn rem(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! rem_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Rem<$t, $t> for $t {
|
||||
@ -502,7 +278,6 @@ macro_rules! rem_impl {
|
||||
)*)
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! rem_float_impl {
|
||||
($t:ty, $fmod:ident) => {
|
||||
impl Rem<$t, $t> for $t {
|
||||
@ -729,46 +504,6 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitAnd<Foo, Foo> for Foo {
|
||||
/// fn bitand(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise And-ing!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo & Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="bitand"]
|
||||
pub trait BitAnd<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `&` operator
|
||||
fn bitand(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! bitand_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitAnd<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn bitand(&self, rhs: &$t) -> $t { (*self) & (*rhs) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `BitAnd` trait is used to specify the functionality of `&`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `BitAnd`. When `Foo & Foo` happens, it ends up
|
||||
/// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl BitAnd<Foo, Foo> for Foo {
|
||||
/// fn bitand(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Bitwise And-ing!");
|
||||
/// self
|
||||
@ -779,14 +514,12 @@ macro_rules! bitand_impl {
|
||||
/// Foo & Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="bitand"]
|
||||
pub trait BitAnd<RHS, Result> {
|
||||
/// The method for the `&` operator
|
||||
fn bitand(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! bitand_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitAnd<$t, $t> for $t {
|
||||
@ -811,46 +544,6 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitOr<Foo, Foo> for Foo {
|
||||
/// fn bitor(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise Or-ing!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo | Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="bitor"]
|
||||
pub trait BitOr<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `|` operator
|
||||
fn bitor(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! bitor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitOr<$t,$t> for $t {
|
||||
#[inline]
|
||||
fn bitor(&self, rhs: &$t) -> $t { (*self) | (*rhs) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `BitOr` trait is used to specify the functionality of `|`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `BitOr`. When `Foo | Foo` happens, it ends up
|
||||
/// calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl BitOr<Foo, Foo> for Foo {
|
||||
/// fn bitor(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Bitwise Or-ing!");
|
||||
/// self
|
||||
@ -861,14 +554,12 @@ macro_rules! bitor_impl {
|
||||
/// Foo | Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="bitor"]
|
||||
pub trait BitOr<RHS, Result> {
|
||||
/// The method for the `|` operator
|
||||
fn bitor(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! bitor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitOr<$t,$t> for $t {
|
||||
@ -893,46 +584,6 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitXor<Foo, Foo> for Foo {
|
||||
/// fn bitxor(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise Xor-ing!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo ^ Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="bitxor"]
|
||||
pub trait BitXor<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `^` operator
|
||||
fn bitxor(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! bitxor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitXor<$t, $t> for $t {
|
||||
#[inline]
|
||||
fn bitxor(&self, other: &$t) -> $t { (*self) ^ (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `BitXor` trait is used to specify the functionality of `^`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `BitXor`. When `Foo ^ Foo` happens, it ends up
|
||||
/// calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl BitXor<Foo, Foo> for Foo {
|
||||
/// fn bitxor(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Bitwise Xor-ing!");
|
||||
/// self
|
||||
@ -943,14 +594,12 @@ macro_rules! bitxor_impl {
|
||||
/// Foo ^ Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="bitxor"]
|
||||
pub trait BitXor<RHS, Result> {
|
||||
/// The method for the `^` operator
|
||||
fn bitxor(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! bitxor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl BitXor<$t, $t> for $t {
|
||||
@ -975,48 +624,6 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Shl<Foo, Foo> for Foo {
|
||||
/// fn shl(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Shifting left!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo << Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="shl"]
|
||||
pub trait Shl<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `<<` operator
|
||||
fn shl(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! shl_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Shl<uint, $t> for $t {
|
||||
#[inline]
|
||||
fn shl(&self, other: &uint) -> $t {
|
||||
(*self) << (*other)
|
||||
}
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Shl` trait is used to specify the functionality of `<<`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Shl`. When `Foo << Foo` happens, it ends up
|
||||
/// calling `shl`, and therefore, `main` prints `Shifting left!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Shl<Foo, Foo> for Foo {
|
||||
/// fn shl(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Shifting left!");
|
||||
/// self
|
||||
@ -1027,14 +634,12 @@ macro_rules! shl_impl {
|
||||
/// Foo << Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="shl"]
|
||||
pub trait Shl<RHS, Result> {
|
||||
/// The method for the `<<` operator
|
||||
fn shl(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! shl_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Shl<uint, $t> for $t {
|
||||
@ -1061,46 +666,6 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Shr<Foo, Foo> for Foo {
|
||||
/// fn shr(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Shifting right!");
|
||||
/// *self
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// Foo >> Foo;
|
||||
/// }
|
||||
/// ```
|
||||
// NOTE(stage0): Remove trait after a snapshot
|
||||
#[cfg(stage0)]
|
||||
#[lang="shr"]
|
||||
pub trait Shr<Sized? RHS, Result> for Sized? {
|
||||
/// The method for the `>>` operator
|
||||
fn shr(&self, rhs: &RHS) -> Result;
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
macro_rules! shr_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Shr<uint, $t> for $t {
|
||||
#[inline]
|
||||
fn shr(&self, other: &uint) -> $t { (*self) >> (*other) }
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
/// The `Shr` trait is used to specify the functionality of `>>`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// A trivial implementation of `Shr`. When `Foo >> Foo` happens, it ends up
|
||||
/// calling `shr`, and therefore, `main` prints `Shifting right!`.
|
||||
///
|
||||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Shr<Foo, Foo> for Foo {
|
||||
/// fn shr(self, _rhs: Foo) -> Foo {
|
||||
/// println!("Shifting right!");
|
||||
/// self
|
||||
@ -1111,14 +676,12 @@ macro_rules! shr_impl {
|
||||
/// Foo >> Foo;
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
#[lang="shr"]
|
||||
pub trait Shr<RHS, Result> {
|
||||
/// The method for the `>>` operator
|
||||
fn shr(self, rhs: RHS) -> Result;
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
macro_rules! shr_impl {
|
||||
($($t:ty)*) => ($(
|
||||
impl Shr<uint, $t> for $t {
|
||||
|
@ -2922,45 +2922,18 @@ impl TypeContents {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl ops::BitOr<TypeContents,TypeContents> for TypeContents {
|
||||
fn bitor(&self, other: &TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits | other.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl ops::BitOr<TypeContents,TypeContents> for TypeContents {
|
||||
fn bitor(self, other: TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits | other.bits}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl ops::BitAnd<TypeContents,TypeContents> for TypeContents {
|
||||
fn bitand(&self, other: &TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits & other.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl ops::BitAnd<TypeContents, TypeContents> for TypeContents {
|
||||
fn bitand(self, other: TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits & other.bits}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl ops::Sub<TypeContents,TypeContents> for TypeContents {
|
||||
fn sub(&self, other: &TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits & !other.bits}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl ops::Sub<TypeContents, TypeContents> for TypeContents {
|
||||
fn sub(self, other: TypeContents) -> TypeContents {
|
||||
TypeContents {bits: self.bits & !other.bits}
|
||||
|
@ -205,17 +205,6 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl BitOr<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the union of the two sets of flags.
|
||||
#[inline]
|
||||
fn bitor(&self, other: &$BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits | other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl BitOr<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the union of the two sets of flags.
|
||||
#[inline]
|
||||
@ -224,17 +213,6 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl BitXor<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the left flags, but with all the right flags toggled.
|
||||
#[inline]
|
||||
fn bitxor(&self, other: &$BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits ^ other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl BitXor<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the left flags, but with all the right flags toggled.
|
||||
#[inline]
|
||||
@ -243,17 +221,6 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl BitAnd<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the intersection between the two sets of flags.
|
||||
#[inline]
|
||||
fn bitand(&self, other: &$BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits & other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl BitAnd<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the intersection between the two sets of flags.
|
||||
#[inline]
|
||||
@ -262,17 +229,6 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Sub<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the set difference of the two sets of flags.
|
||||
#[inline]
|
||||
fn sub(&self, other: &$BitFlags) -> $BitFlags {
|
||||
$BitFlags { bits: self.bits & !other.bits }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Sub<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the set difference of the two sets of flags.
|
||||
#[inline]
|
||||
|
@ -290,21 +290,6 @@ impl Neg<Duration> for Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Add<Duration,Duration> for Duration {
|
||||
fn add(&self, rhs: &Duration) -> Duration {
|
||||
let mut secs = self.secs + rhs.secs;
|
||||
let mut nanos = self.nanos + rhs.nanos;
|
||||
if nanos >= NANOS_PER_SEC {
|
||||
nanos -= NANOS_PER_SEC;
|
||||
secs += 1;
|
||||
}
|
||||
Duration { secs: secs, nanos: nanos }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Add<Duration, Duration> for Duration {
|
||||
fn add(self, rhs: Duration) -> Duration {
|
||||
let mut secs = self.secs + rhs.secs;
|
||||
@ -317,21 +302,6 @@ impl Add<Duration, Duration> for Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Sub<Duration,Duration> for Duration {
|
||||
fn sub(&self, rhs: &Duration) -> Duration {
|
||||
let mut secs = self.secs - rhs.secs;
|
||||
let mut nanos = self.nanos - rhs.nanos;
|
||||
if nanos < 0 {
|
||||
nanos += NANOS_PER_SEC;
|
||||
secs -= 1;
|
||||
}
|
||||
Duration { secs: secs, nanos: nanos }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Sub<Duration, Duration> for Duration {
|
||||
fn sub(self, rhs: Duration) -> Duration {
|
||||
let mut secs = self.secs - rhs.secs;
|
||||
@ -344,19 +314,6 @@ impl Sub<Duration, Duration> for Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Mul<i32,Duration> for Duration {
|
||||
fn mul(&self, rhs: &i32) -> Duration {
|
||||
// Multiply nanoseconds as i64, because it cannot overflow that way.
|
||||
let total_nanos = self.nanos as i64 * *rhs as i64;
|
||||
let (extra_secs, nanos) = div_mod_floor_64(total_nanos, NANOS_PER_SEC as i64);
|
||||
let secs = self.secs * *rhs as i64 + extra_secs;
|
||||
Duration { secs: secs, nanos: nanos as i32 }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Mul<i32, Duration> for Duration {
|
||||
fn mul(self, rhs: i32) -> Duration {
|
||||
// Multiply nanoseconds as i64, because it cannot overflow that way.
|
||||
@ -367,27 +324,6 @@ impl Mul<i32, Duration> for Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Div<i32,Duration> for Duration {
|
||||
fn div(&self, rhs: &i32) -> Duration {
|
||||
let mut secs = self.secs / *rhs as i64;
|
||||
let carry = self.secs - secs * *rhs as i64;
|
||||
let extra_nanos = carry * NANOS_PER_SEC as i64 / *rhs as i64;
|
||||
let mut nanos = self.nanos / *rhs + extra_nanos as i32;
|
||||
if nanos >= NANOS_PER_SEC {
|
||||
nanos -= NANOS_PER_SEC;
|
||||
secs += 1;
|
||||
}
|
||||
if nanos < 0 {
|
||||
nanos += NANOS_PER_SEC;
|
||||
secs -= 1;
|
||||
}
|
||||
Duration { secs: secs, nanos: nanos }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Div<i32, Duration> for Duration {
|
||||
fn div(self, rhs: i32) -> Duration {
|
||||
let mut secs = self.secs / rhs as i64;
|
||||
|
@ -52,30 +52,12 @@ impl Pos for BytePos {
|
||||
fn to_uint(&self) -> uint { let BytePos(n) = *self; n as uint }
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Add<BytePos, BytePos> for BytePos {
|
||||
fn add(&self, rhs: &BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() + rhs.to_uint()) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Add<BytePos, BytePos> for BytePos {
|
||||
fn add(self, rhs: BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() + rhs.to_uint()) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Sub<BytePos, BytePos> for BytePos {
|
||||
fn sub(&self, rhs: &BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() - rhs.to_uint()) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Sub<BytePos, BytePos> for BytePos {
|
||||
fn sub(self, rhs: BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() - rhs.to_uint()) as u32)
|
||||
@ -87,30 +69,12 @@ impl Pos for CharPos {
|
||||
fn to_uint(&self) -> uint { let CharPos(n) = *self; n }
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Add<CharPos,CharPos> for CharPos {
|
||||
fn add(&self, rhs: &CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() + rhs.to_uint())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Add<CharPos, CharPos> for CharPos {
|
||||
fn add(self, rhs: CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() + rhs.to_uint())
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Sub<CharPos,CharPos> for CharPos {
|
||||
fn sub(&self, rhs: &CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() - rhs.to_uint())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Sub<CharPos, CharPos> for CharPos {
|
||||
fn sub(self, rhs: CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() - rhs.to_uint())
|
||||
|
@ -106,30 +106,6 @@ enum LockstepIterSize {
|
||||
LisContradiction(String),
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Add<LockstepIterSize, LockstepIterSize> for LockstepIterSize {
|
||||
fn add(&self, other: &LockstepIterSize) -> LockstepIterSize {
|
||||
match *self {
|
||||
LisUnconstrained => other.clone(),
|
||||
LisContradiction(_) => self.clone(),
|
||||
LisConstraint(l_len, l_id) => match *other {
|
||||
LisUnconstrained => self.clone(),
|
||||
LisContradiction(_) => other.clone(),
|
||||
LisConstraint(r_len, _) if l_len == r_len => self.clone(),
|
||||
LisConstraint(r_len, r_id) => {
|
||||
let l_n = token::get_ident(l_id);
|
||||
let r_n = token::get_ident(r_id);
|
||||
LisContradiction(format!("inconsistent lockstep iteration: \
|
||||
'{}' has {} items, but '{}' has {}",
|
||||
l_n, l_len, r_n, r_len).to_string())
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Add<LockstepIterSize, LockstepIterSize> for LockstepIterSize {
|
||||
fn add(self, other: LockstepIterSize) -> LockstepIterSize {
|
||||
match self {
|
||||
|
@ -99,29 +99,6 @@ impl Timespec {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Add<Duration, Timespec> for Timespec {
|
||||
fn add(&self, other: &Duration) -> Timespec {
|
||||
let d_sec = other.num_seconds();
|
||||
// It is safe to unwrap the nanoseconds, because there cannot be
|
||||
// more than one second left, which fits in i64 and in i32.
|
||||
let d_nsec = (*other - Duration::seconds(d_sec))
|
||||
.num_nanoseconds().unwrap() as i32;
|
||||
let mut sec = self.sec + d_sec;
|
||||
let mut nsec = self.nsec + d_nsec;
|
||||
if nsec >= NSEC_PER_SEC {
|
||||
nsec -= NSEC_PER_SEC;
|
||||
sec += 1;
|
||||
} else if nsec < 0 {
|
||||
nsec += NSEC_PER_SEC;
|
||||
sec -= 1;
|
||||
}
|
||||
Timespec::new(sec, nsec)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Add<Duration, Timespec> for Timespec {
|
||||
fn add(self, other: Duration) -> Timespec {
|
||||
let d_sec = other.num_seconds();
|
||||
@ -142,17 +119,6 @@ impl Add<Duration, Timespec> for Timespec {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Sub<Timespec, Duration> for Timespec {
|
||||
fn sub(&self, other: &Timespec) -> Duration {
|
||||
let sec = self.sec - other.sec;
|
||||
let nsec = self.nsec - other.nsec;
|
||||
Duration::seconds(sec) + Duration::nanoseconds(nsec as i64)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Sub<Timespec, Duration> for Timespec {
|
||||
fn sub(self, other: Timespec) -> Duration {
|
||||
let sec = self.sec - other.sec;
|
||||
|
@ -1,3 +1,12 @@
|
||||
S 2014-12-17 22a9f25
|
||||
freebsd-x86_64 c6a13ad985e8464fef0fc7cb7e0d221cbb4815a9
|
||||
linux-i386 03109a02e2ed6cd2bb982e93814ef555d54b55a6
|
||||
linux-x86_64 0cdf84d5f2fa7cd6b9e321150c6cfc7334206163
|
||||
macos-i386 384406ebaa2a2065a801733f4cb3f53d96a0a73d
|
||||
macos-x86_64 b00e10f44b348da454ad602a921213d8170148b3
|
||||
winnt-i386 3d6b0f333d142d99f21506dcea5f03d428ddec12
|
||||
winnt-x86_64 f8cbf77146d7ddcc5f8388c58c090f31e78de317
|
||||
|
||||
S 2014-12-15 1b97cd3
|
||||
freebsd-x86_64 a5d7ff81ec04e01e64dc201c7aa2d875ebd0cbbb
|
||||
linux-i386 47e13c2f1d26a0d13e593e0881a80ca103aa7b2e
|
||||
|
Loading…
Reference in New Issue
Block a user