diff options
| author | bors <bors@rust-lang.org> | 2013-12-11 12:56:22 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-11 12:56:22 -0800 |
| commit | 1b12dca7f97a51c6cbb4f47ea6e095d841a97c1a (patch) | |
| tree | 19f1a66a4ced0e180c4fa1720ecfe53b14e92465 /src/libstd | |
| parent | 47d10c745ebcc31768e98083c8c6d5396f4edcdb (diff) | |
| parent | 5731ca3078318a66a13208133d8839a9f9f92629 (diff) | |
| download | rust-1b12dca7f97a51c6cbb4f47ea6e095d841a97c1a.tar.gz rust-1b12dca7f97a51c6cbb4f47ea6e095d841a97c1a.zip | |
auto merge of #10897 : boredomist/rust/remove-self-lifetime, r=brson
Also remove all instances of 'self within the codebase. This fixes #10889. To make reviewing easier the following files were modified with more than a dumb text replacement: - `src/test/compile-fail/lifetime-no-keyword.rs` - `src/test/compile-fail/lifetime-obsoleted-self.rs` - `src/test/compile-fail/regions-free-region-ordering-incorrect.rs` - `src/libsyntax/parse/lexer.rs`
Diffstat (limited to 'src/libstd')
37 files changed, 555 insertions, 555 deletions
diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 4133bb1835d..8bce687e245 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -65,16 +65,16 @@ impl<T: 'static> Any for T { /////////////////////////////////////////////////////////////////////////////// /// Extension methods for a referenced `Any` trait object -pub trait AnyRefExt<'self> { +pub trait AnyRefExt<'a> { /// Returns true if the boxed type is the same as `T` fn is<T: 'static>(self) -> bool; /// Returns some reference to the boxed value if it is of type `T`, or /// `None` if it isn't. - fn as_ref<T: 'static>(self) -> Option<&'self T>; + fn as_ref<T: 'static>(self) -> Option<&'a T>; } -impl<'self> AnyRefExt<'self> for &'self Any { +impl<'a> AnyRefExt<'a> for &'a Any { #[inline] fn is<T: 'static>(self) -> bool { // Get TypeId of the type this function is instantiated with @@ -88,7 +88,7 @@ impl<'self> AnyRefExt<'self> for &'self Any { } #[inline] - fn as_ref<T: 'static>(self) -> Option<&'self T> { + fn as_ref<T: 'static>(self) -> Option<&'a T> { if self.is::<T>() { Some(unsafe { transmute(self.as_void_ptr()) }) } else { @@ -98,15 +98,15 @@ impl<'self> AnyRefExt<'self> for &'self Any { } /// Extension methods for a mutable referenced `Any` trait object -pub trait AnyMutRefExt<'self> { +pub trait AnyMutRefExt<'a> { /// Returns some mutable reference to the boxed value if it is of type `T`, or /// `None` if it isn't. - fn as_mut<T: 'static>(self) -> Option<&'self mut T>; + fn as_mut<T: 'static>(self) -> Option<&'a mut T>; } -impl<'self> AnyMutRefExt<'self> for &'self mut Any { +impl<'a> AnyMutRefExt<'a> for &'a mut Any { #[inline] - fn as_mut<T: 'static>(self) -> Option<&'self mut T> { + fn as_mut<T: 'static>(self) -> Option<&'a mut T> { if self.is::<T>() { Some(unsafe { transmute(self.as_mut_void_ptr()) }) } else { @@ -149,7 +149,7 @@ impl ToStr for ~Any { fn to_str(&self) -> ~str { ~"~Any" } } -impl<'self> ToStr for &'self Any { +impl<'a> ToStr for &'a Any { fn to_str(&self) -> ~str { ~"&Any" } } diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index c43b4e9b6ea..2242ded94f5 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -145,15 +145,15 @@ pub trait AsciiCast<T> { fn is_ascii(&self) -> bool; } -impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] { +impl<'a> AsciiCast<&'a[Ascii]> for &'a [u8] { #[inline] - fn to_ascii(&self) -> &'self[Ascii] { + fn to_ascii(&self) -> &'a[Ascii] { assert!(self.is_ascii()); unsafe {self.to_ascii_nocheck()} } #[inline] - unsafe fn to_ascii_nocheck(&self) -> &'self[Ascii] { + unsafe fn to_ascii_nocheck(&self) -> &'a[Ascii] { cast::transmute(*self) } @@ -166,15 +166,15 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] { } } -impl<'self> AsciiCast<&'self [Ascii]> for &'self str { +impl<'a> AsciiCast<&'a [Ascii]> for &'a str { #[inline] - fn to_ascii(&self) -> &'self [Ascii] { + fn to_ascii(&self) -> &'a [Ascii] { assert!(self.is_ascii()); unsafe { self.to_ascii_nocheck() } } #[inline] - unsafe fn to_ascii_nocheck(&self) -> &'self [Ascii] { + unsafe fn to_ascii_nocheck(&self) -> &'a [Ascii] { cast::transmute(*self) } @@ -272,7 +272,7 @@ pub trait AsciiStr { fn eq_ignore_case(self, other: &[Ascii]) -> bool; } -impl<'self> AsciiStr for &'self [Ascii] { +impl<'a> AsciiStr for &'a [Ascii] { #[inline] fn as_str_ascii<'a>(&'a self) -> &'a str { unsafe { cast::transmute(*self) } @@ -351,7 +351,7 @@ pub trait StrAsciiExt { fn eq_ignore_ascii_case(&self, other: &str) -> bool; } -impl<'self> StrAsciiExt for &'self str { +impl<'a> StrAsciiExt for &'a str { #[inline] fn to_ascii_upper(&self) -> ~str { unsafe { str_copy_map_bytes(*self, ASCII_UPPER_MAP) } diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 2b64c5c83fb..352d1abfb4b 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -153,7 +153,7 @@ pub mod traits { use ops::Add; use vec::Vector; - impl<'self,T:Clone, V: Vector<T>> Add<V,@[T]> for @[T] { + impl<'a,T:Clone, V: Vector<T>> Add<V,@[T]> for @[T] { #[inline] fn add(&self, rhs: &V) -> @[T] { append(*self, rhs.as_slice()) diff --git a/src/libstd/borrow.rs b/src/libstd/borrow.rs index 0626b3fc618..e8eda39537c 100644 --- a/src/libstd/borrow.rs +++ b/src/libstd/borrow.rs @@ -27,48 +27,48 @@ pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool { // Equality for region pointers #[cfg(not(test))] -impl<'self, T: Eq> Eq for &'self T { +impl<'a, T: Eq> Eq for &'a T { #[inline] - fn eq(&self, other: & &'self T) -> bool { + fn eq(&self, other: & &'a T) -> bool { *(*self) == *(*other) } #[inline] - fn ne(&self, other: & &'self T) -> bool { + fn ne(&self, other: & &'a T) -> bool { *(*self) != *(*other) } } // Comparison for region pointers #[cfg(not(test))] -impl<'self, T: Ord> Ord for &'self T { +impl<'a, T: Ord> Ord for &'a T { #[inline] - fn lt(&self, other: & &'self T) -> bool { + fn lt(&self, other: & &'a T) -> bool { *(*self) < *(*other) } #[inline] - fn le(&self, other: & &'self T) -> bool { + fn le(&self, other: & &'a T) -> bool { *(*self) <= *(*other) } #[inline] - fn ge(&self, other: & &'self T) -> bool { + fn ge(&self, other: & &'a T) -> bool { *(*self) >= *(*other) } #[inline] - fn gt(&self, other: & &'self T) -> bool { + fn gt(&self, other: & &'a T) -> bool { *(*self) > *(*other) } } #[cfg(not(test))] -impl<'self, T: TotalOrd> TotalOrd for &'self T { +impl<'a, T: TotalOrd> TotalOrd for &'a T { #[inline] - fn cmp(&self, other: & &'self T) -> Ordering { (**self).cmp(*other) } + fn cmp(&self, other: & &'a T) -> Ordering { (**self).cmp(*other) } } #[cfg(not(test))] -impl<'self, T: TotalEq> TotalEq for &'self T { +impl<'a, T: TotalEq> TotalEq for &'a T { #[inline] - fn equals(&self, other: & &'self T) -> bool { (**self).equals(*other) } + fn equals(&self, other: & &'a T) -> bool { (**self).equals(*other) } } #[cfg(test)] diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 11845c766ed..1563b7f99d1 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -234,7 +234,7 @@ pub trait ToCStr { } } -impl<'self> ToCStr for &'self str { +impl<'a> ToCStr for &'a str { #[inline] fn to_c_str(&self) -> CString { self.as_bytes().to_c_str() @@ -259,7 +259,7 @@ impl<'self> ToCStr for &'self str { // The length of the stack allocated buffer for `vec.with_c_str()` static BUF_LEN: uint = 128; -impl<'self> ToCStr for &'self [u8] { +impl<'a> ToCStr for &'a [u8] { fn to_c_str(&self) -> CString { let mut cs = unsafe { self.to_c_str_unchecked() }; cs.with_mut_ref(|buf| check_for_null(*self, buf)); @@ -328,12 +328,12 @@ fn check_for_null(v: &[u8], buf: *mut libc::c_char) { /// External iterator for a CString's bytes. /// /// Use with the `std::iter` module. -pub struct CStringIterator<'self> { +pub struct CStringIterator<'a> { priv ptr: *libc::c_char, - priv lifetime: &'self libc::c_char, // FIXME: #5922 + priv lifetime: &'a libc::c_char, // FIXME: #5922 } -impl<'self> Iterator<libc::c_char> for CStringIterator<'self> { +impl<'a> Iterator<libc::c_char> for CStringIterator<'a> { fn next(&mut self) -> Option<libc::c_char> { let ch = unsafe { *self.ptr }; if ch == 0 { diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index 7c972ed86b4..7b01a5c1b81 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -15,7 +15,7 @@ use ptr; use unstable::intrinsics::TyDesc; use unstable::raw; -type DropGlue<'self> = 'self |**TyDesc, *c_void|; +type DropGlue<'a> = 'a |**TyDesc, *c_void|; /* * Box annihilation diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 584963c36ca..95d75138082 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -64,22 +64,22 @@ impl<T> Clone for @mut T { fn clone(&self) -> @mut T { *self } } -impl<'self, T> Clone for &'self T { +impl<'a, T> Clone for &'a T { /// Return a shallow copy of the borrowed pointer. #[inline] - fn clone(&self) -> &'self T { *self } + fn clone(&self) -> &'a T { *self } } -impl<'self, T> Clone for &'self [T] { +impl<'a, T> Clone for &'a [T] { /// Return a shallow copy of the slice. #[inline] - fn clone(&self) -> &'self [T] { *self } + fn clone(&self) -> &'a [T] { *self } } -impl<'self> Clone for &'self str { +impl<'a> Clone for &'a str { /// Return a shallow copy of the slice. #[inline] - fn clone(&self) -> &'self str { *self } + fn clone(&self) -> &'a str { *self } } macro_rules! clone_impl( diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index c5d6ce2f3df..df5154123f2 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -162,12 +162,12 @@ impl<T, U> Condition<T, U> { /// /// Normally this object is not dealt with directly, but rather it's directly /// used after being returned from `trap` -pub struct Trap<'self, T, U> { - priv cond: &'self Condition<T, U>, +pub struct Trap<'a, T, U> { + priv cond: &'a Condition<T, U>, priv handler: @Handler<T, U> } -impl<'self, T, U> Trap<'self, T, U> { +impl<'a, T, U> Trap<'a, T, U> { /// Execute a block of code with this trap handler's exception handler /// registered. /// @@ -181,7 +181,7 @@ impl<'self, T, U> Trap<'self, T, U> { /// }); /// assert_eq!(result, 7); /// ``` - pub fn inside<V>(&self, inner: 'self || -> V) -> V { + pub fn inside<V>(&self, inner: 'a || -> V) -> V { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); local_data::set(self.cond.key, self.handler); @@ -191,7 +191,7 @@ impl<'self, T, U> Trap<'self, T, U> { /// Returns a guard that will automatically reset the condition upon /// exit of the scope. This is useful if you want to use conditions with /// an RAII pattern. - pub fn guard(&self) -> Guard<'self,T,U> { + pub fn guard(&self) -> Guard<'a,T,U> { let guard = Guard { cond: self.cond }; @@ -204,12 +204,12 @@ impl<'self, T, U> Trap<'self, T, U> { /// A guard that will automatically reset the condition handler upon exit of /// the scope. This is useful if you want to use conditions with an RAII /// pattern. -pub struct Guard<'self, T, U> { - priv cond: &'self Condition<T, U> +pub struct Guard<'a, T, U> { + priv cond: &'a Condition<T, U> } #[unsafe_destructor] -impl<'self, T, U> Drop for Guard<'self, T, U> { +impl<'a, T, U> Drop for Guard<'a, T, U> { fn drop(&mut self) { debug!("Guard: popping handler from TLS"); let curr = local_data::pop(self.cond.key); diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 463540b3677..a98a110ac3b 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -476,7 +476,7 @@ pub mod rt; /// A struct to represent both where to emit formatting strings to and how they /// should be formatted. A mutable version of this is passed to all formatting /// traits. -pub struct Formatter<'self> { +pub struct Formatter<'a> { /// Flags for formatting (packed version of rt::Flag) flags: uint, /// Character used as 'fill' whenever there is alignment @@ -489,21 +489,21 @@ pub struct Formatter<'self> { precision: Option<uint>, /// Output buffer. - buf: &'self mut io::Writer, - priv curarg: vec::VecIterator<'self, Argument<'self>>, - priv args: &'self [Argument<'self>], + buf: &'a mut io::Writer, + priv curarg: vec::VecIterator<'a, Argument<'a>>, + priv args: &'a [Argument<'a>], } /// This struct represents the generic "argument" which is taken by the Xprintf /// family of functions. It contains a function to format the given value. At /// 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. -pub struct Argument<'self> { +pub struct Argument<'a> { priv formatter: extern "Rust" fn(&util::Void, &mut Formatter), - priv value: &'self util::Void, + priv value: &'a util::Void, } -impl<'self> Arguments<'self> { +impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments structure. The compiler inserts an `unsafe` block to call this, /// which is valid because the compiler performs all necessary validation to @@ -524,9 +524,9 @@ impl<'self> Arguments<'self> { /// and pass it to a user-supplied function. The macro validates the format /// string at compile-time so usage of the `write` and `format` functions can /// be safely performed. -pub struct Arguments<'self> { - priv fmt: &'self [rt::Piece<'self>], - priv args: &'self [Argument<'self>], +pub struct Arguments<'a> { + priv fmt: &'a [rt::Piece<'a>], + priv args: &'a [Argument<'a>], } /// When a format is not otherwise specified, types are formatted by ascribing @@ -684,7 +684,7 @@ pub unsafe fn format_unsafe(fmt: &[rt::Piece], args: &[Argument]) -> ~str { return str::from_utf8_owned(output.inner()); } -impl<'self> Formatter<'self> { +impl<'a> Formatter<'a> { // First up is the collection of functions used to execute a format string // at runtime. This consumes all of the compile-time statics generated by @@ -988,7 +988,7 @@ impl Bool for bool { } } -impl<'self, T: str::Str> String for T { +impl<'a, T: str::Str> String for T { fn fmt(s: &T, f: &mut Formatter) { f.pad(s.as_slice()); } @@ -1111,7 +1111,7 @@ impl<T> Pointer for *mut T { // Implementation of Default for various core types macro_rules! delegate(($ty:ty to $other:ident) => { - impl<'self> Default for $ty { + impl<'a> Default for $ty { fn fmt(me: &$ty, f: &mut Formatter) { $other::fmt(me, f) } @@ -1129,7 +1129,7 @@ delegate!( u32 to Unsigned) delegate!( u64 to Unsigned) delegate!(@str to String) delegate!(~str to String) -delegate!(&'self str to String) +delegate!(&'a str to String) delegate!(bool to Bool) delegate!(char to Char) delegate!(f32 to Float) diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 6489ff79205..e9f7af181a7 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -24,31 +24,31 @@ condition! { pub parse_error: ~str -> (); } /// A piece is a portion of the format string which represents the next part to /// emit. These are emitted as a stream by the `Parser` class. #[deriving(Eq)] -pub enum Piece<'self> { +pub enum Piece<'a> { /// A literal string which should directly be emitted - String(&'self str), + String(&'a str), /// A back-reference to whatever the current argument is. This is used /// inside of a method call to refer back to the original argument. CurrentArgument, /// This describes that formatting should process the next argument (as /// specified inside) for emission. - Argument(Argument<'self>), + Argument(Argument<'a>), } /// Representation of an argument specification. #[deriving(Eq)] -pub struct Argument<'self> { +pub struct Argument<'a> { /// Where to find this argument - position: Position<'self>, + position: Position<'a>, /// How to format the argument - format: FormatSpec<'self>, + format: FormatSpec<'a>, /// If not `None`, what method to invoke on the argument - method: Option<~Method<'self>> + method: Option<~Method<'a>> } /// Specification for the formatting of an argument in the format string. #[deriving(Eq)] -pub struct FormatSpec<'self> { +pub struct FormatSpec<'a> { /// Optionally specified character to fill alignment with fill: Option<char>, /// Optionally specified alignment @@ -56,20 +56,20 @@ pub struct FormatSpec<'self> { /// Packed version of various flags provided flags: uint, /// The integer precision to use - precision: Count<'self>, + precision: Count<'a>, /// The string width requested for the resulting format - width: Count<'self>, + width: Count<'a>, /// The descriptor string representing the name of the format desired for /// this argument, this can be empty or any number of characters, although /// it is required to be one word. - ty: &'self str + ty: &'a str } /// Enum describing where an argument for a format can be located. #[deriving(Eq)] #[allow(missing_doc)] -pub enum Position<'self> { - ArgumentNext, ArgumentIs(uint), ArgumentNamed(&'self str) +pub enum Position<'a> { + ArgumentNext, ArgumentIs(uint), ArgumentNamed(&'a str) } /// Enum of alignments which are supported. @@ -92,9 +92,9 @@ pub enum Flag { /// can reference either an argument or a literal integer. #[deriving(Eq)] #[allow(missing_doc)] -pub enum Count<'self> { +pub enum Count<'a> { CountIs(uint), - CountIsName(&'self str), + CountIsName(&'a str), CountIsParam(uint), CountIsNextParam, CountImplied, @@ -103,7 +103,7 @@ pub enum Count<'self> { /// Enum describing all of the possible methods which the formatting language /// currently supports. #[deriving(Eq)] -pub enum Method<'self> { +pub enum Method<'a> { /// A plural method selects on an integer over a list of either integer or /// keyword-defined clauses. The meaning of the keywords is defined by the /// current locale. @@ -113,23 +113,23 @@ pub enum Method<'self> { /// /// The final element of this enum is the default "other" case which is /// always required to be specified. - Plural(Option<uint>, ~[PluralArm<'self>], ~[Piece<'self>]), + Plural(Option<uint>, ~[PluralArm<'a>], ~[Piece<'a>]), /// A select method selects over a string. Each arm is a different string /// which can be selected for. /// /// As with `Plural`, a default "other" case is required as well. - Select(~[SelectArm<'self>], ~[Piece<'self>]), + Select(~[SelectArm<'a>], ~[Piece<'a>]), } /// Structure representing one "arm" of the `plural` function. #[deriving(Eq)] -pub struct PluralArm<'self> { +pub struct PluralArm<'a> { /// A selector can either be specified by a keyword or with an integer /// literal. selector: Either<PluralKeyword, uint>, /// Array of pieces which are the format of this arm - result: ~[Piece<'self>], + result: ~[Piece<'a>], } /// Enum of the 5 CLDR plural keywords. There is one more, "other", but that is @@ -144,11 +144,11 @@ pub enum PluralKeyword { /// Structure representing one "arm" of the `select` function. #[deriving(Eq)] -pub struct SelectArm<'self> { +pub struct SelectArm<'a> { /// String selector which guards this arm - selector: &'self str, + selector: &'a str, /// Array of pieces which are the format of this arm - result: ~[Piece<'self>], + result: ~[Piece<'a>], } /// The parser structure for interpreting the input format string. This is @@ -157,14 +157,14 @@ pub struct SelectArm<'self> { /// /// This is a recursive-descent parser for the sake of simplicity, and if /// necessary there's probably lots of room for improvement performance-wise. -pub struct Parser<'self> { - priv input: &'self str, - priv cur: str::CharOffsetIterator<'self>, +pub struct Parser<'a> { + priv input: &'a str, + priv cur: str::CharOffsetIterator<'a>, priv depth: uint, } -impl<'self> Iterator<Piece<'self>> for Parser<'self> { - fn next(&mut self) -> Option<Piece<'self>> { +impl<'a> Iterator<Piece<'a>> for Parser<'a> { + fn next(&mut self) -> Option<Piece<'a>> { match self.cur.clone().next() { Some((_, '#')) => { self.cur.next(); Some(CurrentArgument) } Some((_, '{')) => { @@ -191,7 +191,7 @@ impl<'self> Iterator<Piece<'self>> for Parser<'self> { } } -impl<'self> Parser<'self> { +impl<'a> Parser<'a> { /// Creates a new parser for the given format string pub fn new<'a>(s: &'a str) -> Parser<'a> { Parser { @@ -276,7 +276,7 @@ impl<'self> Parser<'self> { /// Parses all of a string which is to be considered a "raw literal" in a /// format string. This is everything outside of the braces. - fn string(&mut self, start: uint) -> &'self str { + fn string(&mut self, start: uint) -> &'a str { loop { // we may not consume the character, so clone the iterator match self.cur.clone().next() { @@ -295,7 +295,7 @@ impl<'self> Parser<'self> { /// Parses an Argument structure, or what's contained within braces inside /// the format string - fn argument(&mut self) -> Argument<'self> { + fn argument(&mut self) -> Argument<'a> { Argument { position: self.position(), format: self.format(), @@ -305,7 +305,7 @@ impl<'self> Parser<'self> { /// Parses a positional argument for a format. This could either be an /// integer index of an argument, a named argument, or a blank string. - fn position(&mut self) -> Position<'self> { + fn position(&mut self) -> Position<'a> { match self.integer() { Some(i) => { ArgumentIs(i) } None => { @@ -321,7 +321,7 @@ impl<'self> Parser<'self> { /// Parses a format specifier at the current position, returning all of the /// relevant information in the FormatSpec struct. - fn format(&mut self) -> FormatSpec<'self> { + fn format(&mut self) -> FormatSpec<'a> { let mut spec = FormatSpec { fill: None, align: AlignUnknown, @@ -396,7 +396,7 @@ impl<'self> Parser<'self> { /// Parses a method to be applied to the previously specified argument and /// its format. The two current supported methods are 'plural' and 'select' - fn method(&mut self) -> Option<~Method<'self>> { + fn method(&mut self) -> Option<~Method<'a>> { if !self.wsconsume(',') { return None; } @@ -422,7 +422,7 @@ impl<'self> Parser<'self> { } /// Parses a 'select' statement (after the initial 'select' word) - fn select(&mut self) -> ~Method<'self> { + fn select(&mut self) -> ~Method<'a> { let mut other = None; let mut arms = ~[]; // Consume arms one at a time @@ -464,7 +464,7 @@ impl<'self> Parser<'self> { } /// Parses a 'plural' statement (after the initial 'plural' word) - fn plural(&mut self) -> ~Method<'self> { + fn plural(&mut self) -> ~Method<'a> { let mut offset = None; let mut other = None; let mut arms = ~[]; @@ -564,7 +564,7 @@ impl<'self> Parser<'self> { /// Parses a Count parameter at the current position. This does not check /// for 'CountIsNextParam' because that is only used in precision, not /// width. - fn count(&mut self) -> Count<'self> { + fn count(&mut self) -> Count<'a> { match self.integer() { Some(i) => { if self.consume('$') { @@ -591,7 +591,7 @@ impl<'self> Parser<'self> { /// Parses a word starting at the current position. A word is considered to /// be an alphabetic character followed by any number of alphanumeric /// characters. - fn word(&mut self) -> &'self str { + fn word(&mut self) -> &'a str { let start = match self.cur.clone().next() { Some((pos, c)) if char::is_XID_start(c) => { self.cur.next(); diff --git a/src/libstd/fmt/rt.rs b/src/libstd/fmt/rt.rs index b20af1a35b8..c139a2f5734 100644 --- a/src/libstd/fmt/rt.rs +++ b/src/libstd/fmt/rt.rs @@ -21,17 +21,17 @@ use either::Either; use fmt::parse; use option::Option; -pub enum Piece<'self> { - String(&'self str), +pub enum Piece<'a> { + String(&'a str), // FIXME(#8259): this shouldn't require the unit-value here CurrentArgument(()), - Argument(Argument<'self>), + Argument(Argument<'a>), } -pub struct Argument<'self> { +pub struct Argument<'a> { position: Position, format: FormatSpec, - method: Option<&'self Method<'self>> + method: Option<&'a Method<'a>> } pub struct FormatSpec { @@ -50,17 +50,17 @@ pub enum Position { ArgumentNext, ArgumentIs(uint) } -pub enum Method<'self> { - Plural(Option<uint>, &'self [PluralArm<'self>], &'self [Piece<'self>]), - Select(&'self [SelectArm<'self>], &'self [Piece<'self>]), +pub enum Method<'a> { + Plural(Option<uint>, &'a [PluralArm<'a>], &'a [Piece<'a>]), + Select(&'a [SelectArm<'a>], &'a [Piece<'a>]), } -pub struct PluralArm<'self> { +pub struct PluralArm<'a> { selector: Either<parse::PluralKeyword, uint>, - result: &'self [Piece<'self>], + result: &'a [Piece<'a>], } -pub struct SelectArm<'self> { - selector: &'self str, - result: &'self [Piece<'self>], +pub struct SelectArm<'a> { + selector: &'a str, + result: &'a [Piece<'a>], } diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index fd439eb05e2..a135d66141a 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -305,8 +305,8 @@ mod tests { use prelude::*; // Hash just the bytes of the slice, without length prefix - struct Bytes<'self>(&'self [u8]); - impl<'self> IterBytes for Bytes<'self> { + struct Bytes<'a>(&'a [u8]); + impl<'a> IterBytes for Bytes<'a> { fn iter_bytes(&self, _lsb0: bool, f: |&[u8]| -> bool) -> bool { f(**self) } diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index e7eb8e60704..335e77c6478 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -521,13 +521,13 @@ impl<K:Hash + Eq + Clone,V:Clone> Clone for HashMap<K,V> { /// HashMap iterator #[deriving(Clone)] -pub struct HashMapIterator<'self, K, V> { - priv iter: vec::VecIterator<'self, Option<Bucket<K, V>>>, +pub struct HashMapIterator<'a, K, V> { + priv iter: vec::VecIterator<'a, Option<Bucket<K, V>>>, } /// HashMap mutable values iterator -pub struct HashMapMutIterator<'self, K, V> { - priv iter: vec::VecMutIterator<'self, Option<Bucket<K, V>>>, +pub struct HashMapMutIterator<'a, K, V> { + priv iter: vec::VecMutIterator<'a, Option<Bucket<K, V>>>, } /// HashMap move iterator @@ -537,8 +537,8 @@ pub struct HashMapMoveIterator<K, V> { /// HashSet iterator #[deriving(Clone)] -pub struct HashSetIterator<'self, K> { - priv iter: vec::VecIterator<'self, Option<Bucket<K, ()>>>, +pub struct HashSetIterator<'a, K> { + priv iter: vec::VecIterator<'a, Option<Bucket<K, ()>>>, } /// HashSet move iterator @@ -546,9 +546,9 @@ pub struct HashSetMoveIterator<K> { priv iter: vec::MoveRevIterator<Option<Bucket<K, ()>>>, } -impl<'self, K, V> Iterator<(&'self K, &'self V)> for HashMapIterator<'self, K, V> { +impl<'a, K, V> Iterator<(&'a K, &'a V)> for HashMapIterator<'a, K, V> { #[inline] - fn next(&mut self) -> Option<(&'self K, &'self V)> { + fn next(&mut self) -> Option<(&'a K, &'a V)> { for elt in self.iter { match elt { &Some(ref bucket) => return Some((&bucket.key, &bucket.value)), @@ -559,9 +559,9 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for HashMapIterator<'self, K, V } } -impl<'self, K, V> Iterator<(&'self K, &'self mut V)> for HashMapMutIterator<'self, K, V> { +impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for HashMapMutIterator<'a, K, V> { #[inline] - fn next(&mut self) -> Option<(&'self K, &'self mut V)> { + fn next(&mut self) -> Option<(&'a K, &'a mut V)> { for elt in self.iter { match elt { &Some(ref mut bucket) => return Some((&bucket.key, &mut bucket.value)), @@ -585,9 +585,9 @@ impl<K, V> Iterator<(K, V)> for HashMapMoveIterator<K, V> { } } -impl<'self, K> Iterator<&'self K> for HashSetIterator<'self, K> { +impl<'a, K> Iterator<&'a K> for HashSetIterator<'a, K> { #[inline] - fn next(&mut self) -> Option<&'self K> { + fn next(&mut self) -> Option<&'a K> { for elt in self.iter { match elt { &Some(ref bucket) => return Some(&bucket.key), @@ -798,9 +798,9 @@ impl<K: Eq + Hash> Default for HashSet<K> { // `Repeat` is used to feed the filter closure an explicit capture // of a reference to the other set /// Set operations iterator -pub type SetAlgebraIter<'self, T> = - FilterMap<'static,(&'self HashSet<T>, &'self T), &'self T, - Zip<Repeat<&'self HashSet<T>>,HashSetIterator<'self,T>>>; +pub type SetAlgebraIter<'a, T> = + FilterMap<'static,(&'a HashSet<T>, &'a T), &'a T, + Zip<Repeat<&'a HashSet<T>>,HashSetIterator<'a,T>>>; #[cfg(test)] diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index aa3eb9a8317..b6778d89c33 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -148,12 +148,12 @@ impl Decorator<~[u8]> for MemReader { /// /// If a write will not fit in the buffer, it raises the `io_error` /// condition and does not write any data. -pub struct BufWriter<'self> { - priv buf: &'self mut [u8], +pub struct BufWriter<'a> { + priv buf: &'a mut [u8], priv pos: uint } -impl<'self> BufWriter<'self> { +impl<'a> BufWriter<'a> { pub fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> { BufWriter { buf: buf, @@ -162,7 +162,7 @@ impl<'self> BufWriter<'self> { } } -impl<'self> Writer for BufWriter<'self> { +impl<'a> Writer for BufWriter<'a> { fn write(&mut self, buf: &[u8]) { // raises a condition if the entire write does not fit in the buffer let max_size = self.buf.len(); @@ -182,7 +182,7 @@ impl<'self> Writer for BufWriter<'self> { } // FIXME(#10432) -impl<'self> Seek for BufWriter<'self> { +impl<'a> Seek for BufWriter<'a> { fn tell(&self) -> u64 { self.pos as u64 } fn seek(&mut self, pos: i64, style: SeekStyle) { @@ -199,12 +199,12 @@ impl<'self> Seek for BufWriter<'self> { /// Reads from a fixed-size byte slice -pub struct BufReader<'self> { - priv buf: &'self [u8], +pub struct BufReader<'a> { + priv buf: &'a [u8], priv pos: uint } -impl<'self> BufReader<'self> { +impl<'a> BufReader<'a> { pub fn new<'a>(buf: &'a [u8]) -> BufReader<'a> { BufReader { buf: buf, @@ -213,7 +213,7 @@ impl<'self> BufReader<'self> { } } -impl<'self> Reader for BufReader<'self> { +impl<'a> Reader for BufReader<'a> { fn read(&mut self, buf: &mut [u8]) -> Option<uint> { { if self.eof() { return None; } } @@ -233,13 +233,13 @@ impl<'self> Reader for BufReader<'self> { fn eof(&mut self) -> bool { self.pos == self.buf.len() } } -impl<'self> Seek for BufReader<'self> { +impl<'a> Seek for BufReader<'a> { fn tell(&self) -> u64 { self.pos as u64 } fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() } } -impl<'self> Buffer for BufReader<'self> { +impl<'a> Buffer for BufReader<'a> { fn fill<'a>(&'a mut self) -> &'a [u8] { self.buf.slice_from(self.pos) } fn consume(&mut self, amt: uint) { self.pos += amt; } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 77bdf866338..393262aa1dd 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -811,7 +811,7 @@ impl Reader for ~Reader { fn eof(&mut self) -> bool { self.eof() } } -impl<'self> Reader for &'self mut Reader { +impl<'a> Reader for &'a mut Reader { fn read(&mut self, buf: &mut [u8]) -> Option<uint> { self.read(buf) } fn eof(&mut self) -> bool { self.eof() } } @@ -972,7 +972,7 @@ impl Writer for ~Writer { fn flush(&mut self) { self.flush() } } -impl<'self> Writer for &'self mut Writer { +impl<'a> Writer for &'a mut Writer { fn write(&mut self, buf: &[u8]) { self.write(buf) } fn flush(&mut self) { self.flush() } } @@ -1184,11 +1184,11 @@ pub trait Acceptor<T> { /// The Some contains another Option representing whether the connection attempt was succesful. /// A successful connection will be wrapped in Some. /// A failed connection is represented as a None and raises a condition. -struct IncomingIterator<'self, A> { - priv inc: &'self mut A, +struct IncomingIterator<'a, A> { + priv inc: &'a mut A, } -impl<'self, T, A: Acceptor<T>> Iterator<Option<T>> for IncomingIterator<'self, A> { +impl<'a, T, A: Acceptor<T>> Iterator<Option<T>> for IncomingIterator<'a, A> { fn next(&mut self) -> Option<Option<T>> { Some(self.inc.accept()) } diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 6a97a21673d..b4d14b57efc 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -62,14 +62,14 @@ impl ToStr for SocketAddr { } } -struct Parser<'self> { +struct Parser<'a> { // parsing as ASCII, so can use byte array - s: &'self [u8], + s: &'a [u8], pos: uint, } -impl<'self> Parser<'self> { - fn new(s: &'self str) -> Parser<'self> { +impl<'a> Parser<'a> { + fn new(s: &'a str) -> Parser<'a> { Parser { s: s.as_bytes(), pos: 0, diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 1c86ac84bbb..001faa1ecaf 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -33,20 +33,20 @@ pub struct Process { /// This configuration describes how a new process should be spawned. This is /// translated to libuv's own configuration -pub struct ProcessConfig<'self> { +pub struct ProcessConfig<'a> { /// Path to the program to run - program: &'self str, + program: &'a str, /// Arguments to pass to the program (doesn't include the program itself) - args: &'self [~str], + args: &'a [~str], /// Optional environment to specify for the program. If this is None, then /// it will inherit the current process's environment. - env: Option<&'self [(~str, ~str)]>, + env: Option<&'a [(~str, ~str)]>, /// Optional working directory for the new process. If this is None, then /// the current directory of the running process is inherited. - cwd: Option<&'self str>, + cwd: Option<&'a str>, /// Any number of streams/file descriptors/pipes may be attached to this /// process. This list enumerates the file descriptors and such for the @@ -58,7 +58,7 @@ pub struct ProcessConfig<'self> { /// 0 - stdin /// 1 - stdout /// 2 - stderr - io: &'self [StdioContainer] + io: &'a [StdioContainer] } /// Describes what to do with a standard io stream for a child process. diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 8cebc49be7c..3a7f8ab8629 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -691,7 +691,7 @@ pub trait MutableDoubleEndedIterator { fn reverse_(&mut self); } -impl<'self, A, T: DoubleEndedIterator<&'self mut A>> MutableDoubleEndedIterator for T { +impl<'a, A, T: DoubleEndedIterator<&'a mut A>> MutableDoubleEndedIterator for T { // FIXME: #5898: should be called `reverse` /// Use an iterator to reverse a container in-place fn reverse_(&mut self) { @@ -754,9 +754,9 @@ pub trait ExactSize<A> : DoubleEndedIterator<A> { // All adaptors that preserve the size of the wrapped iterator are fine // Adaptors that may overflow in `size_hint` are not, i.e. `Chain`. impl<A, T: ExactSize<A>> ExactSize<(uint, A)> for Enumerate<T> {} -impl<'self, A, T: ExactSize<A>> ExactSize<A> for Inspect<'self, A, T> {} +impl<'a, A, T: ExactSize<A>> ExactSize<A> for Inspect<'a, A, T> {} impl<A, T: ExactSize<A>> ExactSize<A> for Invert<T> {} -impl<'self, A, B, T: ExactSize<A>> ExactSize<B> for Map<'self, A, B, T> {} +impl<'a, A, B, T: ExactSize<A>> ExactSize<B> for Map<'a, A, B, T> {} impl<A, B, T: ExactSize<A>, U: ExactSize<B>> ExactSize<(A, B)> for Zip<T, U> {} /// An double-ended iterator with the direction inverted @@ -788,17 +788,17 @@ impl<A, T: DoubleEndedIterator<A> + RandomAccessIterator<A>> RandomAccessIterato } /// A mutable reference to an iterator -pub struct ByRef<'self, T> { - priv iter: &'self mut T +pub struct ByRef<'a, T> { + priv iter: &'a mut T } -impl<'self, A, T: Iterator<A>> Iterator<A> for ByRef<'self, T> { +impl<'a, A, T: Iterator<A>> Iterator<A> for ByRef<'a, T> { #[inline] fn next(&mut self) -> Option<A> { self.iter.next() } // FIXME: #9629 we cannot implement &self methods like size_hint on ByRef } -impl<'self, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for ByRef<'self, T> { +impl<'a, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for ByRef<'a, T> { #[inline] fn next_back(&mut self) -> Option<A> { self.iter.next_back() } } @@ -1121,12 +1121,12 @@ RandomAccessIterator<(A, B)> for Zip<T, U> { } /// An iterator which maps the values of `iter` with `f` -pub struct Map<'self, A, B, T> { +pub struct Map<'a, A, B, T> { priv iter: T, - priv f: 'self |A| -> B + priv f: 'a |A| -> B } -impl<'self, A, B, T> Map<'self, A, B, T> { +impl<'a, A, B, T> Map<'a, A, B, T> { #[inline] fn do_map(&self, elt: Option<A>) -> Option<B> { match elt { @@ -1136,7 +1136,7 @@ impl<'self, A, B, T> Map<'self, A, B, T> { } } -impl<'self, A, B, T: Iterator<A>> Iterator<B> for Map<'self, A, B, T> { +impl<'a, A, B, T: Iterator<A>> Iterator<B> for Map<'a, A, B, T> { #[inline] fn next(&mut self) -> Option<B> { let next = self.iter.next(); @@ -1149,7 +1149,7 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for Map<'self, A, B, T> { } } -impl<'self, A, B, T: DoubleEndedIterator<A>> DoubleEndedIterator<B> for Map<'self, A, B, T> { +impl<'a, A, B, T: DoubleEndedIterator<A>> DoubleEndedIterator<B> for Map<'a, A, B, T> { #[inline] fn next_back(&mut self) -> Option<B> { let next = self.iter.next_back(); @@ -1157,7 +1157,7 @@ impl<'self, A, B, T: DoubleEndedIterator<A>> DoubleEndedIterator<B> for Map<'sel } } -impl<'self, A, B, T: RandomAccessIterator<A>> RandomAccessIterator<B> for Map<'self, A, B, T> { +impl<'a, A, B, T: RandomAccessIterator<A>> RandomAccessIterator<B> for Map<'a, A, B, T> { #[inline] fn indexable(&self) -> uint { self.iter.indexable() @@ -1170,12 +1170,12 @@ impl<'self, A, B, T: RandomAccessIterator<A>> RandomAccessIterator<B> for Map<'s } /// An iterator which filters the elements of `iter` with `predicate` -pub struct Filter<'self, A, T> { +pub struct Filter<'a, A, T> { priv iter: T, - priv predicate: 'self |&A| -> bool + priv predicate: 'a |&A| -> bool } -impl<'self, A, T: Iterator<A>> Iterator<A> for Filter<'self, A, T> { +impl<'a, A, T: Iterator<A>> Iterator<A> for Filter<'a, A, T> { #[inline] fn next(&mut self) -> Option<A> { for x in self.iter { @@ -1195,7 +1195,7 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for Filter<'self, A, T> { } } -impl<'self, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for Filter<'self, A, T> { +impl<'a, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for Filter<'a, A, T> { #[inline] fn next_back(&mut self) -> Option<A> { loop { @@ -1214,12 +1214,12 @@ impl<'self, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for Filter<'sel } /// An iterator which uses `f` to both filter and map elements from `iter` -pub struct FilterMap<'self, A, B, T> { +pub struct FilterMap<'a, A, B, T> { priv iter: T, - priv f: 'self |A| -> Option<B> + priv f: 'a |A| -> Option<B> } -impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'self, A, B, T> { +impl<'a, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'a, A, B, T> { #[inline] fn next(&mut self) -> Option<B> { for x in self.iter { @@ -1238,8 +1238,8 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMap<'self, A, B, T> { } } -impl<'self, A, B, T: DoubleEndedIterator<A>> DoubleEndedIterator<B> -for FilterMap<'self, A, B, T> { +impl<'a, A, B, T: DoubleEndedIterator<A>> DoubleEndedIterator<B> +for FilterMap<'a, A, B, T> { #[inline] fn next_back(&mut self) -> Option<B> { loop { @@ -1340,11 +1340,11 @@ impl<A, T: Iterator<A>> Iterator<A> for Peekable<A, T> { } } -impl<'self, A, T: Iterator<A>> Peekable<A, T> { +impl<'a, A, T: Iterator<A>> Peekable<A, T> { /// Return a reference to the next element of the iterator with out advancing it, /// or None if the iterator is exhausted. #[inline] - pub fn peek(&'self mut self) -> Option<&'self A> { + pub fn peek(&'a mut self) -> Option<&'a A> { if self.peeked.is_none() { self.peeked = self.iter.next(); } @@ -1356,13 +1356,13 @@ impl<'self, A, T: Iterator<A>> Peekable<A, T> { } /// An iterator which rejects elements while `predicate` is true -pub struct SkipWhile<'self, A, T> { +pub struct SkipWhile<'a, A, T> { priv iter: T, priv flag: bool, - priv predicate: 'self |&A| -> bool + priv predicate: 'a |&A| -> bool } -impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> { +impl<'a, A, T: Iterator<A>> Iterator<A> for SkipWhile<'a, A, T> { #[inline] fn next(&mut self) -> Option<A> { let mut next = self.iter.next(); @@ -1394,13 +1394,13 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhile<'self, A, T> { } /// An iterator which only accepts elements while `predicate` is true -pub struct TakeWhile<'self, A, T> { +pub struct TakeWhile<'a, A, T> { priv iter: T, priv flag: bool, - priv predicate: 'self |&A| -> bool + priv predicate: 'a |&A| -> bool } -impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhile<'self, A, T> { +impl<'a, A, T: Iterator<A>> Iterator<A> for TakeWhile<'a, A, T> { #[inline] fn next(&mut self) -> Option<A> { if self.flag { @@ -1542,15 +1542,15 @@ impl<A, T: RandomAccessIterator<A>> RandomAccessIterator<A> for Take<T> { /// An iterator to maintain state while iterating another iterator -pub struct Scan<'self, A, B, T, St> { +pub struct Scan<'a, A, B, T, St> { priv iter: T, - priv f: 'self |&mut St, A| -> Option<B>, + priv f: 'a |&mut St, A| -> Option<B>, /// The current internal state to be passed to the closure next. state: St } -impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for Scan<'self, A, B, T, St> { +impl<'a, A, B, T: Iterator<A>, St> Iterator<B> for Scan<'a, A, B, T, St> { #[inline] fn next(&mut self) -> Option<B> { self.iter.next().and_then(|a| (self.f)(&mut self.state, a)) @@ -1566,14 +1566,14 @@ impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for Scan<'self, A, B, T, St> { /// An iterator that maps each element to an iterator, /// and yields the elements of the produced iterators /// -pub struct FlatMap<'self, A, T, U> { +pub struct FlatMap<'a, A, T, U> { priv iter: T, - priv f: 'self |A| -> U, + priv f: 'a |A| -> U, priv frontiter: Option<U>, priv backiter: Option<U>, } -impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for FlatMap<'self, A, T, U> { +impl<'a, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for FlatMap<'a, A, T, U> { #[inline] fn next(&mut self) -> Option<B> { loop { @@ -1601,10 +1601,10 @@ impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for FlatMap<'self, } } -impl<'self, +impl<'a, A, T: DoubleEndedIterator<A>, B, U: DoubleEndedIterator<B>> DoubleEndedIterator<B> - for FlatMap<'self, A, T, U> { + for FlatMap<'a, A, T, U> { #[inline] fn next_back(&mut self) -> Option<B> { loop { @@ -1697,12 +1697,12 @@ impl<T> Fuse<T> { /// An iterator that calls a function with a reference to each /// element before yielding it. -pub struct Inspect<'self, A, T> { +pub struct Inspect<'a, A, T> { priv iter: T, - priv f: 'self |&A| + priv f: 'a |&A| } -impl<'self, A, T> Inspect<'self, A, T> { +impl<'a, A, T> Inspect<'a, A, T> { #[inline] fn do_inspect(&self, elt: Option<A>) -> Option<A> { match elt { @@ -1714,7 +1714,7 @@ impl<'self, A, T> Inspect<'self, A, T> { } } -impl<'self, A, T: Iterator<A>> Iterator<A> for Inspect<'self, A, T> { +impl<'a, A, T: Iterator<A>> Iterator<A> for Inspect<'a, A, T> { #[inline] fn next(&mut self) -> Option<A> { let next = self.iter.next(); @@ -1727,8 +1727,8 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for Inspect<'self, A, T> { } } -impl<'self, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> -for Inspect<'self, A, T> { +impl<'a, A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> +for Inspect<'a, A, T> { #[inline] fn next_back(&mut self) -> Option<A> { let next = self.iter.next_back(); @@ -1736,8 +1736,8 @@ for Inspect<'self, A, T> { } } -impl<'self, A, T: RandomAccessIterator<A>> RandomAccessIterator<A> -for Inspect<'self, A, T> { +impl<'a, A, T: RandomAccessIterator<A>> RandomAccessIterator<A> +for Inspect<'a, A, T> { #[inline] fn indexable(&self) -> uint { self.iter.indexable() @@ -1750,13 +1750,13 @@ for Inspect<'self, A, T> { } /// An iterator which just modifies the contained state throughout iteration. -pub struct Unfold<'self, A, St> { - priv f: 'self |&mut St| -> Option<A>, +pub struct Unfold<'a, A, St> { + priv f: 'a |&mut St| -> Option<A>, /// Internal state that will be yielded on the next iteration state: St } -impl<'self, A, St> Unfold<'self, A, St> { +impl<'a, A, St> Unfold<'a, A, St> { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the iterator #[inline] @@ -1769,7 +1769,7 @@ impl<'self, A, St> Unfold<'self, A, St> { } } -impl<'self, A, St> Iterator<A> for Unfold<'self, A, St> { +impl<'a, A, St> Iterator<A> for Unfold<'a, A, St> { #[inline] fn next(&mut self) -> Option<A> { (self.f)(&mut self.state) diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 303bb470991..53948dc8309 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -523,18 +523,18 @@ pub trait GenericPathUnsafe { } /// Helper struct for printing paths with format!() -pub struct Display<'self, P> { - priv path: &'self P, +pub struct Display<'a, P> { + priv path: &'a P, priv filename: bool } -impl<'self, P: GenericPath> fmt::Default for Display<'self, P> { +impl<'a, P: GenericPath> fmt::Default for Display<'a, P> { fn fmt(d: &Display<P>, f: &mut fmt::Formatter) { d.with_str(|s| f.pad(s)) } } -impl<'self, P: GenericPath> ToStr for Display<'self, P> { +impl<'a, P: GenericPath> ToStr for Display<'a, P> { /// Returns the path as a string /// /// If the path is not UTF-8, invalid sequences with be replaced with the @@ -551,7 +551,7 @@ impl<'self, P: GenericPath> ToStr for Display<'self, P> { } } -impl<'self, P: GenericPath> Display<'self, P> { +impl<'a, P: GenericPath> Display<'a, P> { /// Provides the path as a string to a closure /// /// If the path is not UTF-8, invalid sequences will be replaced with the @@ -570,7 +570,7 @@ impl<'self, P: GenericPath> Display<'self, P> { } } -impl<'self> BytesContainer for &'self str { +impl<'a> BytesContainer for &'a str { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { self.as_bytes() @@ -584,7 +584,7 @@ impl<'self> BytesContainer for &'self str { Some(*self) } #[inline] - fn is_str(_: Option<&'self str>) -> bool { true } + fn is_str(_: Option<&'a str>) -> bool { true } } impl BytesContainer for ~str { @@ -625,7 +625,7 @@ impl BytesContainer for @str { fn is_str(_: Option<@str>) -> bool { true } } -impl<'self> BytesContainer for &'self [u8] { +impl<'a> BytesContainer for &'a [u8] { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { *self diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 10ce06f7e03..3f2535765dd 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -25,16 +25,16 @@ use vec::{CopyableVector, RSplitIterator, SplitIterator, Vector, VectorVector}; use super::{BytesContainer, GenericPath, GenericPathUnsafe}; /// Iterator that yields successive components of a Path as &[u8] -pub type ComponentIter<'self> = SplitIterator<'self, u8>; +pub type ComponentIter<'a> = SplitIterator<'a, u8>; /// Iterator that yields components of a Path in reverse as &[u8] -pub type RevComponentIter<'self> = RSplitIterator<'self, u8>; +pub type RevComponentIter<'a> = RSplitIterator<'a, u8>; /// Iterator that yields successive components of a Path as Option<&str> -pub type StrComponentIter<'self> = Map<'self, &'self [u8], Option<&'self str>, - ComponentIter<'self>>; +pub type StrComponentIter<'a> = Map<'a, &'a [u8], Option<&'a str>, + ComponentIter<'a>>; /// Iterator that yields components of a Path in reverse as Option<&str> -pub type RevStrComponentIter<'self> = Map<'self, &'self [u8], Option<&'self str>, - RevComponentIter<'self>>; +pub type RevStrComponentIter<'a> = Map<'a, &'a [u8], Option<&'a str>, + RevComponentIter<'a>>; /// Represents a POSIX file path #[deriving(Clone, DeepClone)] @@ -103,7 +103,7 @@ impl BytesContainer for Path { } } -impl<'self> BytesContainer for &'self Path { +impl<'a> BytesContainer for &'a Path { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { self.as_vec() diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index b7a0d685f12..114f675cdba 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -27,21 +27,21 @@ use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe}; /// /// Each component is yielded as Option<&str> for compatibility with PosixPath, but /// every component in WindowsPath is guaranteed to be Some. -pub type StrComponentIter<'self> = Map<'self, &'self str, Option<&'self str>, - CharSplitIterator<'self, char>>; +pub type StrComponentIter<'a> = Map<'a, &'a str, Option<&'a str>, + CharSplitIterator<'a, char>>; /// Iterator that yields components of a Path in reverse as &str /// /// Each component is yielded as Option<&str> for compatibility with PosixPath, but /// every component in WindowsPath is guaranteed to be Some. -pub type RevStrComponentIter<'self> = Invert<Map<'self, &'self str, Option<&'self str>, - CharSplitIterator<'self, char>>>; +pub type RevStrComponentIter<'a> = Invert<Map<'a, &'a str, Option<&'a str>, + CharSplitIterator<'a, char>>>; /// Iterator that yields successive components of a Path as &[u8] -pub type ComponentIter<'self> = Map<'self, Option<&'self str>, &'self [u8], - StrComponentIter<'self>>; +pub type ComponentIter<'a> = Map<'a, Option<&'a str>, &'a [u8], + StrComponentIter<'a>>; /// Iterator that yields components of a Path in reverse as &[u8] -pub type RevComponentIter<'self> = Map<'self, Option<&'self str>, &'self [u8], - RevStrComponentIter<'self>>; +pub type RevComponentIter<'a> = Map<'a, Option<&'a str>, &'a [u8], + RevStrComponentIter<'a>>; /// Represents a Windows path // Notes for Windows path impl: @@ -138,7 +138,7 @@ impl BytesContainer for Path { fn is_str(_: Option<Path>) -> bool { true } } -impl<'self> BytesContainer for &'self Path { +impl<'a> BytesContainer for &'a Path { #[inline] fn container_as_bytes<'a>(&'a self) -> &'a [u8] { self.as_vec() @@ -152,7 +152,7 @@ impl<'self> BytesContainer for &'self Path { self.as_str() } #[inline] - fn is_str(_: Option<&'self Path>) -> bool { true } + fn is_str(_: Option<&'a Path>) -> bool { true } } impl GenericPathUnsafe for Path { diff --git a/src/libstd/rand/isaac.rs b/src/libstd/rand/isaac.rs index 877df1fb644..3dcf97212f5 100644 --- a/src/libstd/rand/isaac.rs +++ b/src/libstd/rand/isaac.rs @@ -188,8 +188,8 @@ impl Rng for IsaacRng { } } -impl<'self> SeedableRng<&'self [u32]> for IsaacRng { - fn reseed(&mut self, seed: &'self [u32]) { +impl<'a> SeedableRng<&'a [u32]> for IsaacRng { + fn reseed(&mut self, seed: &'a [u32]) { // make the seed into [seed[0], seed[1], ..., seed[seed.len() // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u32)); @@ -210,7 +210,7 @@ impl<'self> SeedableRng<&'self [u32]> for IsaacRng { /// 256 and any more will be silently ignored. A generator /// constructed with a given seed will generate the same sequence /// of values as all other generators constructed with that seed. - fn from_seed(seed: &'self [u32]) -> IsaacRng { + fn from_seed(seed: &'a [u32]) -> IsaacRng { let mut rng = EMPTY; rng.reseed(seed); rng @@ -399,8 +399,8 @@ impl Rng for Isaac64Rng { } } -impl<'self> SeedableRng<&'self [u64]> for Isaac64Rng { - fn reseed(&mut self, seed: &'self [u64]) { +impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { + fn reseed(&mut self, seed: &'a [u64]) { // make the seed into [seed[0], seed[1], ..., seed[seed.len() // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(Repeat::new(0u64)); @@ -421,7 +421,7 @@ impl<'self> SeedableRng<&'self [u64]> for Isaac64Rng { /// 256 and any more will be silently ignored. A generator /// constructed with a given seed will generate the same sequence /// of values as all other generators constructed with that seed. - fn from_seed(seed: &'self [u64]) -> Isaac64Rng { + fn from_seed(seed: &'a [u64]) -> Isaac64Rng { let mut rng = EMPTY_64; rng.reseed(seed); rng diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 3a33fb182aa..32c2402f39b 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -469,14 +469,14 @@ impl Rng for StdRng { } } -impl<'self> SeedableRng<&'self [uint]> for StdRng { - fn reseed(&mut self, seed: &'self [uint]) { +impl<'a> SeedableRng<&'a [uint]> for StdRng { + fn reseed(&mut self, seed: &'a [uint]) { // the internal RNG can just be seeded from the above // randomness. self.rng.reseed(unsafe {cast::transmute(seed)}) } - fn from_seed(seed: &'self [uint]) -> StdRng { + fn from_seed(seed: &'a [uint]) -> StdRng { StdRng { rng: SeedableRng::from_seed(unsafe {cast::transmute(seed)}) } } } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 081673e86cb..2f9478716a3 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -97,11 +97,11 @@ enum VariantState { AlreadyFound } -pub struct ReprVisitor<'self> { +pub struct ReprVisitor<'a> { priv ptr: *c_void, priv ptr_stk: ~[*c_void], priv var_stk: ~[VariantState], - priv writer: &'self mut io::Writer + priv writer: &'a mut io::Writer } pub fn ReprVisitor<'a>(ptr: *c_void, @@ -114,7 +114,7 @@ pub fn ReprVisitor<'a>(ptr: *c_void, } } -impl<'self> MovePtr for ReprVisitor<'self> { +impl<'a> MovePtr for ReprVisitor<'a> { #[inline] fn move_ptr(&mut self, adjustment: |*c_void| -> *c_void) { self.ptr = adjustment(self.ptr); @@ -127,7 +127,7 @@ impl<'self> MovePtr for ReprVisitor<'self> { } } -impl<'self> ReprVisitor<'self> { +impl<'a> ReprVisitor<'a> { // Various helpers for the TyVisitor impl #[inline] @@ -242,7 +242,7 @@ impl<'self> ReprVisitor<'self> { } } -impl<'self> TyVisitor for ReprVisitor<'self> { +impl<'a> TyVisitor for ReprVisitor<'a> { fn visit_bot(&mut self) -> bool { self.writer.write("!".as_bytes()); true diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 2b1e7865a73..2fa34994292 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -510,7 +510,7 @@ impl<T: Send> Peekable<T> for Port<T> { // of them, but a &Port<T> should also be selectable so you can select2 on it // alongside a PortOne<U> without passing the port by value in recv_ready. -impl<'self, T: Send> SelectInner for &'self Port<T> { +impl<'a, T: Send> SelectInner for &'a Port<T> { #[inline] fn optimistic_check(&mut self) -> bool { self.next.with_mut(|pone| { pone.get_mut_ref().optimistic_check() }) @@ -528,7 +528,7 @@ impl<'self, T: Send> SelectInner for &'self Port<T> { } } -impl<'self, T: Send> Select for &'self Port<T> { } +impl<'a, T: Send> Select for &'a Port<T> { } impl<T: Send> SelectInner for Port<T> { #[inline] @@ -549,7 +549,7 @@ impl<T: Send> SelectInner for Port<T> { impl<T: Send> Select for Port<T> { } -impl<'self, T: Send> SelectPortInner<T> for &'self Port<T> { +impl<'a, T: Send> SelectPortInner<T> for &'a Port<T> { fn recv_ready(self) -> Option<T> { let mut b = self.next.borrow_mut(); match b.get().take_unwrap().recv_ready() { @@ -562,7 +562,7 @@ impl<'self, T: Send> SelectPortInner<T> for &'self Port<T> { } } -impl<'self, T: Send> SelectPort<T> for &'self Port<T> { } +impl<'a, T: Send> SelectPort<T> for &'a Port<T> { } pub struct SharedChan<T> { // Just like Chan, but a shared AtomicOption diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs index 6dcbd4a129e..22fc3f0ab56 100644 --- a/src/libstd/rt/crate_map.rs +++ b/src/libstd/rt/crate_map.rs @@ -21,15 +21,15 @@ use rt::rtio::EventLoop; #[link_args = "-Wl,-U,__rust_crate_map_toplevel"] extern {} -pub struct ModEntry<'self> { - name: &'self str, +pub struct ModEntry<'a> { + name: &'a str, log_level: *mut u32 } -pub struct CrateMap<'self> { +pub struct CrateMap<'a> { version: i32, - entries: &'self [ModEntry<'self>], - children: &'self [&'self CrateMap<'self>], + entries: &'a [ModEntry<'a>], + children: &'a [&'a CrateMap<'a>], event_loop_factory: Option<extern "C" fn() -> ~EventLoop>, } diff --git a/src/libstd/run.rs b/src/libstd/run.rs index f4c6cdbd934..754c02e308f 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -33,7 +33,7 @@ pub struct Process { } /// Options that can be given when starting a Process. -pub struct ProcessOptions<'self> { +pub struct ProcessOptions<'a> { /** * If this is None then the new process will have the same initial * environment as the parent process. @@ -50,7 +50,7 @@ pub struct ProcessOptions<'self> { * If this is Some(path) then the new process will use the given path * for its initial working directory. */ - dir: Option<&'self Path>, + dir: Option<&'a Path>, /** * If this is None then a new pipe will be created for the new process's @@ -83,7 +83,7 @@ pub struct ProcessOptions<'self> { err_fd: Option<c_int>, } -impl <'self> ProcessOptions<'self> { +impl <'a> ProcessOptions<'a> { /// Return a ProcessOptions that has None in every field. pub fn new<'a>() -> ProcessOptions<'a> { ProcessOptions { diff --git a/src/libstd/select.rs b/src/libstd/select.rs index 01b953051db..cca64244db5 100644 --- a/src/libstd/select.rs +++ b/src/libstd/select.rs @@ -108,7 +108,7 @@ pub fn select<A: Select>(ports: &mut [A]) -> uint { /* FIXME(#5121, #7914) This all should be legal, but rust is not clever enough yet. -impl <'self> Select for &'self mut Select { +impl <'a> Select for &'a mut Select { fn optimistic_check(&mut self) -> bool { self.optimistic_check() } fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool { self.block_on(sched, task) diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs index 3ef99d48a03..b0bc4c3f467 100644 --- a/src/libstd/send_str.rs +++ b/src/libstd/send_str.rs @@ -107,7 +107,7 @@ impl TotalOrd for SendStr { } } -impl<'self, S: Str> Equiv<S> for SendStr { +impl<'a, S: Str> Equiv<S> for SendStr { #[inline] fn equiv(&self, other: &S) -> bool { self.as_slice().equals(&other.as_slice()) diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 0fbf9d92595..af381ef3cf0 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -182,7 +182,7 @@ impl FromStr for ~str { fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) } } -impl<'self> ToStr for &'self str { +impl<'a> ToStr for &'a str { #[inline] fn to_str(&self) -> ~str { self.to_owned() } } @@ -192,7 +192,7 @@ impl ToStr for @str { fn to_str(&self) -> ~str { self.to_owned() } } -impl<'self> FromStr for @str { +impl<'a> FromStr for @str { #[inline] fn from_str(s: &str) -> Option<@str> { Some(s.to_managed()) } } @@ -238,7 +238,7 @@ pub trait StrVector { fn connect(&self, sep: &str) -> ~str; } -impl<'self, S: Str> StrVector for &'self [S] { +impl<'a, S: Str> StrVector for &'a [S] { fn concat(&self) -> ~str { if self.is_empty() { return ~""; } @@ -294,7 +294,7 @@ impl CharEq for char { fn only_ascii(&self) -> bool { (*self as uint) < 128 } } -impl<'self> CharEq for 'self |char| -> bool { +impl<'a> CharEq for 'a |char| -> bool { #[inline] fn matches(&self, c: char) -> bool { (*self)(c) } @@ -308,7 +308,7 @@ impl CharEq for extern "Rust" fn(char) -> bool { fn only_ascii(&self) -> bool { false } } -impl<'self, C: CharEq> CharEq for &'self [C] { +impl<'a, C: CharEq> CharEq for &'a [C] { #[inline] fn matches(&self, c: char) -> bool { self.iter().any(|m| m.matches(c)) @@ -326,12 +326,12 @@ Section: Iterators /// External iterator for a string's characters. /// Use with the `std::iter` module. #[deriving(Clone)] -pub struct CharIterator<'self> { +pub struct CharIterator<'a> { /// The slice remaining to be iterated - priv string: &'self str, + priv string: &'a str, } -impl<'self> Iterator<char> for CharIterator<'self> { +impl<'a> Iterator<char> for CharIterator<'a> { #[inline] fn next(&mut self) -> Option<char> { // Decode the next codepoint, then update @@ -353,7 +353,7 @@ impl<'self> Iterator<char> for CharIterator<'self> { } } -impl<'self> DoubleEndedIterator<char> for CharIterator<'self> { +impl<'a> DoubleEndedIterator<char> for CharIterator<'a> { #[inline] fn next_back(&mut self) -> Option<char> { if self.string.len() != 0 { @@ -371,13 +371,13 @@ impl<'self> DoubleEndedIterator<char> for CharIterator<'self> { /// External iterator for a string's characters and their byte offsets. /// Use with the `std::iter` module. #[deriving(Clone)] -pub struct CharOffsetIterator<'self> { +pub struct CharOffsetIterator<'a> { /// The original string to be iterated - priv string: &'self str, - priv iter: CharIterator<'self>, + priv string: &'a str, + priv iter: CharIterator<'a>, } -impl<'self> Iterator<(uint, char)> for CharOffsetIterator<'self> { +impl<'a> Iterator<(uint, char)> for CharOffsetIterator<'a> { #[inline] fn next(&mut self) -> Option<(uint, char)> { // Compute the byte offset by using the pointer offset between @@ -396,7 +396,7 @@ impl<'self> Iterator<(uint, char)> for CharOffsetIterator<'self> { } } -impl<'self> DoubleEndedIterator<(uint, char)> for CharOffsetIterator<'self> { +impl<'a> DoubleEndedIterator<(uint, char)> for CharOffsetIterator<'a> { #[inline] fn next_back(&mut self) -> Option<(uint, char)> { self.iter.next_back().map(|ch| { @@ -412,26 +412,26 @@ impl<'self> DoubleEndedIterator<(uint, char)> for CharOffsetIterator<'self> { /// External iterator for a string's characters in reverse order. /// Use with the `std::iter` module. -pub type CharRevIterator<'self> = Invert<CharIterator<'self>>; +pub type CharRevIterator<'a> = Invert<CharIterator<'a>>; /// External iterator for a string's characters and their byte offsets in reverse order. /// Use with the `std::iter` module. -pub type CharOffsetRevIterator<'self> = Invert<CharOffsetIterator<'self>>; +pub type CharOffsetRevIterator<'a> = Invert<CharOffsetIterator<'a>>; /// External iterator for a string's bytes. /// Use with the `std::iter` module. -pub type ByteIterator<'self> = - Map<'self, &'self u8, u8, vec::VecIterator<'self, u8>>; +pub type ByteIterator<'a> = + Map<'a, &'a u8, u8, vec::VecIterator<'a, u8>>; /// External iterator for a string's bytes in reverse order. /// Use with the `std::iter` module. -pub type ByteRevIterator<'self> = Invert<ByteIterator<'self>>; +pub type ByteRevIterator<'a> = Invert<ByteIterator<'a>>; /// An iterator over the substrings of a string, separated by `sep`. #[deriving(Clone)] -pub struct CharSplitIterator<'self, Sep> { +pub struct CharSplitIterator<'a, Sep> { /// The slice remaining to be iterated - priv string: &'self str, + priv string: &'a str, priv sep: Sep, /// Whether an empty string at the end is allowed priv allow_trailing_empty: bool, @@ -441,29 +441,29 @@ pub struct CharSplitIterator<'self, Sep> { /// An iterator over the substrings of a string, separated by `sep`, /// starting from the back of the string. -pub type CharRSplitIterator<'self, Sep> = Invert<CharSplitIterator<'self, Sep>>; +pub type CharRSplitIterator<'a, Sep> = Invert<CharSplitIterator<'a, Sep>>; /// An iterator over the substrings of a string, separated by `sep`, /// splitting at most `count` times. #[deriving(Clone)] -pub struct CharSplitNIterator<'self, Sep> { - priv iter: CharSplitIterator<'self, Sep>, +pub struct CharSplitNIterator<'a, Sep> { + priv iter: CharSplitIterator<'a, Sep>, /// The number of splits remaining priv count: uint, priv invert: bool, } /// An iterator over the words of a string, separated by an sequence of whitespace -pub type WordIterator<'self> = - Filter<'self, &'self str, CharSplitIterator<'self, extern "Rust" fn(char) -> bool>>; +pub type WordIterator<'a> = + Filter<'a, &'a str, CharSplitIterator<'a, extern "Rust" fn(char) -> bool>>; /// An iterator over the lines of a string, separated by either `\n` or (`\r\n`). -pub type AnyLineIterator<'self> = - Map<'self, &'self str, &'self str, CharSplitIterator<'self, char>>; +pub type AnyLineIterator<'a> = + Map<'a, &'a str, &'a str, CharSplitIterator<'a, char>>; -impl<'self, Sep> CharSplitIterator<'self, Sep> { +impl<'a, Sep> CharSplitIterator<'a, Sep> { #[inline] - fn get_end(&mut self) -> Option<&'self str> { + fn get_end(&mut self) -> Option<&'a str> { if !self.finished && (self.allow_trailing_empty || self.string.len() > 0) { self.finished = true; Some(self.string) @@ -473,9 +473,9 @@ impl<'self, Sep> CharSplitIterator<'self, Sep> { } } -impl<'self, Sep: CharEq> Iterator<&'self str> for CharSplitIterator<'self, Sep> { +impl<'a, Sep: CharEq> Iterator<&'a str> for CharSplitIterator<'a, Sep> { #[inline] - fn next(&mut self) -> Option<&'self str> { + fn next(&mut self) -> Option<&'a str> { if self.finished { return None } let mut next_split = None; @@ -505,10 +505,10 @@ impl<'self, Sep: CharEq> Iterator<&'self str> for CharSplitIterator<'self, Sep> } } -impl<'self, Sep: CharEq> DoubleEndedIterator<&'self str> -for CharSplitIterator<'self, Sep> { +impl<'a, Sep: CharEq> DoubleEndedIterator<&'a str> +for CharSplitIterator<'a, Sep> { #[inline] - fn next_back(&mut self) -> Option<&'self str> { + fn next_back(&mut self) -> Option<&'a str> { if self.finished { return None } if !self.allow_trailing_empty { @@ -547,9 +547,9 @@ for CharSplitIterator<'self, Sep> { } } -impl<'self, Sep: CharEq> Iterator<&'self str> for CharSplitNIterator<'self, Sep> { +impl<'a, Sep: CharEq> Iterator<&'a str> for CharSplitNIterator<'a, Sep> { #[inline] - fn next(&mut self) -> Option<&'self str> { + fn next(&mut self) -> Option<&'a str> { if self.count != 0 { self.count -= 1; if self.invert { self.iter.next_back() } else { self.iter.next() } @@ -562,22 +562,22 @@ impl<'self, Sep: CharEq> Iterator<&'self str> for CharSplitNIterator<'self, Sep> /// An iterator over the start and end indices of the matches of a /// substring within a larger string #[deriving(Clone)] -pub struct MatchesIndexIterator<'self> { - priv haystack: &'self str, - priv needle: &'self str, +pub struct MatchesIndexIterator<'a> { + priv haystack: &'a str, + priv needle: &'a str, priv position: uint, } /// An iterator over the substrings of a string separated by a given /// search string #[deriving(Clone)] -pub struct StrSplitIterator<'self> { - priv it: MatchesIndexIterator<'self>, +pub struct StrSplitIterator<'a> { + priv it: MatchesIndexIterator<'a>, priv last_end: uint, priv finished: bool } -impl<'self> Iterator<(uint, uint)> for MatchesIndexIterator<'self> { +impl<'a> Iterator<(uint, uint)> for MatchesIndexIterator<'a> { #[inline] fn next(&mut self) -> Option<(uint, uint)> { // See Issue #1932 for why this is a naive search @@ -608,9 +608,9 @@ impl<'self> Iterator<(uint, uint)> for MatchesIndexIterator<'self> { } } -impl<'self> Iterator<&'self str> for StrSplitIterator<'self> { +impl<'a> Iterator<&'a str> for StrSplitIterator<'a> { #[inline] - fn next(&mut self) -> Option<&'self str> { + fn next(&mut self) -> Option<&'a str> { if self.finished { return None; } match self.it.next() { @@ -656,14 +656,14 @@ enum NormalizationForm { /// External iterator for a string's normalization's characters. /// Use with the `std::iter` module. #[deriving(Clone)] -struct NormalizationIterator<'self> { +struct NormalizationIterator<'a> { priv kind: NormalizationForm, - priv iter: CharIterator<'self>, + priv iter: CharIterator<'a>, priv buffer: ~[(char, u8)], priv sorted: bool } -impl<'self> Iterator<char> for NormalizationIterator<'self> { +impl<'a> Iterator<char> for NormalizationIterator<'a> { #[inline] fn next(&mut self) -> Option<char> { use unicode::decompose::canonical_combining_class; @@ -1168,18 +1168,18 @@ pub mod traits { use super::{Str, eq_slice}; use option::{Some, None}; - impl<'self> Add<&'self str,~str> for &'self str { + impl<'a> Add<&'a str,~str> for &'a str { #[inline] - fn add(&self, rhs: & &'self str) -> ~str { + fn add(&self, rhs: & &'a str) -> ~str { let mut ret = self.to_owned(); ret.push_str(*rhs); ret } } - impl<'self> TotalOrd for &'self str { + impl<'a> TotalOrd for &'a str { #[inline] - fn cmp(&self, other: & &'self str) -> Ordering { + fn cmp(&self, other: & &'a str) -> Ordering { for (s_b, o_b) in self.bytes().zip(other.bytes()) { match s_b.cmp(&o_b) { Greater => return Greater, @@ -1202,13 +1202,13 @@ pub mod traits { fn cmp(&self, other: &@str) -> Ordering { self.as_slice().cmp(&other.as_slice()) } } - impl<'self> Eq for &'self str { + impl<'a> Eq for &'a str { #[inline] - fn eq(&self, other: & &'self str) -> bool { + fn eq(&self, other: & &'a str) -> bool { eq_slice((*self), (*other)) } #[inline] - fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) } + fn ne(&self, other: & &'a str) -> bool { !(*self).eq(other) } } impl Eq for ~str { @@ -1225,9 +1225,9 @@ pub mod traits { } } - impl<'self> TotalEq for &'self str { + impl<'a> TotalEq for &'a str { #[inline] - fn equals(&self, other: & &'self str) -> bool { + fn equals(&self, other: & &'a str) -> bool { eq_slice((*self), (*other)) } } @@ -1246,9 +1246,9 @@ pub mod traits { } } - impl<'self> Ord for &'self str { + impl<'a> Ord for &'a str { #[inline] - fn lt(&self, other: & &'self str) -> bool { self.cmp(other) == Less } + fn lt(&self, other: & &'a str) -> bool { self.cmp(other) == Less } } impl Ord for ~str { @@ -1261,17 +1261,17 @@ pub mod traits { fn lt(&self, other: &@str) -> bool { self.cmp(other) == Less } } - impl<'self, S: Str> Equiv<S> for &'self str { + impl<'a, S: Str> Equiv<S> for &'a str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } } - impl<'self, S: Str> Equiv<S> for @str { + impl<'a, S: Str> Equiv<S> for @str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } } - impl<'self, S: Str> Equiv<S> for ~str { + impl<'a, S: Str> Equiv<S> for ~str { #[inline] fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } } @@ -1289,7 +1289,7 @@ pub trait Str { fn into_owned(self) -> ~str; } -impl<'self> Str for &'self str { +impl<'a> Str for &'a str { #[inline] fn as_slice<'a>(&'a self) -> &'a str { *self } @@ -1297,7 +1297,7 @@ impl<'self> Str for &'self str { fn into_owned(self) -> ~str { self.to_owned() } } -impl<'self> Str for ~str { +impl<'a> Str for ~str { #[inline] fn as_slice<'a>(&'a self) -> &'a str { let s: &'a str = *self; s @@ -1307,7 +1307,7 @@ impl<'self> Str for ~str { fn into_owned(self) -> ~str { self } } -impl<'self> Str for @str { +impl<'a> Str for @str { #[inline] fn as_slice<'a>(&'a self) -> &'a str { let s: &'a str = *self; s @@ -1317,7 +1317,7 @@ impl<'self> Str for @str { fn into_owned(self) -> ~str { self.to_owned() } } -impl<'self> Container for &'self str { +impl<'a> Container for &'a str { #[inline] fn len(&self) -> uint { self.as_imm_buf(|_p, n| n) @@ -1345,7 +1345,7 @@ impl Mutable for ~str { } /// Methods for string slices -pub trait StrSlice<'self> { +pub trait StrSlice<'a> { /// Returns true if one string contains another /// /// # Arguments @@ -1369,23 +1369,23 @@ pub trait StrSlice<'self> { /// let v: ~[char] = "abc åäö".chars().collect(); /// assert_eq!(v, ~['a', 'b', 'c', ' ', 'å', 'ä', 'ö']); /// ``` - fn chars(&self) -> CharIterator<'self>; + fn chars(&self) -> CharIterator<'a>; /// An iterator over the characters of `self`, in reverse order. - fn chars_rev(&self) -> CharRevIterator<'self>; + fn chars_rev(&self) -> CharRevIterator<'a>; /// An iterator over the bytes of `self` - fn bytes(&self) -> ByteIterator<'self>; + fn bytes(&self) -> ByteIterator<'a>; /// An iterator over the bytes of `self`, in reverse order - fn bytes_rev(&self) -> ByteRevIterator<'self>; + fn bytes_rev(&self) -> ByteRevIterator<'a>; /// An iterator over the characters of `self` and their byte offsets. - fn char_indices(&self) -> CharOffsetIterator<'self>; + fn char_indices(&self) -> CharOffsetIterator<'a>; /// An iterator over the characters of `self` and their byte offsets, /// in reverse order. - fn char_indices_rev(&self) -> CharOffsetRevIterator<'self>; + fn char_indices_rev(&self) -> CharOffsetRevIterator<'a>; /// An iterator over substrings of `self`, separated by characters /// matched by `sep`. @@ -1402,7 +1402,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "lionXXtigerXleopard".split('X').collect(); /// assert_eq!(v, ~["lion", "", "tiger", "leopard"]); /// ``` - fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'self, Sep>; + fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'a, Sep>; /// An iterator over substrings of `self`, separated by characters /// matched by `sep`, restricted to splitting at most `count` @@ -1420,7 +1420,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "lionXXtigerXleopard".splitn('X', 2).collect(); /// assert_eq!(v, ~["lion", "", "tigerXleopard"]); /// ``` - fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitNIterator<'self, Sep>; + fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitNIterator<'a, Sep>; /// An iterator over substrings of `self`, separated by characters /// matched by `sep`. @@ -1437,7 +1437,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "A..B..".split_terminator('.').collect(); /// assert_eq!(v, ~["A", "", "B", ""]); /// ``` - fn split_terminator<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'self, Sep>; + fn split_terminator<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'a, Sep>; /// An iterator over substrings of `self`, separated by characters /// matched by `sep`, in reverse order. @@ -1454,7 +1454,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "lionXXtigerXleopard".rsplit('X').collect(); /// assert_eq!(v, ~["leopard", "tiger", "", "lion"]); /// ``` - fn rsplit<Sep: CharEq>(&self, sep: Sep) -> CharRSplitIterator<'self, Sep>; + fn rsplit<Sep: CharEq>(&self, sep: Sep) -> CharRSplitIterator<'a, Sep>; /// An iterator over substrings of `self`, separated by characters /// matched by `sep`, starting from the end of the string. @@ -1472,7 +1472,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "lionXXtigerXleopard".rsplitn('X', 2).collect(); /// assert_eq!(v, ~["leopard", "tiger", "lionX"]); /// ``` - fn rsplitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitNIterator<'self, Sep>; + fn rsplitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitNIterator<'a, Sep>; /// An iterator over the start and end indices of the disjoint /// matches of `sep` within `self`. @@ -1494,7 +1494,7 @@ pub trait StrSlice<'self> { /// let v: ~[(uint, uint)] = "ababa".split_str("aba").collect(); /// assert_eq!(v, ~[(0, 3)]); // only the first `aba` /// ``` - fn match_indices(&self, sep: &'self str) -> MatchesIndexIterator<'self>; + fn match_indices(&self, sep: &'a str) -> MatchesIndexIterator<'a>; /// An iterator over the substrings of `self` separated by `sep`. /// @@ -1507,7 +1507,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = "1abcabc2".split_str("abc").collect(); /// assert_eq!(v, ~["1", "", "2"]); /// ``` - fn split_str(&self, &'self str) -> StrSplitIterator<'self>; + fn split_str(&self, &'a str) -> StrSplitIterator<'a>; /// An iterator over the lines of a string (subsequences separated /// by `\n`). This does not include the empty string after a @@ -1520,7 +1520,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = four_lines.lines().collect(); /// assert_eq!(v, ~["foo", "bar", "", "baz"]); /// ``` - fn lines(&self) -> CharSplitIterator<'self, char>; + fn lines(&self) -> CharSplitIterator<'a, char>; /// An iterator over the lines of a string, separated by either /// `\n` or `\r\n`. As with `.lines()`, this does not include an @@ -1533,7 +1533,7 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = four_lines.lines_any().collect(); /// assert_eq!(v, ~["foo", "bar", "", "baz"]); /// ``` - fn lines_any(&self) -> AnyLineIterator<'self>; + fn lines_any(&self) -> AnyLineIterator<'a>; /// An iterator over the words of a string (subsequences separated /// by any sequence of whitespace). Sequences of whitespace are @@ -1546,15 +1546,15 @@ pub trait StrSlice<'self> { /// let v: ~[&str] = some_words.words().collect(); /// assert_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); /// ``` - fn words(&self) -> WordIterator<'self>; + fn words(&self) -> WordIterator<'a>; /// An Iterator over the string in Unicode Normalization Form D /// (canonical decomposition). - fn nfd_chars(&self) -> NormalizationIterator<'self>; + fn nfd_chars(&self) -> NormalizationIterator<'a>; /// An Iterator over the string in Unicode Normalization Form KD /// (compatibility decomposition). - fn nfkd_chars(&self) -> NormalizationIterator<'self>; + fn nfkd_chars(&self) -> NormalizationIterator<'a>; /// Returns true if the string contains only whitespace. /// @@ -1647,7 +1647,7 @@ pub trait StrSlice<'self> { /// // byte 100 is outside the string /// // s.slice(3, 100); /// ``` - fn slice(&self, begin: uint, end: uint) -> &'self str; + fn slice(&self, begin: uint, end: uint) -> &'a str; /// Returns a slice of the string from `begin` to its end. /// @@ -1657,7 +1657,7 @@ pub trait StrSlice<'self> { /// out of bounds. /// /// See also `slice`, `slice_to` and `slice_chars`. - fn slice_from(&self, begin: uint) -> &'self str; + fn slice_from(&self, begin: uint) -> &'a str; /// Returns a slice of the string from the beginning to byte /// `end`. @@ -1668,7 +1668,7 @@ pub trait StrSlice<'self> { /// out of bounds. /// /// See also `slice`, `slice_from` and `slice_chars`. - fn slice_to(&self, end: uint) -> &'self str; + fn slice_to(&self, end: uint) -> &'a str; /// Returns a slice of the string from the character range /// [`begin`..`end`). @@ -1693,7 +1693,7 @@ pub trait StrSlice<'self> { /// assert_eq!(s.slice_chars(0, 4), "Löwe"); /// assert_eq!(s.slice_chars(6, 8), "老虎"); /// ``` - fn slice_chars(&self, begin: uint, end: uint) -> &'self str; + fn slice_chars(&self, begin: uint, end: uint) -> &'a str; /// Returns true if `needle` is a prefix of the string. fn starts_with(&self, needle: &str) -> bool; @@ -1708,13 +1708,13 @@ pub trait StrSlice<'self> { fn escape_unicode(&self) -> ~str; /// Returns a string with leading and trailing whitespace removed. - fn trim(&self) -> &'self str; + fn trim(&self) -> &'a str; /// Returns a string with leading whitespace removed. - fn trim_left(&self) -> &'self str; + fn trim_left(&self) -> &'a str; /// Returns a string with trailing whitespace removed. - fn trim_right(&self) -> &'self str; + fn trim_right(&self) -> &'a str; /// Returns a string with characters that match `to_trim` removed. /// @@ -1729,7 +1729,7 @@ pub trait StrSlice<'self> { /// assert_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar") /// assert_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar") /// ``` - fn trim_chars<C: CharEq>(&self, to_trim: &C) -> &'self str; + fn trim_chars<C: CharEq>(&self, to_trim: &C) -> &'a str; /// Returns a string with leading `chars_to_trim` removed. /// @@ -1744,7 +1744,7 @@ pub trait StrSlice<'self> { /// assert_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12") /// assert_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123") /// ``` - fn trim_left_chars<C: CharEq>(&self, to_trim: &C) -> &'self str; + fn trim_left_chars<C: CharEq>(&self, to_trim: &C) -> &'a str; /// Returns a string with trailing `chars_to_trim` removed. /// @@ -1759,7 +1759,7 @@ pub trait StrSlice<'self> { /// assert_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar") /// assert_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar") /// ``` - fn trim_right_chars<C: CharEq>(&self, to_trim: &C) -> &'self str; + fn trim_right_chars<C: CharEq>(&self, to_trim: &C) -> &'a str; /// Replace all occurrences of one string with another. /// @@ -1891,7 +1891,7 @@ pub trait StrSlice<'self> { fn char_at_reverse(&self, i: uint) -> char; /// Work with the byte buffer of a string as a byte slice. - fn as_bytes(&self) -> &'self [u8]; + fn as_bytes(&self) -> &'a [u8]; /// Returns the byte index of the first character of `self` that /// matches `search`. @@ -1986,7 +1986,7 @@ pub trait StrSlice<'self> { /// assert_eq!(c, 'ö'); /// assert_eq!(s2, "we 老虎 Léopard"); /// ``` - fn slice_shift_char(&self) -> (char, &'self str); + fn slice_shift_char(&self) -> (char, &'a str); /// Levenshtein Distance between two strings. fn lev_distance(&self, t: &str) -> uint; @@ -2013,7 +2013,7 @@ pub trait StrSlice<'self> { fn as_imm_buf<T>(&self, f: |*u8, uint| -> T) -> T; } -impl<'self> StrSlice<'self> for &'self str { +impl<'a> StrSlice<'a> for &'a str { #[inline] fn contains<'a>(&self, needle: &'a str) -> bool { self.find_str(needle).is_some() @@ -2025,37 +2025,37 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn chars(&self) -> CharIterator<'self> { + fn chars(&self) -> CharIterator<'a> { CharIterator{string: *self} } #[inline] - fn chars_rev(&self) -> CharRevIterator<'self> { + fn chars_rev(&self) -> CharRevIterator<'a> { self.chars().invert() } #[inline] - fn bytes(&self) -> ByteIterator<'self> { + fn bytes(&self) -> ByteIterator<'a> { self.as_bytes().iter().map(|&b| b) } #[inline] - fn bytes_rev(&self) -> ByteRevIterator<'self> { + fn bytes_rev(&self) -> ByteRevIterator<'a> { self.bytes().invert() } #[inline] - fn char_indices(&self) -> CharOffsetIterator<'self> { + fn char_indices(&self) -> CharOffsetIterator<'a> { CharOffsetIterator{string: *self, iter: self.chars()} } #[inline] - fn char_indices_rev(&self) -> CharOffsetRevIterator<'self> { + fn char_indices_rev(&self) -> CharOffsetRevIterator<'a> { self.char_indices().invert() } #[inline] - fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'self, Sep> { + fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplitIterator<'a, Sep> { CharSplitIterator { string: *self, only_ascii: sep.only_ascii(), @@ -2067,7 +2067,7 @@ impl<'self> StrSlice<'self> for &'self str { #[inline] fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) - -> CharSplitNIterator<'self, Sep> { + -> CharSplitNIterator<'a, Sep> { CharSplitNIterator { iter: self.split(sep), count: count, @@ -2077,7 +2077,7 @@ impl<'self> StrSlice<'self> for &'self str { #[inline] fn split_terminator<Sep: CharEq>(&self, sep: Sep) - -> CharSplitIterator<'self, Sep> { + -> CharSplitIterator<'a, Sep> { CharSplitIterator { allow_trailing_empty: false, ..self.split(sep) @@ -2085,13 +2085,13 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn rsplit<Sep: CharEq>(&self, sep: Sep) -> CharRSplitIterator<'self, Sep> { + fn rsplit<Sep: CharEq>(&self, sep: Sep) -> CharRSplitIterator<'a, Sep> { self.split(sep).invert() } #[inline] fn rsplitn<Sep: CharEq>(&self, sep: Sep, count: uint) - -> CharSplitNIterator<'self, Sep> { + -> CharSplitNIterator<'a, Sep> { CharSplitNIterator { iter: self.split(sep), count: count, @@ -2100,7 +2100,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn match_indices(&self, sep: &'self str) -> MatchesIndexIterator<'self> { + fn match_indices(&self, sep: &'a str) -> MatchesIndexIterator<'a> { assert!(!sep.is_empty()) MatchesIndexIterator { haystack: *self, @@ -2110,7 +2110,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn split_str(&self, sep: &'self str) -> StrSplitIterator<'self> { + fn split_str(&self, sep: &'a str) -> StrSplitIterator<'a> { StrSplitIterator { it: self.match_indices(sep), last_end: 0, @@ -2119,11 +2119,11 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn lines(&self) -> CharSplitIterator<'self, char> { + fn lines(&self) -> CharSplitIterator<'a, char> { self.split_terminator('\n') } - fn lines_any(&self) -> AnyLineIterator<'self> { + fn lines_any(&self) -> AnyLineIterator<'a> { self.lines().map(|line| { let l = line.len(); if l > 0 && line[l - 1] == '\r' as u8 { line.slice(0, l - 1) } @@ -2132,12 +2132,12 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn words(&self) -> WordIterator<'self> { + fn words(&self) -> WordIterator<'a> { self.split(char::is_whitespace).filter(|s| !s.is_empty()) } #[inline] - fn nfd_chars(&self) -> NormalizationIterator<'self> { + fn nfd_chars(&self) -> NormalizationIterator<'a> { NormalizationIterator { iter: self.chars(), buffer: ~[], @@ -2147,7 +2147,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn nfkd_chars(&self) -> NormalizationIterator<'self> { + fn nfkd_chars(&self) -> NormalizationIterator<'a> { NormalizationIterator { iter: self.chars(), buffer: ~[], @@ -2166,23 +2166,23 @@ impl<'self> StrSlice<'self> for &'self str { fn char_len(&self) -> uint { self.chars().len() } #[inline] - fn slice(&self, begin: uint, end: uint) -> &'self str { + fn slice(&self, begin: uint, end: uint) -> &'a str { assert!(self.is_char_boundary(begin) && self.is_char_boundary(end)); unsafe { raw::slice_bytes(*self, begin, end) } } #[inline] - fn slice_from(&self, begin: uint) -> &'self str { + fn slice_from(&self, begin: uint) -> &'a str { self.slice(begin, self.len()) } #[inline] - fn slice_to(&self, end: uint) -> &'self str { + fn slice_to(&self, end: uint) -> &'a str { assert!(self.is_char_boundary(end)); unsafe { raw::slice_bytes(*self, 0, end) } } - fn slice_chars(&self, begin: uint, end: uint) -> &'self str { + fn slice_chars(&self, begin: uint, end: uint) -> &'a str { assert!(begin <= end); let mut count = 0; let mut begin_byte = None; @@ -2236,27 +2236,27 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn trim(&self) -> &'self str { + fn trim(&self) -> &'a str { self.trim_left().trim_right() } #[inline] - fn trim_left(&self) -> &'self str { + fn trim_left(&self) -> &'a str { self.trim_left_chars(&char::is_whitespace) } #[inline] - fn trim_right(&self) -> &'self str { + fn trim_right(&self) -> &'a str { self.trim_right_chars(&char::is_whitespace) } #[inline] - fn trim_chars<C: CharEq>(&self, to_trim: &C) -> &'self str { + fn trim_chars<C: CharEq>(&self, to_trim: &C) -> &'a str { self.trim_left_chars(to_trim).trim_right_chars(to_trim) } #[inline] - fn trim_left_chars<C: CharEq>(&self, to_trim: &C) -> &'self str { + fn trim_left_chars<C: CharEq>(&self, to_trim: &C) -> &'a str { match self.find(|c: char| !to_trim.matches(c)) { None => "", Some(first) => unsafe { raw::slice_bytes(*self, first, self.len()) } @@ -2264,7 +2264,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn trim_right_chars<C: CharEq>(&self, to_trim: &C) -> &'self str { + fn trim_right_chars<C: CharEq>(&self, to_trim: &C) -> &'a str { match self.rfind(|c: char| !to_trim.matches(c)) { None => "", Some(last) => { @@ -2408,7 +2408,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn as_bytes(&self) -> &'self [u8] { + fn as_bytes(&self) -> &'a [u8] { unsafe { cast::transmute(*self) } } @@ -2453,7 +2453,7 @@ impl<'self> StrSlice<'self> for &'self str { } #[inline] - fn slice_shift_char(&self) -> (char, &'self str) { + fn slice_shift_char(&self) -> (char, &'a str) { let CharRange {ch, next} = self.char_range_at(0u); let next_s = unsafe { raw::slice_bytes(*self, next, self.len()) }; return (ch, next_s); @@ -2756,8 +2756,8 @@ impl Extendable<char> for ~str { } // This works because every lifetime is a sub-lifetime of 'static -impl<'self> Default for &'self str { - fn default() -> &'self str { "" } +impl<'a> Default for &'a str { + fn default() -> &'a str { "" } } impl Default for ~str { diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index d81fe0c2fbd..815320be94e 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -22,7 +22,7 @@ use rc::Rc; use str::{Str, StrSlice}; use vec::{Vector, ImmutableVector}; -pub type Cb<'self> = 'self |buf: &[u8]| -> bool; +pub type Cb<'a> = 'a |buf: &[u8]| -> bool; /// /// A trait to implement in order to make a type hashable; @@ -219,7 +219,7 @@ impl IterBytes for f64 { } } -impl<'self,A:IterBytes> IterBytes for &'self [A] { +impl<'a,A:IterBytes> IterBytes for &'a [A] { #[inline] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { self.len().iter_bytes(lsb0, |b| f(b)) && @@ -273,7 +273,7 @@ impl<A:IterBytes> IterBytes for @[A] { } } -impl<'self> IterBytes for &'self str { +impl<'a> IterBytes for &'a str { #[inline] fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool { // Terminate the string with a byte that does not appear in UTF-8 @@ -305,7 +305,7 @@ impl<A:IterBytes> IterBytes for Option<A> { } } -impl<'self,A:IterBytes> IterBytes for &'self A { +impl<'a,A:IterBytes> IterBytes for &'a A { #[inline] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { (**self).iter_bytes(lsb0, f) diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index 554b9a85100..41c8aef18f4 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -121,7 +121,7 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) { } } -impl<'self,A:ToStr> ToStr for &'self [A] { +impl<'a,A:ToStr> ToStr for &'a [A] { #[inline] fn to_str(&self) -> ~str { let mut acc = ~"["; diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 97209e99bd6..09dd091d0e7 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -443,14 +443,14 @@ fn remove<T>(count: &mut uint, child: &mut Child<T>, key: uint, } /// Forward iterator over a map -pub struct TrieMapIterator<'self, T> { - priv stack: ~[vec::VecIterator<'self, Child<T>>], +pub struct TrieMapIterator<'a, T> { + priv stack: ~[vec::VecIterator<'a, Child<T>>], priv remaining_min: uint, priv remaining_max: uint } -impl<'self, T> Iterator<(uint, &'self T)> for TrieMapIterator<'self, T> { - fn next(&mut self) -> Option<(uint, &'self T)> { +impl<'a, T> Iterator<(uint, &'a T)> for TrieMapIterator<'a, T> { + fn next(&mut self) -> Option<(uint, &'a T)> { while !self.stack.is_empty() { match self.stack[self.stack.len() - 1].next() { None => { @@ -483,11 +483,11 @@ impl<'self, T> Iterator<(uint, &'self T)> for TrieMapIterator<'self, T> { } /// Forward iterator over a set -pub struct TrieSetIterator<'self> { - priv iter: TrieMapIterator<'self, ()> +pub struct TrieSetIterator<'a> { + priv iter: TrieMapIterator<'a, ()> } -impl<'self> Iterator<uint> for TrieSetIterator<'self> { +impl<'a> Iterator<uint> for TrieSetIterator<'a> { fn next(&mut self) -> Option<uint> { self.iter.next().map(|(key, _)| key) } diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/unstable/dynamic_lib.rs index 42a696eaf7e..03b25fbd044 100644 --- a/src/libstd/unstable/dynamic_lib.rs +++ b/src/libstd/unstable/dynamic_lib.rs @@ -62,7 +62,7 @@ impl DynamicLibrary { /// Access the value at the symbol of the dynamic library pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, ~str> { - // This function should have a lifetime constraint of 'self on + // This function should have a lifetime constraint of 'a on // T but that feature is still unimplemented let maybe_symbol_value = dl::check_for_errors_in(|| { diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 57aff6031ba..6f92da5e93e 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -44,7 +44,7 @@ macro_rules! finally_fn { } } -impl<'self,T> Finally<T> for 'self || -> T { +impl<'a,T> Finally<T> for 'a || -> T { fn finally(&self, dtor: ||) -> T { let _d = Finallyalizer { dtor: dtor @@ -56,12 +56,12 @@ impl<'self,T> Finally<T> for 'self || -> T { finally_fn!(extern "Rust" fn() -> T) -struct Finallyalizer<'self> { - dtor: 'self || +struct Finallyalizer<'a> { + dtor: 'a || } #[unsafe_destructor] -impl<'self> Drop for Finallyalizer<'self> { +impl<'a> Drop for Finallyalizer<'a> { fn drop(&mut self) { (self.dtor)(); } diff --git a/src/libstd/unstable/raw.rs b/src/libstd/unstable/raw.rs index 4ad4656af7b..64a9a7c672a 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/unstable/raw.rs @@ -53,8 +53,8 @@ pub trait Repr<T> { fn repr(&self) -> T { unsafe { cast::transmute_copy(self) } } } -impl<'self, T> Repr<Slice<T>> for &'self [T] {} -impl<'self> Repr<Slice<u8>> for &'self str {} +impl<'a, T> Repr<Slice<T>> for &'a [T] {} +impl<'a> Repr<Slice<u8>> for &'a str {} impl<T> Repr<*Box<T>> for @T {} impl<T> Repr<*Box<Vec<T>>> for @[T] {} impl Repr<*String> for ~str {} diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 621a0be60b3..78ed58ba356 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -219,16 +219,16 @@ pub fn build<A>(size: Option<uint>, builder: |push: |v: A||) -> ~[A] { /// An iterator over the slices of a vector separated by elements that /// match a predicate function. -pub struct SplitIterator<'self, T> { - priv v: &'self [T], +pub struct SplitIterator<'a, T> { + priv v: &'a [T], priv n: uint, - priv pred: 'self |t: &T| -> bool, + priv pred: 'a |t: &T| -> bool, priv finished: bool } -impl<'self, T> Iterator<&'self [T]> for SplitIterator<'self, T> { +impl<'a, T> Iterator<&'a [T]> for SplitIterator<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self [T]> { + fn next(&mut self) -> Option<&'a [T]> { if self.finished { return None; } if self.n == 0 { @@ -268,16 +268,16 @@ impl<'self, T> Iterator<&'self [T]> for SplitIterator<'self, T> { /// An iterator over the slices of a vector separated by elements that /// match a predicate function, from back to front. -pub struct RSplitIterator<'self, T> { - priv v: &'self [T], +pub struct RSplitIterator<'a, T> { + priv v: &'a [T], priv n: uint, - priv pred: 'self |t: &T| -> bool, + priv pred: 'a |t: &T| -> bool, priv finished: bool } -impl<'self, T> Iterator<&'self [T]> for RSplitIterator<'self, T> { +impl<'a, T> Iterator<&'a [T]> for RSplitIterator<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self [T]> { + fn next(&mut self) -> Option<&'a [T]> { if self.finished { return None; } if self.n == 0 { @@ -355,7 +355,7 @@ pub trait VectorVector<T> { fn connect_vec(&self, sep: &T) -> ~[T]; } -impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] { +impl<'a, T: Clone, V: Vector<T>> VectorVector<T> for &'a [V] { fn concat_vec(&self) -> ~[T] { let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len()); let mut result = with_capacity(size); @@ -503,14 +503,14 @@ impl<T: Clone> Iterator<~[T]> for Permutations<T> { /// An iterator over the (overlapping) slices of length `size` within /// a vector. #[deriving(Clone)] -pub struct WindowIter<'self, T> { - priv v: &'self [T], +pub struct WindowIter<'a, T> { + priv v: &'a [T], priv size: uint } -impl<'self, T> Iterator<&'self [T]> for WindowIter<'self, T> { +impl<'a, T> Iterator<&'a [T]> for WindowIter<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self [T]> { + fn next(&mut self) -> Option<&'a [T]> { if self.size > self.v.len() { None } else { @@ -537,14 +537,14 @@ impl<'self, T> Iterator<&'self [T]> for WindowIter<'self, T> { /// When the vector len is not evenly divided by the chunk size, /// the last slice of the iteration will be the remainder. #[deriving(Clone)] -pub struct ChunkIter<'self, T> { - priv v: &'self [T], +pub struct ChunkIter<'a, T> { + priv v: &'a [T], priv size: uint } -impl<'self, T> Iterator<&'self [T]> for ChunkIter<'self, T> { +impl<'a, T> Iterator<&'a [T]> for ChunkIter<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self [T]> { + fn next(&mut self) -> Option<&'a [T]> { if self.v.len() == 0 { None } else { @@ -568,9 +568,9 @@ impl<'self, T> Iterator<&'self [T]> for ChunkIter<'self, T> { } } -impl<'self, T> DoubleEndedIterator<&'self [T]> for ChunkIter<'self, T> { +impl<'a, T> DoubleEndedIterator<&'a [T]> for ChunkIter<'a, T> { #[inline] - fn next_back(&mut self) -> Option<&'self [T]> { + fn next_back(&mut self) -> Option<&'a [T]> { if self.v.len() == 0 { None } else { @@ -584,14 +584,14 @@ impl<'self, T> DoubleEndedIterator<&'self [T]> for ChunkIter<'self, T> { } } -impl<'self, T> RandomAccessIterator<&'self [T]> for ChunkIter<'self, T> { +impl<'a, T> RandomAccessIterator<&'a [T]> for ChunkIter<'a, T> { #[inline] fn indexable(&self) -> uint { self.v.len()/self.size + if self.v.len() % self.size != 0 { 1 } else { 0 } } #[inline] - fn idx(&self, index: uint) -> Option<&'self [T]> { + fn idx(&self, index: uint) -> Option<&'a [T]> { if index < self.indexable() { let lo = index * self.size; let mut hi = lo + self.size; @@ -616,12 +616,12 @@ pub mod traits { use iter::order; use ops::Add; - impl<'self,T:Eq> Eq for &'self [T] { - fn eq(&self, other: & &'self [T]) -> bool { + impl<'a,T:Eq> Eq for &'a [T] { + fn eq(&self, other: & &'a [T]) -> bool { self.len() == other.len() && order::eq(self.iter(), other.iter()) } - fn ne(&self, other: & &'self [T]) -> bool { + fn ne(&self, other: & &'a [T]) -> bool { self.len() != other.len() || order::ne(self.iter(), other.iter()) } @@ -641,8 +641,8 @@ pub mod traits { fn ne(&self, other: &@[T]) -> bool { !self.eq(other) } } - impl<'self,T:TotalEq> TotalEq for &'self [T] { - fn equals(&self, other: & &'self [T]) -> bool { + impl<'a,T:TotalEq> TotalEq for &'a [T] { + fn equals(&self, other: & &'a [T]) -> bool { self.len() == other.len() && order::equals(self.iter(), other.iter()) } @@ -658,23 +658,23 @@ pub mod traits { fn equals(&self, other: &@[T]) -> bool { self.as_slice().equals(&other.as_slice()) } } - impl<'self,T:Eq, V: Vector<T>> Equiv<V> for &'self [T] { + impl<'a,T:Eq, V: Vector<T>> Equiv<V> for &'a [T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } - impl<'self,T:Eq, V: Vector<T>> Equiv<V> for ~[T] { + impl<'a,T:Eq, V: Vector<T>> Equiv<V> for ~[T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } - impl<'self,T:Eq, V: Vector<T>> Equiv<V> for @[T] { + impl<'a,T:Eq, V: Vector<T>> Equiv<V> for @[T] { #[inline] fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } } - impl<'self,T:TotalOrd> TotalOrd for &'self [T] { - fn cmp(&self, other: & &'self [T]) -> Ordering { + impl<'a,T:TotalOrd> TotalOrd for &'a [T] { + fn cmp(&self, other: & &'a [T]) -> Ordering { order::cmp(self.iter(), other.iter()) } } @@ -689,20 +689,20 @@ pub mod traits { fn cmp(&self, other: &@[T]) -> Ordering { self.as_slice().cmp(&other.as_slice()) } } - impl<'self, T: Eq + Ord> Ord for &'self [T] { - fn lt(&self, other: & &'self [T]) -> bool { + impl<'a, T: Eq + Ord> Ord for &'a [T] { + fn lt(&self, other: & &'a [T]) -> bool { order::lt(self.iter(), other.iter()) } #[inline] - fn le(&self, other: & &'self [T]) -> bool { + fn le(&self, other: & &'a [T]) -> bool { order::le(self.iter(), other.iter()) } #[inline] - fn ge(&self, other: & &'self [T]) -> bool { + fn ge(&self, other: & &'a [T]) -> bool { order::ge(self.iter(), other.iter()) } #[inline] - fn gt(&self, other: & &'self [T]) -> bool { + fn gt(&self, other: & &'a [T]) -> bool { order::gt(self.iter(), other.iter()) } } @@ -729,7 +729,7 @@ pub mod traits { fn gt(&self, other: &@[T]) -> bool { self.as_slice() > other.as_slice() } } - impl<'self,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'self [T] { + impl<'a,T:Clone, V: Vector<T>> Add<V, ~[T]> for &'a [T] { #[inline] fn add(&self, rhs: &V) -> ~[T] { let mut res = with_capacity(self.len() + rhs.as_slice().len()); @@ -756,7 +756,7 @@ pub trait Vector<T> { fn as_slice<'a>(&'a self) -> &'a [T]; } -impl<'self,T> Vector<T> for &'self [T] { +impl<'a,T> Vector<T> for &'a [T] { #[inline(always)] fn as_slice<'a>(&'a self) -> &'a [T] { *self } } @@ -771,7 +771,7 @@ impl<T> Vector<T> for @[T] { fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v } } -impl<'self, T> Container for &'self [T] { +impl<'a, T> Container for &'a [T] { /// Returns the length of a vector #[inline] fn len(&self) -> uint { @@ -797,7 +797,7 @@ pub trait CopyableVector<T> { } /// Extension methods for vector slices -impl<'self, T: Clone> CopyableVector<T> for &'self [T] { +impl<'a, T: Clone> CopyableVector<T> for &'a [T] { /// Returns a copy of `v`. #[inline] fn to_owned(&self) -> ~[T] { @@ -831,52 +831,52 @@ impl<T: Clone> CopyableVector<T> for @[T] { } /// Extension methods for vectors -pub trait ImmutableVector<'self, T> { +pub trait ImmutableVector<'a, T> { /** * Returns a slice of self between `start` and `end`. * * Fails when `start` or `end` point outside the bounds of self, * or when `start` > `end`. */ - fn slice(&self, start: uint, end: uint) -> &'self [T]; + fn slice(&self, start: uint, end: uint) -> &'a [T]; /** * Returns a slice of self from `start` to the end of the vec. * * Fails when `start` points outside the bounds of self. */ - fn slice_from(&self, start: uint) -> &'self [T]; + fn slice_from(&self, start: uint) -> &'a [T]; /** * Returns a slice of self from the start of the vec to `end`. * * Fails when `end` points outside the bounds of self. */ - fn slice_to(&self, end: uint) -> &'self [T]; + fn slice_to(&self, end: uint) -> &'a [T]; /// Returns an iterator over the vector - fn iter(self) -> VecIterator<'self, T>; + fn iter(self) -> VecIterator<'a, T>; /// Returns a reversed iterator over a vector - fn rev_iter(self) -> RevIterator<'self, T>; + fn rev_iter(self) -> RevIterator<'a, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. The matched element /// is not contained in the subslices. - fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>; + fn split(self, pred: 'a |&T| -> bool) -> SplitIterator<'a, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`, limited to splitting /// at most `n` times. The matched element is not contained in /// the subslices. - fn splitn(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>; + fn splitn(self, n: uint, pred: 'a |&T| -> bool) -> SplitIterator<'a, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred`. This starts at the /// end of the vector and works backwards. The matched element is /// not contained in the subslices. - fn rsplit(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>; + fn rsplit(self, pred: 'a |&T| -> bool) -> RSplitIterator<'a, T>; /// Returns an iterator over the subslices of the vector which are /// separated by elements that match `pred` limited to splitting /// at most `n` times. This starts at the end of the vector and /// works backwards. The matched element is not contained in the /// subslices. - fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>; + fn rsplitn(self, n: uint, pred: 'a |&T| -> bool) -> RSplitIterator<'a, T>; /** * Returns an iterator over all contiguous windows of length @@ -900,7 +900,7 @@ pub trait ImmutableVector<'self, T> { * ``` * */ - fn windows(self, size: uint) -> WindowIter<'self, T>; + fn windows(self, size: uint) -> WindowIter<'a, T>; /** * * Returns an iterator over `size` elements of the vector at a @@ -925,27 +925,27 @@ pub trait ImmutableVector<'self, T> { * ``` * */ - fn chunks(self, size: uint) -> ChunkIter<'self, T>; + fn chunks(self, size: uint) -> ChunkIter<'a, T>; /// Returns the element of a vector at the given index, or `None` if the /// index is out of bounds - fn get_opt(&self, index: uint) -> Option<&'self T>; + fn get_opt(&self, index: uint) -> Option<&'a T>; /// Returns the first element of a vector, failing if the vector is empty. - fn head(&self) -> &'self T; + fn head(&self) -> &'a T; /// Returns the first element of a vector, or `None` if it is empty - fn head_opt(&self) -> Option<&'self T>; + fn head_opt(&self) -> Option<&'a T>; /// Returns all but the first element of a vector - fn tail(&self) -> &'self [T]; + fn tail(&self) -> &'a [T]; /// Returns all but the first `n' elements of a vector - fn tailn(&self, n: uint) -> &'self [T]; + fn tailn(&self, n: uint) -> &'a [T]; /// Returns all but the last element of a vector - fn init(&self) -> &'self [T]; + fn init(&self) -> &'a [T]; /// Returns all but the last `n' elemnts of a vector - fn initn(&self, n: uint) -> &'self [T]; + fn initn(&self, n: uint) -> &'a [T]; /// Returns the last element of a vector, failing if the vector is empty. - fn last(&self) -> &'self T; + fn last(&self) -> &'a T; /// Returns the last element of a vector, or `None` if it is empty. - fn last_opt(&self) -> Option<&'self T>; + fn last_opt(&self) -> Option<&'a T>; /** * Apply a function to each element of a vector and return a concatenation * of each result vector @@ -995,7 +995,7 @@ pub trait ImmutableVector<'self, T> { * * Fails if slice is empty. */ - fn shift_ref(&mut self) -> &'self T; + fn shift_ref(&mut self) -> &'a T; /** * Returns a mutable reference to the last element in this slice @@ -1012,12 +1012,12 @@ pub trait ImmutableVector<'self, T> { * * Fails if slice is empty. */ - fn pop_ref(&mut self) -> &'self T; + fn pop_ref(&mut self) -> &'a T; } -impl<'self,T> ImmutableVector<'self, T> for &'self [T] { +impl<'a,T> ImmutableVector<'a, T> for &'a [T] { #[inline] - fn slice(&self, start: uint, end: uint) -> &'self [T] { + fn slice(&self, start: uint, end: uint) -> &'a [T] { assert!(start <= end); assert!(end <= self.len()); self.as_imm_buf(|p, _len| { @@ -1031,17 +1031,17 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn slice_from(&self, start: uint) -> &'self [T] { + fn slice_from(&self, start: uint) -> &'a [T] { self.slice(start, self.len()) } #[inline] - fn slice_to(&self, end: uint) -> &'self [T] { + fn slice_to(&self, end: uint) -> &'a [T] { self.slice(0, end) } #[inline] - fn iter(self) -> VecIterator<'self, T> { + fn iter(self) -> VecIterator<'a, T> { unsafe { let p = vec::raw::to_ptr(self); if mem::size_of::<T>() == 0 { @@ -1057,17 +1057,17 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn rev_iter(self) -> RevIterator<'self, T> { + fn rev_iter(self) -> RevIterator<'a, T> { self.iter().invert() } #[inline] - fn split(self, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { + fn split(self, pred: 'a |&T| -> bool) -> SplitIterator<'a, T> { self.splitn(uint::max_value, pred) } #[inline] - fn splitn(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T> { + fn splitn(self, n: uint, pred: 'a |&T| -> bool) -> SplitIterator<'a, T> { SplitIterator { v: self, n: n, @@ -1077,12 +1077,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn rsplit(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { + fn rsplit(self, pred: 'a |&T| -> bool) -> RSplitIterator<'a, T> { self.rsplitn(uint::max_value, pred) } #[inline] - fn rsplitn(self, n: uint, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T> { + fn rsplitn(self, n: uint, pred: 'a |&T| -> bool) -> RSplitIterator<'a, T> { RSplitIterator { v: self, n: n, @@ -1092,57 +1092,57 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { } #[inline] - fn windows(self, size: uint) -> WindowIter<'self, T> { + fn windows(self, size: uint) -> WindowIter<'a, T> { assert!(size != 0); WindowIter { v: self, size: size } } #[inline] - fn chunks(self, size: uint) -> ChunkIter<'self, T> { + fn chunks(self, size: uint) -> ChunkIter<'a, T> { assert!(size != 0); ChunkIter { v: self, size: size } } #[inline] - fn get_opt(&self, index: uint) -> Option<&'self T> { + fn get_opt(&self, index: uint) -> Option<&'a T> { if index < self.len() { Some(&self[index]) } else { None } } #[inline] - fn head(&self) -> &'self T { + fn head(&self) -> &'a T { if self.len() == 0 { fail!("head: empty vector") } &self[0] } #[inline] - fn head_opt(&self) -> Option<&'self T> { + fn head_opt(&self) -> Option<&'a T> { if self.len() == 0 { None } else { Some(&self[0]) } } #[inline] - fn tail(&self) -> &'self [T] { self.slice(1, self.len()) } + fn tail(&self) -> &'a [T] { self.slice(1, self.len()) } #[inline] - fn tailn(&self, n: uint) -> &'self [T] { self.slice(n, self.len()) } + fn tailn(&self, n: uint) -> &'a [T] { self.slice(n, self.len()) } #[inline] - fn init(&self) -> &'self [T] { + fn init(&self) -> &'a [T] { self.slice(0, self.len() - 1) } #[inline] - fn initn(&self, n: uint) -> &'self [T] { + fn initn(&self, n: uint) -> &'a [T] { self.slice(0, self.len() - n) } #[inline] - fn last(&self) -> &'self T { + fn last(&self) -> &'a T { if self.len() == 0 { fail!("last: empty vector") } &self[self.len() - 1] } #[inline] - fn last_opt(&self) -> Option<&'self T> { + fn last_opt(&self) -> Option<&'a T> { if self.len() == 0 { None } else { Some(&self[self.len() - 1]) } } @@ -1185,14 +1185,14 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { f(s.data, s.len) } - fn shift_ref(&mut self) -> &'self T { + fn shift_ref(&mut self) -> &'a T { unsafe { let s: &mut Slice<T> = cast::transmute(self); &*raw::shift_ptr(s) } } - fn pop_ref(&mut self) -> &'self T { + fn pop_ref(&mut self) -> &'a T { unsafe { let s: &mut Slice<T> = cast::transmute(self); &*raw::pop_ptr(s) @@ -1218,7 +1218,7 @@ pub trait ImmutableEqVector<T:Eq> { fn ends_with(&self, needle: &[T]) -> bool; } -impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] { +impl<'a,T:Eq> ImmutableEqVector<T> for &'a [T] { #[inline] fn position_elem(&self, x: &T) -> Option<uint> { self.iter().position(|y| *x == *y) @@ -1257,7 +1257,7 @@ pub trait ImmutableTotalOrdVector<T: TotalOrd> { fn bsearch_elem(&self, x: &T) -> Option<uint>; } -impl<'self, T: TotalOrd> ImmutableTotalOrdVector<T> for &'self [T] { +impl<'a, T: TotalOrd> ImmutableTotalOrdVector<T> for &'a [T] { fn bsearch_elem(&self, x: &T) -> Option<uint> { self.bsearch(|p| p.cmp(x)) } @@ -1278,7 +1278,7 @@ pub trait ImmutableCopyableVector<T> { fn permutations(self) -> Permutations<T>; } -impl<'self,T:Clone> ImmutableCopyableVector<T> for &'self [T] { +impl<'a,T:Clone> ImmutableCopyableVector<T> for &'a [T] { #[inline] fn partitioned(&self, f: |&T| -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; @@ -1913,34 +1913,34 @@ impl<T:Eq> OwnedEqVector<T> for ~[T] { /// Extension methods for vectors such that their elements are /// mutable. -pub trait MutableVector<'self, T> { +pub trait MutableVector<'a, T> { /// Return a slice that points into another slice. - fn mut_slice(self, start: uint, end: uint) -> &'self mut [T]; + fn mut_slice(self, start: uint, end: uint) -> &'a mut [T]; /** * Returns a slice of self from `start` to the end of the vec. * * Fails when `start` points outside the bounds of self. */ - fn mut_slice_from(self, start: uint) -> &'self mut [T]; + fn mut_slice_from(self, start: uint) -> &'a mut [T]; /** * Returns a slice of self from the start of the vec to `end`. * * Fails when `end` points outside the bounds of self. */ - fn mut_slice_to(self, end: uint) -> &'self mut [T]; + fn mut_slice_to(self, end: uint) -> &'a mut [T]; /// Returns an iterator that allows modifying each value - fn mut_iter(self) -> VecMutIterator<'self, T>; + fn mut_iter(self) -> VecMutIterator<'a, T>; /// Returns a reversed iterator that allows modifying each value - fn mut_rev_iter(self) -> MutRevIterator<'self, T>; + fn mut_rev_iter(self) -> MutRevIterator<'a, T>; /// Returns an iterator over the mutable subslices of the vector /// which are separated by elements that match `pred`. The /// matched element is not contained in the subslices. - fn mut_split(self, pred: 'self |&T| -> bool) -> MutSplitIterator<'self, T>; + fn mut_split(self, pred: 'a |&T| -> bool) -> MutSplitIterator<'a, T>; /** * Returns an iterator over `size` elements of the vector at a time. @@ -1952,7 +1952,7 @@ pub trait MutableVector<'self, T> { * * Fails if `size` is 0. */ - fn mut_chunks(self, chunk_size: uint) -> MutChunkIter<'self, T>; + fn mut_chunks(self, chunk_size: uint) -> MutChunkIter<'a, T>; /** * Returns a mutable reference to the first element in this slice @@ -1969,7 +1969,7 @@ pub trait MutableVector<'self, T> { * * Fails if slice is empty. */ - fn mut_shift_ref(&mut self) -> &'self mut T; + fn mut_shift_ref(&mut self) -> &'a mut T; /** * Returns a mutable reference to the last element in this slice @@ -1986,7 +1986,7 @@ pub trait MutableVector<'self, T> { * * Fails if slice is empty. */ - fn mut_pop_ref(&mut self) -> &'self mut T; + fn mut_pop_ref(&mut self) -> &'a mut T; /** * Swaps two elements in a vector @@ -2004,8 +2004,8 @@ pub trait MutableVector<'self, T> { * itself) and the second will contain all indices from * `mid..len` (excluding the index `len` itself). */ - fn mut_split_at(self, mid: uint) -> (&'self mut [T], - &'self mut [T]); + fn mut_split_at(self, mid: uint) -> (&'a mut [T], + &'a mut [T]); /// Reverse the order of elements in a vector, in place fn reverse(self); @@ -2034,9 +2034,9 @@ pub trait MutableVector<'self, T> { fn as_mut_buf<U>(self, f: |*mut T, uint| -> U) -> U; } -impl<'self,T> MutableVector<'self, T> for &'self mut [T] { +impl<'a,T> MutableVector<'a, T> for &'a mut [T] { #[inline] - fn mut_slice(self, start: uint, end: uint) -> &'self mut [T] { + fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { assert!(start <= end); assert!(end <= self.len()); self.as_mut_buf(|p, _len| { @@ -2050,27 +2050,27 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] { } #[inline] - fn mut_slice_from(self, start: uint) -> &'self mut [T] { + fn mut_slice_from(self, start: uint) -> &'a mut [T] { let len = self.len(); self.mut_slice(start, len) } #[inline] - fn mut_slice_to(self, end: uint) -> &'self mut [T] { + fn mut_slice_to(self, end: uint) -> &'a mut [T] { self.mut_slice(0, end) } #[inline] - fn mut_split_at(self, mid: uint) -> (&'self mut [T], &'self mut [T]) { + fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { unsafe { let len = self.len(); - let self2: &'self mut [T] = cast::transmute_copy(&self); + let self2: &'a mut [T] = cast::transmute_copy(&self); (self.mut_slice(0, mid), self2.mut_slice(mid, len)) } } #[inline] - fn mut_iter(self) -> VecMutIterator<'self, T> { + fn mut_iter(self) -> VecMutIterator<'a, T> { unsafe { let p = vec::raw::to_mut_ptr(self); if mem::size_of::<T>() == 0 { @@ -2086,30 +2086,30 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] { } #[inline] - fn mut_rev_iter(self) -> MutRevIterator<'self, T> { + fn mut_rev_iter(self) -> MutRevIterator<'a, T> { self.mut_iter().invert() } #[inline] - fn mut_split(self, pred: 'self |&T| -> bool) -> MutSplitIterator<'self, T> { + fn mut_split(self, pred: 'a |&T| -> bool) -> MutSplitIterator<'a, T> { MutSplitIterator { v: self, pred: pred, finished: false } } #[inline] - fn mut_chunks(self, chunk_size: uint) -> MutChunkIter<'self, T> { + fn mut_chunks(self, chunk_size: uint) -> MutChunkIter<'a, T> { assert!(chunk_size > 0); let len = self.len(); MutChunkIter { v: self, chunk_size: chunk_size, remaining: len } } - fn mut_shift_ref(&mut self) -> &'self mut T { + fn mut_shift_ref(&mut self) -> &'a mut T { unsafe { let s: &mut Slice<T> = cast::transmute(self); cast::transmute_mut(&*raw::shift_ptr(s)) } } - fn mut_pop_ref(&mut self) -> &'self mut T { + fn mut_pop_ref(&mut self) -> &'a mut T { unsafe { let s: &mut Slice<T> = cast::transmute(self); cast::transmute_mut(&*raw::pop_ptr(s)) @@ -2167,7 +2167,7 @@ pub trait MutableCloneableVector<T> { fn copy_from(self, &[T]) -> uint; } -impl<'self, T:Clone> MutableCloneableVector<T> for &'self mut [T] { +impl<'a, T:Clone> MutableCloneableVector<T> for &'a mut [T] { #[inline] fn copy_from(self, src: &[T]) -> uint { for (a, b) in self.mut_iter().zip(src.iter()) { @@ -2368,7 +2368,7 @@ pub mod bytes { fn set_memory(self, value: u8); } - impl<'self> MutableByteVector for &'self mut [u8] { + impl<'a> MutableByteVector for &'a mut [u8] { #[inline] fn set_memory(self, value: u8) { self.as_mut_buf(|p, len| { @@ -2483,8 +2483,8 @@ impl<A: DeepClone> DeepClone for ~[A] { } // This works because every lifetime is a sub-lifetime of 'static -impl<'self, A> Default for &'self [A] { - fn default() -> &'self [A] { &'self [] } +impl<'a, A> Default for &'a [A] { + fn default() -> &'a [A] { &'a [] } } impl<A> Default for ~[A] { @@ -2498,13 +2498,13 @@ impl<A> Default for @[A] { macro_rules! iterator { (struct $name:ident -> $ptr:ty, $elem:ty) => { /// An iterator for iterating over a vector. - pub struct $name<'self, T> { + pub struct $name<'a, T> { priv ptr: $ptr, priv end: $ptr, priv lifetime: Option<$elem> // FIXME: #5922 } - impl<'self, T> Iterator<$elem> for $name<'self, T> { + impl<'a, T> Iterator<$elem> for $name<'a, T> { #[inline] fn next(&mut self) -> Option<$elem> { // could be implemented with slices, but this avoids bounds checks @@ -2535,7 +2535,7 @@ macro_rules! iterator { } } - impl<'self, T> DoubleEndedIterator<$elem> for $name<'self, T> { + impl<'a, T> DoubleEndedIterator<$elem> for $name<'a, T> { #[inline] fn next_back(&mut self) -> Option<$elem> { // could be implemented with slices, but this avoids bounds checks @@ -2557,7 +2557,7 @@ macro_rules! iterator { } } -impl<'self, T> RandomAccessIterator<&'self T> for VecIterator<'self, T> { +impl<'a, T> RandomAccessIterator<&'a T> for VecIterator<'a, T> { #[inline] fn indexable(&self) -> uint { let (exact, _) = self.size_hint(); @@ -2565,7 +2565,7 @@ impl<'self, T> RandomAccessIterator<&'self T> for VecIterator<'self, T> { } #[inline] - fn idx(&self, index: uint) -> Option<&'self T> { + fn idx(&self, index: uint) -> Option<&'a T> { unsafe { if index < self.indexable() { cast::transmute(self.ptr.offset(index as int)) @@ -2576,30 +2576,30 @@ impl<'self, T> RandomAccessIterator<&'self T> for VecIterator<'self, T> { } } -iterator!{struct VecIterator -> *T, &'self T} -pub type RevIterator<'self, T> = Invert<VecIterator<'self, T>>; +iterator!{struct VecIterator -> *T, &'a T} +pub type RevIterator<'a, T> = Invert<VecIterator<'a, T>>; -impl<'self, T> ExactSize<&'self T> for VecIterator<'self, T> {} -impl<'self, T> ExactSize<&'self mut T> for VecMutIterator<'self, T> {} +impl<'a, T> ExactSize<&'a T> for VecIterator<'a, T> {} +impl<'a, T> ExactSize<&'a mut T> for VecMutIterator<'a, T> {} -impl<'self, T> Clone for VecIterator<'self, T> { - fn clone(&self) -> VecIterator<'self, T> { *self } +impl<'a, T> Clone for VecIterator<'a, T> { + fn clone(&self) -> VecIterator<'a, T> { *self } } -iterator!{struct VecMutIterator -> *mut T, &'self mut T} -pub type MutRevIterator<'self, T> = Invert<VecMutIterator<'self, T>>; +iterator!{struct VecMutIterator -> *mut T, &'a mut T} +pub type MutRevIterator<'a, T> = Invert<VecMutIterator<'a, T>>; /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`. -pub struct MutSplitIterator<'self, T> { - priv v: &'self mut [T], - priv pred: 'self |t: &T| -> bool, +pub struct MutSplitIterator<'a, T> { + priv v: &'a mut [T], + priv pred: 'a |t: &T| -> bool, priv finished: bool } -impl<'self, T> Iterator<&'self mut [T]> for MutSplitIterator<'self, T> { +impl<'a, T> Iterator<&'a mut [T]> for MutSplitIterator<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self mut [T]> { + fn next(&mut self) -> Option<&'a mut [T]> { if self.finished { return None; } match self.v.iter().position(|x| (self.pred)(x)) { @@ -2632,9 +2632,9 @@ impl<'self, T> Iterator<&'self mut [T]> for MutSplitIterator<'self, T> { } } -impl<'self, T> DoubleEndedIterator<&'self mut [T]> for MutSplitIterator<'self, T> { +impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplitIterator<'a, T> { #[inline] - fn next_back(&mut self) -> Option<&'self mut [T]> { + fn next_back(&mut self) -> Option<&'a mut [T]> { if self.finished { return None; } match self.v.iter().rposition(|x| (self.pred)(x)) { @@ -2659,15 +2659,15 @@ impl<'self, T> DoubleEndedIterator<&'self mut [T]> for MutSplitIterator<'self, T /// An iterator over a vector in (non-overlapping) mutable chunks (`size` elements at a time). When /// the vector len is not evenly divided by the chunk size, the last slice of the iteration will be /// the remainder. -pub struct MutChunkIter<'self, T> { - priv v: &'self mut [T], +pub struct MutChunkIter<'a, T> { + priv v: &'a mut [T], priv chunk_size: uint, priv remaining: uint } -impl<'self, T> Iterator<&'self mut [T]> for MutChunkIter<'self, T> { +impl<'a, T> Iterator<&'a mut [T]> for MutChunkIter<'a, T> { #[inline] - fn next(&mut self) -> Option<&'self mut [T]> { + fn next(&mut self) -> Option<&'a mut [T]> { if self.remaining == 0 { None } else { @@ -2692,9 +2692,9 @@ impl<'self, T> Iterator<&'self mut [T]> for MutChunkIter<'self, T> { } } -impl<'self, T> DoubleEndedIterator<&'self mut [T]> for MutChunkIter<'self, T> { +impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutChunkIter<'a, T> { #[inline] - fn next_back(&mut self) -> Option<&'self mut [T]> { + fn next_back(&mut self) -> Option<&'a mut [T]> { if self.remaining == 0 { None } else { |
