libcore: use #[deriving(Copy)]

This commit is contained in:
Jorge Aparicio 2014-12-14 22:35:22 -05:00
parent c32a48293a
commit 30cefcbdfd
16 changed files with 57 additions and 151 deletions

View file

@ -16,7 +16,6 @@ pub use self::Ordering::*;
use intrinsics;
use cell::UnsafeCell;
use kinds::Copy;
/// A boolean type which can be safely shared between threads.
#[stable]
@ -53,6 +52,7 @@ pub struct AtomicPtr<T> {
/// Rust's memory orderings are [the same as
/// C++'s](http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync).
#[stable]
#[deriving(Copy)]
pub enum Ordering {
/// No ordering constraints, only atomic operations.
#[stable]
@ -77,8 +77,6 @@ pub enum Ordering {
SeqCst,
}
impl Copy for Ordering {}
/// An `AtomicBool` initialized to `false`.
#[unstable = "may be renamed, pending conventions for static initalizers"]
pub const INIT_ATOMIC_BOOL: AtomicBool =

View file

@ -43,7 +43,7 @@
pub use self::Ordering::*;
use kinds::{Copy, Sized};
use kinds::Sized;
use option::Option::{mod, Some, None};
/// Trait for values that can be compared for equality and inequality.
@ -94,7 +94,7 @@ pub trait Eq<Sized? Rhs = Self> for Sized?: PartialEq<Rhs> {
}
/// An ordering is, e.g, a result of a comparison between two values.
#[deriving(Clone, PartialEq, Show)]
#[deriving(Clone, Copy, PartialEq, Show)]
#[stable]
pub enum Ordering {
/// An ordering where a compared value is less [than another].
@ -105,8 +105,6 @@ pub enum Ordering {
Greater = 1i,
}
impl Copy for Ordering {}
impl Ordering {
/// Reverse the `Ordering`, so that `Less` becomes `Greater` and
/// vice versa.

View file

@ -44,10 +44,9 @@ pub type Result = result::Result<(), Error>;
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
#[experimental = "core and I/O reconciliation may alter this definition"]
#[deriving(Copy)]
pub struct Error;
impl Copy for Error {}
/// A collection of methods that are required to format a message into a stream.
///
/// This trait is the type which this modules requires when formatting
@ -104,6 +103,7 @@ enum Void {}
/// compile time it is ensured that the function and the value have the correct
/// types, and then this struct is used to canonicalize arguments to one type.
#[experimental = "implementation detail of the `format_args!` macro"]
#[deriving(Copy)]
pub struct Argument<'a> {
value: &'a Void,
formatter: fn(&Void, &mut Formatter) -> Result,
@ -137,8 +137,6 @@ impl<'a> Argument<'a> {
}
}
impl<'a> Copy for Argument<'a> {}
impl<'a> Arguments<'a> {
/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.

View file

@ -16,7 +16,6 @@
use fmt;
use iter::DoubleEndedIteratorExt;
use kinds::Copy;
use num::{Int, cast};
use slice::SliceExt;
@ -109,14 +108,12 @@ radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
x @ 10 ... 15 => b'A' + (x - 10) }
/// A radix with in the range of `2..36`.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, Copy, PartialEq)]
#[unstable = "may be renamed or move to a different module"]
pub struct Radix {
base: u8,
}
impl Copy for Radix {}
impl Radix {
fn new(base: u8) -> Radix {
assert!(2 <= base && base <= 36, "the base must be in the range of 2..36: {}", base);
@ -137,10 +134,9 @@ impl GenericRadix for Radix {
/// A helper type for formatting radixes.
#[unstable = "may be renamed or move to a different module"]
#[deriving(Copy)]
pub struct RadixFmt<T, R>(T, R);
impl<T,R> Copy for RadixFmt<T,R> where T: Copy, R: Copy {}
/// Constructs a radix formatter in the range of `2..36`.
///
/// # Example

View file

@ -20,17 +20,16 @@ pub use self::Alignment::*;
pub use self::Count::*;
pub use self::Position::*;
pub use self::Flag::*;
use kinds::Copy;
#[doc(hidden)]
#[deriving(Copy)]
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
}
impl<'a> Copy for Argument<'a> {}
#[doc(hidden)]
#[deriving(Copy)]
pub struct FormatSpec {
pub fill: char,
pub align: Alignment,
@ -39,10 +38,8 @@ pub struct FormatSpec {
pub width: Count,
}
impl Copy for FormatSpec {}
/// Possible alignments that can be requested as part of a formatting directive.
#[deriving(PartialEq)]
#[deriving(Copy, PartialEq)]
pub enum Alignment {
/// Indication that contents should be left-aligned.
AlignLeft,
@ -54,27 +51,24 @@ pub enum Alignment {
AlignUnknown,
}
impl Copy for Alignment {}
#[doc(hidden)]
#[deriving(Copy)]
pub enum Count {
CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
}
impl Copy for Count {}
#[doc(hidden)]
#[deriving(Copy)]
pub enum Position {
ArgumentNext, ArgumentIs(uint)
}
impl Copy for Position {}
/// Flags which can be passed to formatting via a directive.
///
/// These flags are discovered through the `flags` field of the `Formatter`
/// structure. The flag in that structure is a union of these flags into a
/// `uint` where each flag's discriminant is the corresponding bit.
#[deriving(Copy)]
pub enum Flag {
/// A flag which enables number formatting to always print the sign of a
/// number.
@ -89,5 +83,3 @@ pub enum Flag {
/// being aware of the sign to be printed.
FlagSignAwareZeroPad,
}
impl Copy for Flag {}

View file

@ -42,11 +42,10 @@
#![experimental]
#![allow(missing_docs)]
use kinds::Copy;
pub type GlueFn = extern "Rust" fn(*const i8);
#[lang="ty_desc"]
#[deriving(Copy)]
pub struct TyDesc {
// sizeof(T)
pub size: uint,
@ -61,8 +60,6 @@ pub struct TyDesc {
pub name: &'static str,
}
impl Copy for TyDesc {}
extern "rust-intrinsic" {
// NB: These intrinsics take unsafe pointers because they mutate aliased
@ -540,13 +537,11 @@ extern "rust-intrinsic" {
/// `TypeId` represents a globally unique identifier for a type
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
// middle/lang_items.rs
#[deriving(Clone, PartialEq, Eq, Show)]
#[deriving(Clone, Copy, PartialEq, Eq, Show)]
pub struct TypeId {
t: u64,
}
impl Copy for TypeId {}
impl TypeId {
/// Returns the `TypeId` of the type this generic function has been instantiated with
pub fn of<T: 'static>() -> TypeId {

View file

@ -59,7 +59,6 @@ pub use self::MinMaxResult::*;
use clone::Clone;
use cmp;
use cmp::Ord;
use kinds::Copy;
use mem;
use num::{ToPrimitive, Int};
use ops::{Add, Deref, FnMut};
@ -1168,7 +1167,7 @@ impl<A, I> CloneIteratorExt for I where I: Iterator<A> + Clone {
}
/// An iterator that repeats endlessly
#[deriving(Clone)]
#[deriving(Clone, Copy)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable]
pub struct Cycle<T> {
@ -1176,8 +1175,6 @@ pub struct Cycle<T> {
iter: T,
}
impl<T:Copy> Copy for Cycle<T> {}
impl<A, T: Clone + Iterator<A>> Iterator<A> for Cycle<T> {
#[inline]
fn next(&mut self) -> Option<A> {
@ -1635,13 +1632,12 @@ impl<A, T: RandomAccessIterator<A>> RandomAccessIterator<(uint, A)> for Enumerat
/// An iterator with a `peek()` that returns an optional reference to the next element.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable]
#[deriving(Copy)]
pub struct Peekable<A, T> {
iter: T,
peeked: Option<A>,
}
impl<T:Copy,A:Copy> Copy for Peekable<A,T> {}
impl<A, T: Iterator<A>> Iterator<A> for Peekable<A, T> {
#[inline]
fn next(&mut self) -> Option<A> {
@ -2267,7 +2263,7 @@ impl<A, St, F> Iterator<A> for Unfold<A, St, F> where F: FnMut(&mut St) -> Optio
/// An infinite iterator starting at `start` and advancing by `step` with each
/// iteration
#[deriving(Clone)]
#[deriving(Clone, Copy)]
#[unstable = "may be renamed"]
pub struct Counter<A> {
/// The current state the counter is at (next value to be yielded)
@ -2276,8 +2272,6 @@ pub struct Counter<A> {
step: A,
}
impl<A:Copy> Copy for Counter<A> {}
/// Creates a new counter with the specified start/step
#[inline]
#[unstable = "may be renamed"]
@ -2301,7 +2295,7 @@ impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
}
/// An iterator over the range [start, stop)
#[deriving(Clone)]
#[deriving(Clone, Copy)]
#[unstable = "may be refactored due to numerics reform or ops reform"]
pub struct Range<A> {
state: A,
@ -2309,8 +2303,6 @@ pub struct Range<A> {
one: A,
}
impl<A:Copy> Copy for Range<A> {}
/// Returns an iterator over the given range [start, stop) (that is, starting
/// at start (inclusive), and ending at stop (exclusive)).
///

View file

@ -225,11 +225,9 @@ pub mod marker {
/// For more information about variance, refer to this Wikipedia
/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
#[lang="covariant_lifetime"]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
#[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct CovariantLifetime<'a>;
impl<'a> Copy for CovariantLifetime<'a> {}
/// As `ContravariantType`, but for lifetime parameters. Using
/// `ContravariantLifetime<'a>` indicates that it is ok to
/// substitute a *shorter* lifetime for `'a` than the one you
@ -243,11 +241,9 @@ pub mod marker {
/// For more information about variance, refer to this Wikipedia
/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
#[lang="contravariant_lifetime"]
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
#[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct ContravariantLifetime<'a>;
impl<'a> Copy for ContravariantLifetime<'a> {}
/// As `InvariantType`, but for lifetime parameters. Using
/// `InvariantLifetime<'a>` indicates that it is not ok to
/// substitute any other lifetime for `'a` besides its original

View file

@ -1225,7 +1225,7 @@ impl_num_cast! { f32, to_f32 }
impl_num_cast! { f64, to_f64 }
/// Used for representing the classification of floating point numbers
#[deriving(PartialEq, Show)]
#[deriving(Copy, PartialEq, Show)]
#[unstable = "may be renamed"]
pub enum FPCategory {
/// "Not a Number", often obtained by dividing by zero
@ -1240,8 +1240,6 @@ pub enum FPCategory {
FPNormal,
}
impl Copy for FPCategory {}
/// A built-in floating point number.
// FIXME(#5527): In a future version of Rust, many of these functions will
// become constants.

View file

@ -88,10 +88,9 @@ pub trait Drop {
/// calling `add`, and therefore, `main` prints `Adding!`.
///
/// ```rust
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Add<Foo, Foo> for Foo {
/// fn add(&self, _rhs: &Foo) -> Foo {
/// println!("Adding!");
@ -170,10 +169,9 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// calling `sub`, and therefore, `main` prints `Subtracting!`.
///
/// ```rust
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Sub<Foo, Foo> for Foo {
/// fn sub(&self, _rhs: &Foo) -> Foo {
/// println!("Subtracting!");
@ -252,10 +250,9 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// calling `mul`, and therefore, `main` prints `Multiplying!`.
///
/// ```rust
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Mul<Foo, Foo> for Foo {
/// fn mul(&self, _rhs: &Foo) -> Foo {
/// println!("Multiplying!");
@ -334,10 +331,9 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// calling `div`, and therefore, `main` prints `Dividing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Div<Foo, Foo> for Foo {
/// fn div(&self, _rhs: &Foo) -> Foo {
/// println!("Dividing!");
@ -416,10 +412,9 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// calling `rem`, and therefore, `main` prints `Remainder-ing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Rem<Foo, Foo> for Foo {
/// fn rem(&self, _rhs: &Foo) -> Foo {
/// println!("Remainder-ing!");
@ -527,10 +522,9 @@ rem_float_impl! { f64, fmod }
/// `neg`, and therefore, `main` prints `Negating!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Neg<Foo> for Foo {
/// fn neg(&self) -> Foo {
/// println!("Negating!");
@ -639,10 +633,9 @@ neg_uint_impl! { u64, i64 }
/// `not`, and therefore, `main` prints `Not-ing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Not<Foo> for Foo {
/// fn not(&self) -> Foo {
/// println!("Not-ing!");
@ -724,10 +717,9 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl BitAnd<Foo, Foo> for Foo {
/// fn bitand(&self, _rhs: &Foo) -> Foo {
/// println!("Bitwise And-ing!");
@ -806,10 +798,9 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl BitOr<Foo, Foo> for Foo {
/// fn bitor(&self, _rhs: &Foo) -> Foo {
/// println!("Bitwise Or-ing!");
@ -888,10 +879,9 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl BitXor<Foo, Foo> for Foo {
/// fn bitxor(&self, _rhs: &Foo) -> Foo {
/// println!("Bitwise Xor-ing!");
@ -970,10 +960,9 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `shl`, and therefore, `main` prints `Shifting left!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Shl<Foo, Foo> for Foo {
/// fn shl(&self, _rhs: &Foo) -> Foo {
/// println!("Shifting left!");
@ -1056,10 +1045,9 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `shr`, and therefore, `main` prints `Shifting right!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Shr<Foo, Foo> for Foo {
/// fn shr(&self, _rhs: &Foo) -> Foo {
/// println!("Shifting right!");
@ -1139,10 +1127,9 @@ shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// calling `index`, and therefore, `main` prints `Indexing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Index<Foo, Foo> for Foo {
/// fn index<'a>(&'a self, _index: &Foo) -> &'a Foo {
/// println!("Indexing!");
@ -1169,10 +1156,9 @@ pub trait Index<Sized? Index, Sized? Result> for Sized? {
/// calling `index_mut`, and therefore, `main` prints `Indexing!`.
///
/// ```
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl IndexMut<Foo, Foo> for Foo {
/// fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo {
/// println!("Indexing!");
@ -1199,10 +1185,9 @@ pub trait IndexMut<Sized? Index, Sized? Result> for Sized? {
/// calling `slice_to`, and therefore, `main` prints `Slicing!`.
///
/// ```ignore
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Slice<Foo, Foo> for Foo {
/// fn as_slice_<'a>(&'a self) -> &'a Foo {
/// println!("Slicing!");
@ -1247,10 +1232,9 @@ pub trait Slice<Sized? Idx, Sized? Result> for Sized? {
/// calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
///
/// ```ignore
/// #[deriving(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl SliceMut<Foo, Foo> for Foo {
/// fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
/// println!("Slicing!");

View file

@ -149,7 +149,6 @@ use cmp::{Eq, Ord};
use default::Default;
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator};
use iter::{ExactSizeIterator};
use kinds::Copy;
use mem;
use result::Result;
use result::Result::{Ok, Err};
@ -164,7 +163,7 @@ use ops::{Deref, FnOnce};
// which basically means it must be `Option`.
/// The `Option` type.
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Hash)]
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Show, Hash)]
#[stable]
pub enum Option<T> {
/// No value
@ -920,7 +919,3 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
}
}
}
#[stable]
impl<T:Copy> Copy for Option<T> {}

View file

@ -33,25 +33,23 @@ impl<T> Copy for Slice<T> {}
/// The representation of a Rust closure
#[repr(C)]
#[deriving(Copy)]
pub struct Closure {
pub code: *mut (),
pub env: *mut (),
}
impl Copy for Closure {}
/// The representation of a Rust trait object.
///
/// This struct does not have a `Repr` implementation
/// because there is no way to refer to all trait objects generically.
#[repr(C)]
#[deriving(Copy)]
pub struct TraitObject {
pub data: *mut (),
pub vtable: *mut (),
}
impl Copy for TraitObject {}
/// This trait is meant to map equivalences between raw structs and their
/// corresponding rust values.
pub trait Repr<T> for Sized? {

View file

@ -232,7 +232,6 @@
use self::Result::*;
use kinds::Copy;
use std::fmt::Show;
use slice;
use slice::AsSlice;
@ -244,7 +243,7 @@ use ops::{FnMut, FnOnce};
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
///
/// See the [`std::result`](index.html) module documentation for details.
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Hash)]
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Show, Hash)]
#[must_use]
#[stable]
pub enum Result<T, E> {
@ -919,6 +918,3 @@ pub fn fold<T,
}
Ok(init)
}
impl<T:Copy,U:Copy> Copy for Result<T,U> {}

View file

@ -37,93 +37,70 @@
#![allow(non_camel_case_types)]
#![allow(missing_docs)]
use kinds::Copy;
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8);
impl Copy for i8x16 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
pub i16, pub i16, pub i16, pub i16);
impl Copy for i16x8 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
impl Copy for i32x4 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct i64x2(pub i64, pub i64);
impl Copy for i64x2 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8);
impl Copy for u8x16 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
pub u16, pub u16, pub u16, pub u16);
impl Copy for u16x8 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
impl Copy for u32x4 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct u64x2(pub u64, pub u64);
impl Copy for u64x2 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
impl Copy for f32x4 {}
#[experimental]
#[simd]
#[deriving(Show)]
#[deriving(Copy, Show)]
#[repr(C)]
pub struct f64x2(pub f64, pub f64);
impl Copy for f64x2 {}

View file

@ -1229,7 +1229,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunks<'a, T> {
/// index of the matching element. `NotFound` means the search
/// succeeded, and the contained value is an index where a matching
/// value could be inserted while maintaining sort order.
#[deriving(PartialEq, Show)]
#[deriving(Copy, PartialEq, Show)]
#[experimental = "needs review"]
pub enum BinarySearchResult {
/// The index of the found value.
@ -1238,8 +1238,6 @@ pub enum BinarySearchResult {
NotFound(uint)
}
impl Copy for BinarySearchResult {}
#[experimental = "needs review"]
impl BinarySearchResult {
/// Converts a `Found` to `Some`, `NotFound` to `None`.

View file

@ -27,7 +27,7 @@ use default::Default;
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
use iter::{DoubleEndedIteratorExt, ExactSizeIterator};
use iter::range;
use kinds::{Copy, Sized};
use kinds::Sized;
use mem;
use num::Int;
use option::Option;
@ -165,13 +165,11 @@ Section: Iterators
/// Iterator for the char (representing *Unicode Scalar Values*) of a string
///
/// Created with the method `.chars()`.
#[deriving(Clone)]
#[deriving(Clone, Copy)]
pub struct Chars<'a> {
iter: slice::Items<'a, u8>
}
impl<'a> Copy for Chars<'a> {}
// Return the initial codepoint accumulator for the first byte.
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
// for width 3, and 3 bits for width 4
@ -998,7 +996,7 @@ pub struct Utf16Items<'a> {
iter: slice::Items<'a, u16>
}
/// The possibilities for values decoded from a `u16` stream.
#[deriving(PartialEq, Eq, Clone, Show)]
#[deriving(Copy, PartialEq, Eq, Clone, Show)]
pub enum Utf16Item {
/// A valid codepoint.
ScalarValue(char),
@ -1006,8 +1004,6 @@ pub enum Utf16Item {
LoneSurrogate(u16)
}
impl Copy for Utf16Item {}
impl Utf16Item {
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
/// replacement character (U+FFFD).
@ -1144,6 +1140,7 @@ pub fn utf8_char_width(b: u8) -> uint {
/// Struct that contains a `char` and the index of the first byte of
/// the next `char` in a string. This can be used as a data structure
/// for iterating over the UTF-8 bytes of a string.
#[deriving(Copy)]
pub struct CharRange {
/// Current `char`
pub ch: char,
@ -1151,8 +1148,6 @@ pub struct CharRange {
pub next: uint,
}
impl Copy for CharRange {}
/// Mask of the value bits of a continuation byte
const CONT_MASK: u8 = 0b0011_1111u8;
/// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte