mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
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`
This commit is contained in:
commit
1b12dca7f9
10
doc/rust.md
10
doc/rust.md
@ -1239,9 +1239,9 @@ static BIT2: uint = 1 << 1;
|
||||
static BITS: [uint, ..2] = [BIT1, BIT2];
|
||||
static STRING: &'static str = "bitstring";
|
||||
|
||||
struct BitsNStrings<'self> {
|
||||
struct BitsNStrings<'a> {
|
||||
mybits: [uint, ..2],
|
||||
mystring: &'self str
|
||||
mystring: &'a str
|
||||
}
|
||||
|
||||
static bits_n_strings: BitsNStrings<'static> = BitsNStrings {
|
||||
@ -2281,7 +2281,7 @@ The following are examples of structure expressions:
|
||||
~~~~
|
||||
# struct Point { x: f64, y: f64 }
|
||||
# struct TuplePoint(f64, f64);
|
||||
# mod game { pub struct User<'self> { name: &'self str, age: uint, score: uint } }
|
||||
# mod game { pub struct User<'a> { name: &'a str, age: uint, score: uint } }
|
||||
# struct Cookie; fn some_fn<T>(t: T) {}
|
||||
Point {x: 10.0, y: 20.0};
|
||||
TuplePoint(10.0, 20.0);
|
||||
@ -3055,7 +3055,7 @@ order specified by the tuple type.
|
||||
An example of a tuple type and its use:
|
||||
|
||||
~~~~
|
||||
type Pair<'self> = (int,&'self str);
|
||||
type Pair<'a> = (int,&'a str);
|
||||
let p: Pair<'static> = (10,"hello");
|
||||
let (a, b) = p;
|
||||
assert!(b != "world");
|
||||
@ -3220,7 +3220,7 @@ fn add(x: int, y: int) -> int {
|
||||
|
||||
let mut x = add(5,7);
|
||||
|
||||
type Binop<'self> = 'self |int,int| -> int;
|
||||
type Binop<'a> = 'a |int,int| -> int;
|
||||
let bo: Binop = add;
|
||||
x = bo(5,7);
|
||||
~~~~
|
||||
|
@ -49,13 +49,13 @@ use std::task;
|
||||
use std::borrow;
|
||||
|
||||
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
|
||||
pub struct Condvar<'self> {
|
||||
pub struct Condvar<'a> {
|
||||
priv is_mutex: bool,
|
||||
priv failed: &'self mut bool,
|
||||
priv cond: &'self sync::Condvar<'self>
|
||||
priv failed: &'a mut bool,
|
||||
priv cond: &'a sync::Condvar<'a>
|
||||
}
|
||||
|
||||
impl<'self> Condvar<'self> {
|
||||
impl<'a> Condvar<'a> {
|
||||
/// Atomically exit the associated Arc and block until a signal is sent.
|
||||
#[inline]
|
||||
pub fn wait(&self) { self.wait_on(0) }
|
||||
@ -523,19 +523,19 @@ fn borrow_rwlock<T:Freeze + Send>(state: *mut RWArcInner<T>) -> *RWLock {
|
||||
}
|
||||
|
||||
/// The "write permission" token used for RWArc.write_downgrade().
|
||||
pub struct RWWriteMode<'self, T> {
|
||||
priv data: &'self mut T,
|
||||
priv token: sync::RWLockWriteMode<'self>,
|
||||
pub struct RWWriteMode<'a, T> {
|
||||
priv data: &'a mut T,
|
||||
priv token: sync::RWLockWriteMode<'a>,
|
||||
priv poison: PoisonOnFail,
|
||||
}
|
||||
|
||||
/// The "read permission" token used for RWArc.write_downgrade().
|
||||
pub struct RWReadMode<'self, T> {
|
||||
priv data: &'self T,
|
||||
priv token: sync::RWLockReadMode<'self>,
|
||||
pub struct RWReadMode<'a, T> {
|
||||
priv data: &'a T,
|
||||
priv token: sync::RWLockReadMode<'a>,
|
||||
}
|
||||
|
||||
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
|
||||
impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
|
||||
/// Access the pre-downgrade RWArc in write mode.
|
||||
pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
|
||||
match *self {
|
||||
@ -574,7 +574,7 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
|
||||
impl<'a, T:Freeze + Send> RWReadMode<'a, T> {
|
||||
/// Access the post-downgrade rwlock in read mode.
|
||||
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
|
||||
match *self {
|
||||
|
@ -56,7 +56,7 @@ pub trait ToBase64 {
|
||||
fn to_base64(&self, config: Config) -> ~str;
|
||||
}
|
||||
|
||||
impl<'self> ToBase64 for &'self [u8] {
|
||||
impl<'a> ToBase64 for &'a [u8] {
|
||||
/**
|
||||
* Turn a vector of `u8` bytes into a base64 string.
|
||||
*
|
||||
@ -157,7 +157,7 @@ pub trait FromBase64 {
|
||||
fn from_base64(&self) -> Result<~[u8], ~str>;
|
||||
}
|
||||
|
||||
impl<'self> FromBase64 for &'self str {
|
||||
impl<'a> FromBase64 for &'a str {
|
||||
/**
|
||||
* Convert any base64 encoded string (literal, `@`, `&`, or `~`)
|
||||
* to the byte values it encodes.
|
||||
|
@ -578,13 +578,13 @@ fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
|
||||
}
|
||||
|
||||
/// An iterator for `Bitv`.
|
||||
pub struct BitvIterator<'self> {
|
||||
priv bitv: &'self Bitv,
|
||||
pub struct BitvIterator<'a> {
|
||||
priv bitv: &'a Bitv,
|
||||
priv next_idx: uint,
|
||||
priv end_idx: uint,
|
||||
}
|
||||
|
||||
impl<'self> Iterator<bool> for BitvIterator<'self> {
|
||||
impl<'a> Iterator<bool> for BitvIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<bool> {
|
||||
if self.next_idx != self.end_idx {
|
||||
@ -602,7 +602,7 @@ impl<'self> Iterator<bool> for BitvIterator<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> DoubleEndedIterator<bool> for BitvIterator<'self> {
|
||||
impl<'a> DoubleEndedIterator<bool> for BitvIterator<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<bool> {
|
||||
if self.next_idx != self.end_idx {
|
||||
@ -614,9 +614,9 @@ impl<'self> DoubleEndedIterator<bool> for BitvIterator<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> ExactSize<bool> for BitvIterator<'self> {}
|
||||
impl<'a> ExactSize<bool> for BitvIterator<'a> {}
|
||||
|
||||
impl<'self> RandomAccessIterator<bool> for BitvIterator<'self> {
|
||||
impl<'a> RandomAccessIterator<bool> for BitvIterator<'a> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint {
|
||||
self.end_idx - self.next_idx
|
||||
@ -903,12 +903,12 @@ impl BitvSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BitvSetIterator<'self> {
|
||||
priv set: &'self BitvSet,
|
||||
pub struct BitvSetIterator<'a> {
|
||||
priv set: &'a BitvSet,
|
||||
priv next_idx: uint
|
||||
}
|
||||
|
||||
impl<'self> Iterator<uint> for BitvSetIterator<'self> {
|
||||
impl<'a> Iterator<uint> for BitvSetIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<uint> {
|
||||
while self.next_idx < self.set.capacity() {
|
||||
|
@ -48,15 +48,15 @@ struct Node<T> {
|
||||
|
||||
/// Double-ended DList iterator
|
||||
#[deriving(Clone)]
|
||||
pub struct DListIterator<'self, T> {
|
||||
priv head: &'self Link<T>,
|
||||
pub struct DListIterator<'a, T> {
|
||||
priv head: &'a Link<T>,
|
||||
priv tail: Rawlink<Node<T>>,
|
||||
priv nelem: uint,
|
||||
}
|
||||
|
||||
/// Double-ended mutable DList iterator
|
||||
pub struct MutDListIterator<'self, T> {
|
||||
priv list: &'self mut DList<T>,
|
||||
pub struct MutDListIterator<'a, T> {
|
||||
priv list: &'a mut DList<T>,
|
||||
priv head: Rawlink<Node<T>>,
|
||||
priv tail: Rawlink<Node<T>>,
|
||||
priv nelem: uint,
|
||||
@ -439,9 +439,9 @@ impl<T> Drop for DList<T> {
|
||||
}
|
||||
|
||||
|
||||
impl<'self, A> Iterator<&'self A> for DListIterator<'self, A> {
|
||||
impl<'a, A> Iterator<&'a A> for DListIterator<'a, A> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self A> {
|
||||
fn next(&mut self) -> Option<&'a A> {
|
||||
if self.nelem == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -458,9 +458,9 @@ impl<'self, A> Iterator<&'self A> for DListIterator<'self, A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
|
||||
impl<'a, A> DoubleEndedIterator<&'a A> for DListIterator<'a, A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'self A> {
|
||||
fn next_back(&mut self) -> Option<&'a A> {
|
||||
if self.nelem == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -473,11 +473,11 @@ impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> ExactSize<&'self A> for DListIterator<'self, A> {}
|
||||
impl<'a, A> ExactSize<&'a A> for DListIterator<'a, A> {}
|
||||
|
||||
impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
|
||||
impl<'a, A> Iterator<&'a mut A> for MutDListIterator<'a, A> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self mut A> {
|
||||
fn next(&mut self) -> Option<&'a mut A> {
|
||||
if self.nelem == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -497,9 +497,9 @@ impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A> {
|
||||
impl<'a, A> DoubleEndedIterator<&'a mut A> for MutDListIterator<'a, A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'self mut A> {
|
||||
fn next_back(&mut self) -> Option<&'a mut A> {
|
||||
if self.nelem == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -511,7 +511,7 @@ impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> ExactSize<&'self mut A> for MutDListIterator<'self, A> {}
|
||||
impl<'a, A> ExactSize<&'a mut A> for MutDListIterator<'a, A> {}
|
||||
|
||||
/// Allow mutating the DList while iterating
|
||||
pub trait ListInsertion<A> {
|
||||
@ -525,7 +525,7 @@ pub trait ListInsertion<A> {
|
||||
}
|
||||
|
||||
// private methods for MutDListIterator
|
||||
impl<'self, A> MutDListIterator<'self, A> {
|
||||
impl<'a, A> MutDListIterator<'a, A> {
|
||||
fn insert_next_node(&mut self, mut ins_node: ~Node<A>) {
|
||||
// Insert before `self.head` so that it is between the
|
||||
// previously yielded element and self.head.
|
||||
@ -547,7 +547,7 @@ impl<'self, A> MutDListIterator<'self, A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
|
||||
impl<'a, A> ListInsertion<A> for MutDListIterator<'a, A> {
|
||||
#[inline]
|
||||
fn insert_next(&mut self, elt: A) {
|
||||
self.insert_next_node(~Node::new(elt))
|
||||
|
@ -21,7 +21,7 @@ pub trait ToHex {
|
||||
|
||||
static CHARS: &'static[u8] = bytes!("0123456789abcdef");
|
||||
|
||||
impl<'self> ToHex for &'self [u8] {
|
||||
impl<'a> ToHex for &'a [u8] {
|
||||
/**
|
||||
* Turn a vector of `u8` bytes into a hexadecimal string.
|
||||
*
|
||||
@ -57,7 +57,7 @@ pub trait FromHex {
|
||||
fn from_hex(&self) -> Result<~[u8], ~str>;
|
||||
}
|
||||
|
||||
impl<'self> FromHex for &'self str {
|
||||
impl<'a> FromHex for &'a str {
|
||||
/**
|
||||
* Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`)
|
||||
* to the byte values it encodes.
|
||||
|
@ -84,11 +84,11 @@ fn spaces(n: uint) -> ~str {
|
||||
}
|
||||
|
||||
/// A structure for implementing serialization to JSON.
|
||||
pub struct Encoder<'self> {
|
||||
priv wr: &'self mut io::Writer,
|
||||
pub struct Encoder<'a> {
|
||||
priv wr: &'a mut io::Writer,
|
||||
}
|
||||
|
||||
impl<'self> Encoder<'self> {
|
||||
impl<'a> Encoder<'a> {
|
||||
/// Creates a new JSON encoder whose output will be written to the writer
|
||||
/// specified.
|
||||
pub fn new<'a>(wr: &'a mut io::Writer) -> Encoder<'a> {
|
||||
@ -96,7 +96,7 @@ impl<'self> Encoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
impl<'a> serialize::Encoder for Encoder<'a> {
|
||||
fn emit_nil(&mut self) { write!(self.wr, "null") }
|
||||
|
||||
fn emit_uint(&mut self, v: uint) { self.emit_f64(v as f64); }
|
||||
@ -129,13 +129,13 @@ impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
write!(self.wr, "{}", escape_str(v))
|
||||
}
|
||||
|
||||
fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'self>|) { f(self) }
|
||||
fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'a>|) { f(self) }
|
||||
|
||||
fn emit_enum_variant(&mut self,
|
||||
name: &str,
|
||||
_id: uint,
|
||||
cnt: uint,
|
||||
f: |&mut Encoder<'self>|) {
|
||||
f: |&mut Encoder<'a>|) {
|
||||
// enums are encoded as strings or objects
|
||||
// Bunny => "Bunny"
|
||||
// Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
|
||||
@ -150,7 +150,7 @@ impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_enum_variant_arg(&mut self, idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_enum_variant_arg(&mut self, idx: uint, f: |&mut Encoder<'a>|) {
|
||||
if idx != 0 {
|
||||
write!(self.wr, ",");
|
||||
}
|
||||
@ -161,18 +161,18 @@ impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
name: &str,
|
||||
id: uint,
|
||||
cnt: uint,
|
||||
f: |&mut Encoder<'self>|) {
|
||||
f: |&mut Encoder<'a>|) {
|
||||
self.emit_enum_variant(name, id, cnt, f)
|
||||
}
|
||||
|
||||
fn emit_enum_struct_variant_field(&mut self,
|
||||
_: &str,
|
||||
idx: uint,
|
||||
f: |&mut Encoder<'self>|) {
|
||||
f: |&mut Encoder<'a>|) {
|
||||
self.emit_enum_variant_arg(idx, f)
|
||||
}
|
||||
|
||||
fn emit_struct(&mut self, _: &str, _: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_struct(&mut self, _: &str, _: uint, f: |&mut Encoder<'a>|) {
|
||||
write!(self.wr, r"\{");
|
||||
f(self);
|
||||
write!(self.wr, r"\}");
|
||||
@ -181,58 +181,58 @@ impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
fn emit_struct_field(&mut self,
|
||||
name: &str,
|
||||
idx: uint,
|
||||
f: |&mut Encoder<'self>|) {
|
||||
f: |&mut Encoder<'a>|) {
|
||||
if idx != 0 { write!(self.wr, ",") }
|
||||
write!(self.wr, "{}:", escape_str(name));
|
||||
f(self);
|
||||
}
|
||||
|
||||
fn emit_tuple(&mut self, len: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_tuple(&mut self, len: uint, f: |&mut Encoder<'a>|) {
|
||||
self.emit_seq(len, f)
|
||||
}
|
||||
fn emit_tuple_arg(&mut self, idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_tuple_arg(&mut self, idx: uint, f: |&mut Encoder<'a>|) {
|
||||
self.emit_seq_elt(idx, f)
|
||||
}
|
||||
|
||||
fn emit_tuple_struct(&mut self,
|
||||
_name: &str,
|
||||
len: uint,
|
||||
f: |&mut Encoder<'self>|) {
|
||||
f: |&mut Encoder<'a>|) {
|
||||
self.emit_seq(len, f)
|
||||
}
|
||||
fn emit_tuple_struct_arg(&mut self, idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_tuple_struct_arg(&mut self, idx: uint, f: |&mut Encoder<'a>|) {
|
||||
self.emit_seq_elt(idx, f)
|
||||
}
|
||||
|
||||
fn emit_option(&mut self, f: |&mut Encoder<'self>|) { f(self); }
|
||||
fn emit_option(&mut self, f: |&mut Encoder<'a>|) { f(self); }
|
||||
fn emit_option_none(&mut self) { self.emit_nil(); }
|
||||
fn emit_option_some(&mut self, f: |&mut Encoder<'self>|) { f(self); }
|
||||
fn emit_option_some(&mut self, f: |&mut Encoder<'a>|) { f(self); }
|
||||
|
||||
fn emit_seq(&mut self, _len: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_seq(&mut self, _len: uint, f: |&mut Encoder<'a>|) {
|
||||
write!(self.wr, "[");
|
||||
f(self);
|
||||
write!(self.wr, "]");
|
||||
}
|
||||
|
||||
fn emit_seq_elt(&mut self, idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_seq_elt(&mut self, idx: uint, f: |&mut Encoder<'a>|) {
|
||||
if idx != 0 {
|
||||
write!(self.wr, ",");
|
||||
}
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>|) {
|
||||
write!(self.wr, r"\{");
|
||||
f(self);
|
||||
write!(self.wr, r"\}");
|
||||
}
|
||||
|
||||
fn emit_map_elt_key(&mut self, idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_map_elt_key(&mut self, idx: uint, f: |&mut Encoder<'a>|) {
|
||||
if idx != 0 { write!(self.wr, ",") }
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut Encoder<'self>|) {
|
||||
fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut Encoder<'a>|) {
|
||||
write!(self.wr, ":");
|
||||
f(self)
|
||||
}
|
||||
@ -240,12 +240,12 @@ impl<'self> serialize::Encoder for Encoder<'self> {
|
||||
|
||||
/// Another encoder for JSON, but prints out human-readable JSON instead of
|
||||
/// compact data
|
||||
pub struct PrettyEncoder<'self> {
|
||||
priv wr: &'self mut io::Writer,
|
||||
pub struct PrettyEncoder<'a> {
|
||||
priv wr: &'a mut io::Writer,
|
||||
priv indent: uint,
|
||||
}
|
||||
|
||||
impl<'self> PrettyEncoder<'self> {
|
||||
impl<'a> PrettyEncoder<'a> {
|
||||
/// Creates a new encoder whose output will be written to the specified writer
|
||||
pub fn new<'a>(wr: &'a mut io::Writer) -> PrettyEncoder<'a> {
|
||||
PrettyEncoder {
|
||||
@ -255,7 +255,7 @@ impl<'self> PrettyEncoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
impl<'a> serialize::Encoder for PrettyEncoder<'a> {
|
||||
fn emit_nil(&mut self) { write!(self.wr, "null") }
|
||||
|
||||
fn emit_uint(&mut self, v: uint) { self.emit_f64(v as f64); }
|
||||
@ -286,7 +286,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) }
|
||||
fn emit_str(&mut self, v: &str) { write!(self.wr, "{}", escape_str(v)); }
|
||||
|
||||
fn emit_enum(&mut self, _name: &str, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_enum(&mut self, _name: &str, f: |&mut PrettyEncoder<'a>|) {
|
||||
f(self)
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
name: &str,
|
||||
_: uint,
|
||||
cnt: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
if cnt == 0 {
|
||||
write!(self.wr, "{}", escape_str(name));
|
||||
} else {
|
||||
@ -308,7 +308,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
|
||||
fn emit_enum_variant_arg(&mut self,
|
||||
idx: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
if idx != 0 {
|
||||
write!(self.wr, ",\n");
|
||||
}
|
||||
@ -320,14 +320,14 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
name: &str,
|
||||
id: uint,
|
||||
cnt: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_enum_variant(name, id, cnt, f)
|
||||
}
|
||||
|
||||
fn emit_enum_struct_variant_field(&mut self,
|
||||
_: &str,
|
||||
idx: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_enum_variant_arg(idx, f)
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
fn emit_struct(&mut self,
|
||||
_: &str,
|
||||
len: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
if len == 0 {
|
||||
write!(self.wr, "\\{\\}");
|
||||
} else {
|
||||
@ -350,7 +350,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
fn emit_struct_field(&mut self,
|
||||
name: &str,
|
||||
idx: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
if idx == 0 {
|
||||
write!(self.wr, "\n");
|
||||
} else {
|
||||
@ -360,30 +360,30 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
f(self);
|
||||
}
|
||||
|
||||
fn emit_tuple(&mut self, len: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_tuple(&mut self, len: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_seq(len, f)
|
||||
}
|
||||
fn emit_tuple_arg(&mut self, idx: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_tuple_arg(&mut self, idx: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_seq_elt(idx, f)
|
||||
}
|
||||
|
||||
fn emit_tuple_struct(&mut self,
|
||||
_: &str,
|
||||
len: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_seq(len, f)
|
||||
}
|
||||
fn emit_tuple_struct_arg(&mut self,
|
||||
idx: uint,
|
||||
f: |&mut PrettyEncoder<'self>|) {
|
||||
f: |&mut PrettyEncoder<'a>|) {
|
||||
self.emit_seq_elt(idx, f)
|
||||
}
|
||||
|
||||
fn emit_option(&mut self, f: |&mut PrettyEncoder<'self>|) { f(self); }
|
||||
fn emit_option(&mut self, f: |&mut PrettyEncoder<'a>|) { f(self); }
|
||||
fn emit_option_none(&mut self) { self.emit_nil(); }
|
||||
fn emit_option_some(&mut self, f: |&mut PrettyEncoder<'self>|) { f(self); }
|
||||
fn emit_option_some(&mut self, f: |&mut PrettyEncoder<'a>|) { f(self); }
|
||||
|
||||
fn emit_seq(&mut self, len: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_seq(&mut self, len: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
if len == 0 {
|
||||
write!(self.wr, "[]");
|
||||
} else {
|
||||
@ -395,7 +395,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_seq_elt(&mut self, idx: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_seq_elt(&mut self, idx: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
if idx == 0 {
|
||||
write!(self.wr, "\n");
|
||||
} else {
|
||||
@ -405,7 +405,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn emit_map(&mut self, len: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_map(&mut self, len: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
if len == 0 {
|
||||
write!(self.wr, "\\{\\}");
|
||||
} else {
|
||||
@ -417,7 +417,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_map_elt_key(&mut self, idx: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_map_elt_key(&mut self, idx: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
if idx == 0 {
|
||||
write!(self.wr, "\n");
|
||||
} else {
|
||||
@ -427,7 +427,7 @@ impl<'self> serialize::Encoder for PrettyEncoder<'self> {
|
||||
f(self);
|
||||
}
|
||||
|
||||
fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut PrettyEncoder<'self>|) {
|
||||
fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut PrettyEncoder<'a>|) {
|
||||
write!(self.wr, ": ");
|
||||
f(self);
|
||||
}
|
||||
|
@ -177,13 +177,13 @@ impl<T:Ord> PriorityQueue<T> {
|
||||
}
|
||||
|
||||
/// PriorityQueue iterator
|
||||
pub struct PriorityQueueIterator <'self, T> {
|
||||
priv iter: vec::VecIterator<'self, T>,
|
||||
pub struct PriorityQueueIterator <'a, T> {
|
||||
priv iter: vec::VecIterator<'a, T>,
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self T> for PriorityQueueIterator<'self, T> {
|
||||
impl<'a, T> Iterator<&'a T> for PriorityQueueIterator<'a, T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<(&'self T)> { self.iter.next() }
|
||||
fn next(&mut self) -> Option<(&'a T)> { self.iter.next() }
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
|
||||
|
@ -229,16 +229,16 @@ impl<T> RingBuf<T> {
|
||||
}
|
||||
|
||||
/// RingBuf iterator
|
||||
pub struct RingBufIterator<'self, T> {
|
||||
pub struct RingBufIterator<'a, T> {
|
||||
priv lo: uint,
|
||||
priv index: uint,
|
||||
priv rindex: uint,
|
||||
priv elts: &'self [Option<T>],
|
||||
priv elts: &'a [Option<T>],
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self T> for RingBufIterator<'self, T> {
|
||||
impl<'a, T> Iterator<&'a T> for RingBufIterator<'a, T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
if self.index == self.rindex {
|
||||
return None;
|
||||
}
|
||||
@ -254,9 +254,9 @@ impl<'self, T> Iterator<&'self T> for RingBufIterator<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T> DoubleEndedIterator<&'self T> for RingBufIterator<'self, T> {
|
||||
impl<'a, T> DoubleEndedIterator<&'a T> for RingBufIterator<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'self T> {
|
||||
fn next_back(&mut self) -> Option<&'a T> {
|
||||
if self.index == self.rindex {
|
||||
return None;
|
||||
}
|
||||
@ -266,14 +266,14 @@ impl<'self, T> DoubleEndedIterator<&'self T> for RingBufIterator<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T> ExactSize<&'self T> for RingBufIterator<'self, T> {}
|
||||
impl<'a, T> ExactSize<&'a T> for RingBufIterator<'a, T> {}
|
||||
|
||||
impl<'self, T> RandomAccessIterator<&'self T> for RingBufIterator<'self, T> {
|
||||
impl<'a, T> RandomAccessIterator<&'a T> for RingBufIterator<'a, T> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint { self.rindex - self.index }
|
||||
|
||||
#[inline]
|
||||
fn idx(&self, j: uint) -> Option<&'self T> {
|
||||
fn idx(&self, j: uint) -> Option<&'a T> {
|
||||
if j >= self.indexable() {
|
||||
None
|
||||
} else {
|
||||
@ -284,15 +284,15 @@ impl<'self, T> RandomAccessIterator<&'self T> for RingBufIterator<'self, T> {
|
||||
}
|
||||
|
||||
/// RingBuf mutable iterator
|
||||
pub struct RingBufMutIterator<'self, T> {
|
||||
priv remaining1: &'self mut [Option<T>],
|
||||
priv remaining2: &'self mut [Option<T>],
|
||||
pub struct RingBufMutIterator<'a, T> {
|
||||
priv remaining1: &'a mut [Option<T>],
|
||||
priv remaining2: &'a mut [Option<T>],
|
||||
priv nelts: uint,
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self mut T> for RingBufMutIterator<'self, T> {
|
||||
impl<'a, T> Iterator<&'a mut T> for RingBufMutIterator<'a, T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self mut T> {
|
||||
fn next(&mut self) -> Option<&'a mut T> {
|
||||
if self.nelts == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -312,9 +312,9 @@ impl<'self, T> Iterator<&'self mut T> for RingBufMutIterator<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T> DoubleEndedIterator<&'self mut T> for RingBufMutIterator<'self, T> {
|
||||
impl<'a, T> DoubleEndedIterator<&'a mut T> for RingBufMutIterator<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'self mut T> {
|
||||
fn next_back(&mut self) -> Option<&'a mut T> {
|
||||
if self.nelts == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -329,7 +329,7 @@ impl<'self, T> DoubleEndedIterator<&'self mut T> for RingBufMutIterator<'self, T
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T> ExactSize<&'self mut T> for RingBufMutIterator<'self, T> {}
|
||||
impl<'a, T> ExactSize<&'a mut T> for RingBufMutIterator<'a, T> {}
|
||||
|
||||
/// Grow is only called on full elts, so nelts is also len(elts), unlike
|
||||
/// elsewhere.
|
||||
|
@ -292,7 +292,7 @@ impl<D:Decoder> Decodable<D> for i64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, S:Encoder> Encodable<S> for &'self str {
|
||||
impl<'a, S:Encoder> Encodable<S> for &'a str {
|
||||
fn encode(&self, s: &mut S) {
|
||||
s.emit_str(*self)
|
||||
}
|
||||
@ -382,7 +382,7 @@ impl<D:Decoder> Decodable<D> for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
|
||||
impl<'a, S:Encoder,T:Encodable<S>> Encodable<S> for &'a T {
|
||||
fn encode(&self, s: &mut S) {
|
||||
(**self).encode(s)
|
||||
}
|
||||
@ -438,7 +438,7 @@ impl<D:Decoder,T:Decodable<D> + 'static> Decodable<D> for @mut T {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] {
|
||||
impl<'a, S:Encoder,T:Encodable<S>> Encodable<S> for &'a [T] {
|
||||
fn encode(&self, s: &mut S) {
|
||||
s.emit_seq(self.len(), |s| {
|
||||
for (i, e) in self.iter().enumerate() {
|
||||
|
@ -184,7 +184,7 @@ impl<V:Clone> SmallIntMap<V> {
|
||||
|
||||
macro_rules! iterator {
|
||||
(impl $name:ident -> $elem:ty, $getter:ident) => {
|
||||
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> {
|
||||
while self.front < self.back {
|
||||
@ -213,7 +213,7 @@ macro_rules! iterator {
|
||||
|
||||
macro_rules! double_ended_iterator {
|
||||
(impl $name:ident -> $elem:ty, $getter:ident) => {
|
||||
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> {
|
||||
while self.front < self.back {
|
||||
@ -234,25 +234,25 @@ macro_rules! double_ended_iterator {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SmallIntMapIterator<'self, T> {
|
||||
pub struct SmallIntMapIterator<'a, T> {
|
||||
priv front: uint,
|
||||
priv back: uint,
|
||||
priv iter: VecIterator<'self, Option<T>>
|
||||
priv iter: VecIterator<'a, Option<T>>
|
||||
}
|
||||
|
||||
iterator!(impl SmallIntMapIterator -> (uint, &'self T), get_ref)
|
||||
double_ended_iterator!(impl SmallIntMapIterator -> (uint, &'self T), get_ref)
|
||||
pub type SmallIntMapRevIterator<'self, T> = Invert<SmallIntMapIterator<'self, T>>;
|
||||
iterator!(impl SmallIntMapIterator -> (uint, &'a T), get_ref)
|
||||
double_ended_iterator!(impl SmallIntMapIterator -> (uint, &'a T), get_ref)
|
||||
pub type SmallIntMapRevIterator<'a, T> = Invert<SmallIntMapIterator<'a, T>>;
|
||||
|
||||
pub struct SmallIntMapMutIterator<'self, T> {
|
||||
pub struct SmallIntMapMutIterator<'a, T> {
|
||||
priv front: uint,
|
||||
priv back: uint,
|
||||
priv iter: VecMutIterator<'self, Option<T>>
|
||||
priv iter: VecMutIterator<'a, Option<T>>
|
||||
}
|
||||
|
||||
iterator!(impl SmallIntMapMutIterator -> (uint, &'self mut T), get_mut_ref)
|
||||
double_ended_iterator!(impl SmallIntMapMutIterator -> (uint, &'self mut T), get_mut_ref)
|
||||
pub type SmallIntMapMutRevIterator<'self, T> = Invert<SmallIntMapMutIterator<'self, T>>;
|
||||
iterator!(impl SmallIntMapMutIterator -> (uint, &'a mut T), get_mut_ref)
|
||||
double_ended_iterator!(impl SmallIntMapMutIterator -> (uint, &'a mut T), get_mut_ref)
|
||||
pub type SmallIntMapMutRevIterator<'a, T> = Invert<SmallIntMapMutIterator<'a, T>>;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_map {
|
||||
|
@ -15,7 +15,7 @@ use std::cmp::{Eq, Ord};
|
||||
use std::util::swap;
|
||||
use std::vec;
|
||||
|
||||
type Le<'self, T> = 'self |v1: &T, v2: &T| -> bool;
|
||||
type Le<'a, T> = 'a |v1: &T, v2: &T| -> bool;
|
||||
|
||||
/**
|
||||
* Merge sort. Returns a new vector containing the sorted list.
|
||||
@ -173,7 +173,7 @@ pub trait Sort {
|
||||
fn qsort(self);
|
||||
}
|
||||
|
||||
impl<'self, T:Clone + Ord + Eq> Sort for &'self mut [T] {
|
||||
impl<'a, T:Clone + Ord + Eq> Sort for &'a mut [T] {
|
||||
fn qsort(self) { quick_sort3(self); }
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ impl Summary {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Stats for &'self [f64] {
|
||||
impl<'a> Stats for &'a [f64] {
|
||||
|
||||
fn sum(self) -> f64 {
|
||||
self.iter().fold(0.0, |p,q| p + *q)
|
||||
|
@ -155,28 +155,28 @@ impl Sem<~[WaitQueue]> {
|
||||
// FIXME(#3598): Want to use an Option down below, but we need a custom enum
|
||||
// that's not polymorphic to get around the fact that lifetimes are invariant
|
||||
// inside of type parameters.
|
||||
enum ReacquireOrderLock<'self> {
|
||||
enum ReacquireOrderLock<'a> {
|
||||
Nothing, // c.c
|
||||
Just(&'self Semaphore),
|
||||
Just(&'a Semaphore),
|
||||
}
|
||||
|
||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||
pub struct Condvar<'self> {
|
||||
pub struct Condvar<'a> {
|
||||
// The 'Sem' object associated with this condvar. This is the one that's
|
||||
// atomically-unlocked-and-descheduled upon and reacquired during wakeup.
|
||||
priv sem: &'self Sem<~[WaitQueue]>,
|
||||
priv sem: &'a Sem<~[WaitQueue]>,
|
||||
// This is (can be) an extra semaphore which is held around the reacquire
|
||||
// operation on the first one. This is only used in cvars associated with
|
||||
// rwlocks, and is needed to ensure that, when a downgrader is trying to
|
||||
// hand off the access lock (which would be the first field, here), a 2nd
|
||||
// writer waking up from a cvar wait can't race with a reader to steal it,
|
||||
// See the comment in write_cond for more detail.
|
||||
priv order: ReacquireOrderLock<'self>,
|
||||
priv order: ReacquireOrderLock<'a>,
|
||||
// Make sure condvars are non-copyable.
|
||||
priv token: util::NonCopyable,
|
||||
}
|
||||
|
||||
impl<'self> Condvar<'self> {
|
||||
impl<'a> Condvar<'a> {
|
||||
/**
|
||||
* Atomically drop the associated lock, and block until a signal is sent.
|
||||
*
|
||||
@ -644,12 +644,12 @@ impl RWLock {
|
||||
|
||||
/// The "write permission" token used for rwlock.write_downgrade().
|
||||
|
||||
pub struct RWLockWriteMode<'self> { priv lock: &'self RWLock, priv token: NonCopyable }
|
||||
pub struct RWLockWriteMode<'a> { priv lock: &'a RWLock, priv token: NonCopyable }
|
||||
/// The "read permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWLockReadMode<'self> { priv lock: &'self RWLock,
|
||||
pub struct RWLockReadMode<'a> { priv lock: &'a RWLock,
|
||||
priv token: NonCopyable }
|
||||
|
||||
impl<'self> RWLockWriteMode<'self> {
|
||||
impl<'a> RWLockWriteMode<'a> {
|
||||
/// Access the pre-downgrade rwlock in write mode.
|
||||
pub fn write<U>(&self, blk: || -> U) -> U { blk() }
|
||||
/// Access the pre-downgrade rwlock in write mode with a condvar.
|
||||
@ -662,7 +662,7 @@ impl<'self> RWLockWriteMode<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> RWLockReadMode<'self> {
|
||||
impl<'a> RWLockReadMode<'a> {
|
||||
/// Access the post-downgrade rwlock in read mode.
|
||||
pub fn read<U>(&self, blk: || -> U) -> U { blk() }
|
||||
}
|
||||
|
@ -228,9 +228,9 @@ impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
}
|
||||
|
||||
/// Lazy forward iterator over a map
|
||||
pub struct TreeMapIterator<'self, K, V> {
|
||||
priv stack: ~[&'self TreeNode<K, V>],
|
||||
priv node: Option<&'self TreeNode<K, V>>,
|
||||
pub struct TreeMapIterator<'a, K, V> {
|
||||
priv stack: ~[&'a TreeNode<K, V>],
|
||||
priv node: Option<&'a TreeNode<K, V>>,
|
||||
priv remaining_min: uint,
|
||||
priv remaining_max: uint
|
||||
}
|
||||
@ -245,9 +245,9 @@ fn deref<'a, K, V>(node: &'a Option<~TreeNode<K, V>>) -> Option<&'a TreeNode<K,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, K, V> TreeMapIterator<'self, K, V> {
|
||||
impl<'a, K, V> TreeMapIterator<'a, K, V> {
|
||||
#[inline(always)]
|
||||
fn next_(&mut self, forward: bool) -> Option<(&'self K, &'self V)> {
|
||||
fn next_(&mut self, forward: bool) -> Option<(&'a K, &'a V)> {
|
||||
while !self.stack.is_empty() || self.node.is_some() {
|
||||
match self.node {
|
||||
Some(x) => {
|
||||
@ -269,11 +269,11 @@ impl<'self, K, V> TreeMapIterator<'self, K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V> {
|
||||
impl<'a, K, V> Iterator<(&'a K, &'a V)> for TreeMapIterator<'a, K, V> {
|
||||
/// Advance the iterator to the next node (in order) and return a
|
||||
/// tuple with a reference to the key and value. If there are no
|
||||
/// more nodes, return `None`.
|
||||
fn next(&mut self) -> Option<(&'self K, &'self V)> {
|
||||
fn next(&mut self) -> Option<(&'a K, &'a V)> {
|
||||
self.next_(true)
|
||||
}
|
||||
|
||||
@ -284,15 +284,15 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V
|
||||
}
|
||||
|
||||
/// Lazy backward iterator over a map
|
||||
pub struct TreeMapRevIterator<'self, K, V> {
|
||||
priv iter: TreeMapIterator<'self, K, V>,
|
||||
pub struct TreeMapRevIterator<'a, K, V> {
|
||||
priv iter: TreeMapIterator<'a, K, V>,
|
||||
}
|
||||
|
||||
impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapRevIterator<'self, K, V> {
|
||||
impl<'a, K, V> Iterator<(&'a K, &'a V)> for TreeMapRevIterator<'a, K, V> {
|
||||
/// Advance the iterator to the next node (in order) and return a
|
||||
/// tuple with a reference to the key and value. If there are no
|
||||
/// more nodes, return `None`.
|
||||
fn next(&mut self) -> Option<(&'self K, &'self V)> {
|
||||
fn next(&mut self) -> Option<(&'a K, &'a V)> {
|
||||
self.iter.next_(false)
|
||||
}
|
||||
|
||||
@ -390,18 +390,18 @@ impl<K, V> Iterator<(K, V)> for TreeMapMoveIterator<K,V> {
|
||||
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
|
||||
impl<'a, T> Iterator<&'a T> for TreeSetIterator<'a, T> {
|
||||
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
self.iter.next().map(|(value, _)| value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T> Iterator<&'self T> for TreeSetRevIterator<'self, T> {
|
||||
impl<'a, T> Iterator<&'a T> for TreeSetRevIterator<'a, T> {
|
||||
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
self.iter.next().map(|(value, _)| value)
|
||||
}
|
||||
}
|
||||
@ -561,37 +561,37 @@ impl<T: TotalOrd> TreeSet<T> {
|
||||
}
|
||||
|
||||
/// Lazy forward iterator over a set
|
||||
pub struct TreeSetIterator<'self, T> {
|
||||
priv iter: TreeMapIterator<'self, T, ()>
|
||||
pub struct TreeSetIterator<'a, T> {
|
||||
priv iter: TreeMapIterator<'a, T, ()>
|
||||
}
|
||||
|
||||
/// Lazy backward iterator over a set
|
||||
pub struct TreeSetRevIterator<'self, T> {
|
||||
priv iter: TreeMapRevIterator<'self, T, ()>
|
||||
pub struct TreeSetRevIterator<'a, T> {
|
||||
priv iter: TreeMapRevIterator<'a, T, ()>
|
||||
}
|
||||
|
||||
/// Lazy iterator producing elements in the set difference (in-order)
|
||||
pub struct Difference<'self, T> {
|
||||
priv a: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
priv b: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
pub struct Difference<'a, T> {
|
||||
priv a: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
priv b: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
}
|
||||
|
||||
/// Lazy iterator producing elements in the set symmetric difference (in-order)
|
||||
pub struct SymDifference<'self, T> {
|
||||
priv a: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
priv b: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
pub struct SymDifference<'a, T> {
|
||||
priv a: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
priv b: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
}
|
||||
|
||||
/// Lazy iterator producing elements in the set intersection (in-order)
|
||||
pub struct Intersection<'self, T> {
|
||||
priv a: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
priv b: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
pub struct Intersection<'a, T> {
|
||||
priv a: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
priv b: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
}
|
||||
|
||||
/// Lazy iterator producing elements in the set intersection (in-order)
|
||||
pub struct Union<'self, T> {
|
||||
priv a: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
priv b: Peekable<&'self T, TreeSetIterator<'self, T>>,
|
||||
pub struct Union<'a, T> {
|
||||
priv a: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
priv b: Peekable<&'a T, TreeSetIterator<'a, T>>,
|
||||
}
|
||||
|
||||
/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
|
||||
@ -604,8 +604,8 @@ fn cmp_opt<T: TotalOrd>(x: Option<&T>, y: Option<&T>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T: TotalOrd> Iterator<&'self T> for Difference<'self, T> {
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for Difference<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Less, Less) {
|
||||
Less => return self.a.next(),
|
||||
@ -616,8 +616,8 @@ impl<'self, T: TotalOrd> Iterator<&'self T> for Difference<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T: TotalOrd> Iterator<&'self T> for SymDifference<'self, T> {
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for SymDifference<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
|
||||
Less => return self.a.next(),
|
||||
@ -628,8 +628,8 @@ impl<'self, T: TotalOrd> Iterator<&'self T> for SymDifference<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T: TotalOrd> Iterator<&'self T> for Intersection<'self, T> {
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for Intersection<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
let o_cmp = match (self.a.peek(), self.b.peek()) {
|
||||
(None , _ ) => None,
|
||||
@ -646,8 +646,8 @@ impl<'self, T: TotalOrd> Iterator<&'self T> for Intersection<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T: TotalOrd> Iterator<&'self T> for Union<'self, T> {
|
||||
fn next(&mut self) -> Option<&'self T> {
|
||||
impl<'a, T: TotalOrd> Iterator<&'a T> for Union<'a, T> {
|
||||
fn next(&mut self) -> Option<&'a T> {
|
||||
loop {
|
||||
match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
|
||||
Less => return self.a.next(),
|
||||
|
@ -239,9 +239,9 @@ pub struct Context {
|
||||
priv freshness: Arc<FreshnessMap>
|
||||
}
|
||||
|
||||
pub struct Prep<'self> {
|
||||
priv ctxt: &'self Context,
|
||||
priv fn_name: &'self str,
|
||||
pub struct Prep<'a> {
|
||||
priv ctxt: &'a Context,
|
||||
priv fn_name: &'a str,
|
||||
priv declared_inputs: WorkMap,
|
||||
}
|
||||
|
||||
@ -250,12 +250,12 @@ pub struct Exec {
|
||||
priv discovered_outputs: WorkMap
|
||||
}
|
||||
|
||||
enum Work<'self, T> {
|
||||
enum Work<'a, T> {
|
||||
WorkValue(T),
|
||||
WorkFromTask(&'self Prep<'self>, PortOne<(Exec, T)>),
|
||||
WorkFromTask(&'a Prep<'a>, PortOne<(Exec, T)>),
|
||||
}
|
||||
|
||||
fn json_encode<'self, T:Encodable<json::Encoder<'self>>>(t: &T) -> ~str {
|
||||
fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str {
|
||||
let mut writer = MemWriter::new();
|
||||
let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer);
|
||||
t.encode(&mut encoder);
|
||||
@ -336,8 +336,8 @@ impl Exec {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Prep<'self> {
|
||||
fn new(ctxt: &'self Context, fn_name: &'self str) -> Prep<'self> {
|
||||
impl<'a> Prep<'a> {
|
||||
fn new(ctxt: &'a Context, fn_name: &'a str) -> Prep<'a> {
|
||||
Prep {
|
||||
ctxt: ctxt,
|
||||
fn_name: fn_name,
|
||||
@ -356,7 +356,7 @@ impl<'self> Prep<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Prep<'self> {
|
||||
impl<'a> Prep<'a> {
|
||||
pub fn declare_input(&mut self, kind: &str, name: &str, val: &str) {
|
||||
debug!("Declaring input {} {} {}", kind, name, val);
|
||||
self.declared_inputs.insert_work_key(WorkKey::new(kind, name),
|
||||
@ -395,17 +395,17 @@ impl<'self> Prep<'self> {
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn exec<'self, T:Send +
|
||||
Encodable<json::Encoder<'self>> +
|
||||
pub fn exec<'a, T:Send +
|
||||
Encodable<json::Encoder<'a>> +
|
||||
Decodable<json::Decoder>>(
|
||||
&'self self, blk: proc(&mut Exec) -> T) -> T {
|
||||
&'a self, blk: proc(&mut Exec) -> T) -> T {
|
||||
self.exec_work(blk).unwrap()
|
||||
}
|
||||
|
||||
fn exec_work<'self, T:Send +
|
||||
Encodable<json::Encoder<'self>> +
|
||||
fn exec_work<'a, T:Send +
|
||||
Encodable<json::Encoder<'a>> +
|
||||
Decodable<json::Decoder>>( // FIXME(#5121)
|
||||
&'self self, blk: proc(&mut Exec) -> T) -> Work<'self, T> {
|
||||
&'a self, blk: proc(&mut Exec) -> T) -> Work<'a, T> {
|
||||
let mut bo = Some(blk);
|
||||
|
||||
debug!("exec_work: looking up {} and {:?}", self.fn_name,
|
||||
@ -445,16 +445,16 @@ impl<'self> Prep<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, T:Send +
|
||||
Encodable<json::Encoder<'self>> +
|
||||
impl<'a, T:Send +
|
||||
Encodable<json::Encoder<'a>> +
|
||||
Decodable<json::Decoder>>
|
||||
Work<'self, T> { // FIXME(#5121)
|
||||
Work<'a, T> { // FIXME(#5121)
|
||||
|
||||
pub fn from_value(elt: T) -> Work<'self, T> {
|
||||
pub fn from_value(elt: T) -> Work<'a, T> {
|
||||
WorkValue(elt)
|
||||
}
|
||||
pub fn from_task(prep: &'self Prep<'self>, port: PortOne<(Exec, T)>)
|
||||
-> Work<'self, T> {
|
||||
pub fn from_task(prep: &'a Prep<'a>, port: PortOne<(Exec, T)>)
|
||||
-> Work<'a, T> {
|
||||
WorkFromTask(prep, port)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
use syntax::fold::ast_fold;
|
||||
use syntax::{ast, fold, attr};
|
||||
|
||||
struct Context<'self> {
|
||||
in_cfg: 'self |attrs: &[ast::Attribute]| -> bool,
|
||||
struct Context<'a> {
|
||||
in_cfg: 'a |attrs: &[ast::Attribute]| -> bool,
|
||||
}
|
||||
|
||||
// Support conditional compilation by transforming the AST, stripping out
|
||||
@ -23,7 +23,7 @@ pub fn strip_unconfigured_items(crate: ast::Crate) -> ast::Crate {
|
||||
strip_items(crate, |attrs| in_cfg(config, attrs))
|
||||
}
|
||||
|
||||
impl<'self> fold::ast_fold for Context<'self> {
|
||||
impl<'a> fold::ast_fold for Context<'a> {
|
||||
fn fold_mod(&self, module: &ast::_mod) -> ast::_mod {
|
||||
fold_mod(self, module)
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) ->
|
||||
ret
|
||||
}
|
||||
|
||||
pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd;
|
||||
pub type GetCrateDataCb<'a> = 'a |ast::CrateNum| -> Cmd;
|
||||
|
||||
pub fn maybe_find_item(item_id: ast::NodeId, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
|
||||
@ -694,7 +694,7 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> ast_map::path {
|
||||
item_path(lookup_item(id, cdata.data))
|
||||
}
|
||||
|
||||
pub type decode_inlined_item<'self> = 'self |cdata: @cstore::crate_metadata,
|
||||
pub type decode_inlined_item<'a> = 'a |cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::Doc|
|
||||
|
@ -51,21 +51,21 @@ use writer = extra::ebml::writer;
|
||||
// used by astencode:
|
||||
type abbrev_map = @mut HashMap<ty::t, tyencode::ty_abbrev>;
|
||||
|
||||
pub type encode_inlined_item<'self> = 'self |ecx: &EncodeContext,
|
||||
pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext,
|
||||
ebml_w: &mut writer::Encoder,
|
||||
path: &[ast_map::path_elt],
|
||||
ii: ast::inlined_item|;
|
||||
|
||||
pub struct EncodeParams<'self> {
|
||||
pub struct EncodeParams<'a> {
|
||||
diag: @mut span_handler,
|
||||
tcx: ty::ctxt,
|
||||
reexports2: middle::resolve::ExportMap2,
|
||||
item_symbols: &'self HashMap<ast::NodeId, ~str>,
|
||||
discrim_symbols: &'self HashMap<ast::NodeId, @str>,
|
||||
non_inlineable_statics: &'self HashSet<ast::NodeId>,
|
||||
link_meta: &'self LinkMeta,
|
||||
item_symbols: &'a HashMap<ast::NodeId, ~str>,
|
||||
discrim_symbols: &'a HashMap<ast::NodeId, @str>,
|
||||
non_inlineable_statics: &'a HashSet<ast::NodeId>,
|
||||
link_meta: &'a LinkMeta,
|
||||
cstore: @mut cstore::CStore,
|
||||
encode_inlined_item: encode_inlined_item<'self>,
|
||||
encode_inlined_item: encode_inlined_item<'a>,
|
||||
reachable: @mut HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
@ -85,17 +85,17 @@ struct Stats {
|
||||
n_inlines: uint
|
||||
}
|
||||
|
||||
pub struct EncodeContext<'self> {
|
||||
pub struct EncodeContext<'a> {
|
||||
diag: @mut span_handler,
|
||||
tcx: ty::ctxt,
|
||||
stats: @mut Stats,
|
||||
reexports2: middle::resolve::ExportMap2,
|
||||
item_symbols: &'self HashMap<ast::NodeId, ~str>,
|
||||
discrim_symbols: &'self HashMap<ast::NodeId, @str>,
|
||||
non_inlineable_statics: &'self HashSet<ast::NodeId>,
|
||||
link_meta: &'self LinkMeta,
|
||||
cstore: &'self cstore::CStore,
|
||||
encode_inlined_item: encode_inlined_item<'self>,
|
||||
item_symbols: &'a HashMap<ast::NodeId, ~str>,
|
||||
discrim_symbols: &'a HashMap<ast::NodeId, @str>,
|
||||
non_inlineable_statics: &'a HashSet<ast::NodeId>,
|
||||
link_meta: &'a LinkMeta,
|
||||
cstore: &'a cstore::CStore,
|
||||
encode_inlined_item: encode_inlined_item<'a>,
|
||||
type_abbrevs: abbrev_map,
|
||||
reachable: @mut HashSet<ast::NodeId>,
|
||||
}
|
||||
@ -1605,12 +1605,12 @@ fn encode_native_libraries(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
struct ImplVisitor<'self> {
|
||||
ecx: &'self EncodeContext<'self>,
|
||||
ebml_w: &'self mut writer::Encoder,
|
||||
struct ImplVisitor<'a> {
|
||||
ecx: &'a EncodeContext<'a>,
|
||||
ebml_w: &'a mut writer::Encoder,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for ImplVisitor<'self> {
|
||||
impl<'a> Visitor<()> for ImplVisitor<'a> {
|
||||
fn visit_item(&mut self, item: @item, _: ()) {
|
||||
match item.node {
|
||||
item_impl(_, Some(ref trait_ref), _, _) => {
|
||||
|
@ -23,7 +23,7 @@ pub enum FileMatch { FileMatches, FileDoesntMatch }
|
||||
|
||||
/// Functions with type `pick` take a parent directory as well as
|
||||
/// a file found in that directory.
|
||||
pub type pick<'self> = 'self |path: &Path| -> FileMatch;
|
||||
pub type pick<'a> = 'a |path: &Path| -> FileMatch;
|
||||
|
||||
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
|
||||
if path.filename() == Some(file.as_vec()) {
|
||||
|
@ -52,11 +52,11 @@ pub enum DefIdSource {
|
||||
// Identifies a region parameter (`fn foo<'X>() { ... }`).
|
||||
RegionParameter,
|
||||
}
|
||||
type conv_did<'self> =
|
||||
'self |source: DefIdSource, ast::DefId| -> ast::DefId;
|
||||
type conv_did<'a> =
|
||||
'a |source: DefIdSource, ast::DefId| -> ast::DefId;
|
||||
|
||||
pub struct PState<'self> {
|
||||
data: &'self [u8],
|
||||
pub struct PState<'a> {
|
||||
data: &'a [u8],
|
||||
crate: ast::CrateNum,
|
||||
pos: uint,
|
||||
tcx: ty::ctxt
|
||||
|
@ -765,7 +765,7 @@ trait get_ty_str_ctxt {
|
||||
fn ty_str_ctxt(&self) -> @tyencode::ctxt;
|
||||
}
|
||||
|
||||
impl<'self> get_ty_str_ctxt for e::EncodeContext<'self> {
|
||||
impl<'a> get_ty_str_ctxt for e::EncodeContext<'a> {
|
||||
fn ty_str_ctxt(&self) -> @tyencode::ctxt {
|
||||
@tyencode::ctxt {
|
||||
diag: self.tcx.sess.diagnostic(),
|
||||
|
@ -32,15 +32,15 @@ use syntax::visit;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct CheckLoanCtxt<'self> {
|
||||
bccx: &'self BorrowckCtxt,
|
||||
dfcx_loans: &'self LoanDataFlow,
|
||||
struct CheckLoanCtxt<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
dfcx_loans: &'a LoanDataFlow,
|
||||
move_data: @move_data::FlowedMoveData,
|
||||
all_loans: &'self [Loan],
|
||||
all_loans: &'a [Loan],
|
||||
reported: @mut HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for CheckLoanCtxt<'self> {
|
||||
impl<'a> Visitor<()> for CheckLoanCtxt<'a> {
|
||||
|
||||
fn visit_expr(&mut self, ex:@ast::Expr, _:()) {
|
||||
check_loans_in_expr(self, ex);
|
||||
@ -86,7 +86,7 @@ enum MoveError {
|
||||
MoveWhileBorrowed(/*loan*/@LoanPath, /*loan*/Span)
|
||||
}
|
||||
|
||||
impl<'self> CheckLoanCtxt<'self> {
|
||||
impl<'a> CheckLoanCtxt<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||
|
||||
pub fn each_issued_loan(&self, scope_id: ast::NodeId, op: |&Loan| -> bool)
|
||||
|
@ -45,8 +45,8 @@ pub fn guarantee_lifetime(bccx: &BorrowckCtxt,
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
|
||||
struct GuaranteeLifetimeContext<'self> {
|
||||
bccx: &'self BorrowckCtxt,
|
||||
struct GuaranteeLifetimeContext<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
|
||||
// the node id of the function body for the enclosing item
|
||||
item_scope_id: ast::NodeId,
|
||||
@ -61,7 +61,7 @@ struct GuaranteeLifetimeContext<'self> {
|
||||
cmt_original: mc::cmt
|
||||
}
|
||||
|
||||
impl<'self> GuaranteeLifetimeContext<'self> {
|
||||
impl<'a> GuaranteeLifetimeContext<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
self.bccx.tcx
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ mod gather_moves;
|
||||
/// No good. Instead what will happen is that `root_ub` will be set to the
|
||||
/// body of the while loop and we will refuse to root the pointer `&*x`
|
||||
/// because it would have to be rooted for a region greater than `root_ub`.
|
||||
struct GatherLoanCtxt<'self> {
|
||||
bccx: &'self BorrowckCtxt,
|
||||
struct GatherLoanCtxt<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
id_range: id_range,
|
||||
move_data: @mut move_data::MoveData,
|
||||
all_loans: @mut ~[Loan],
|
||||
@ -73,7 +73,7 @@ struct GatherLoanCtxt<'self> {
|
||||
repeating_ids: ~[ast::NodeId]
|
||||
}
|
||||
|
||||
impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {
|
||||
impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> {
|
||||
fn visit_expr(&mut self, ex:@Expr, _:()) {
|
||||
gather_loans_in_expr(self, ex);
|
||||
}
|
||||
@ -333,7 +333,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> GatherLoanCtxt<'self> {
|
||||
impl<'a> GatherLoanCtxt<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||
|
||||
pub fn push_repeating_id(&mut self, id: ast::NodeId) {
|
||||
|
@ -42,14 +42,14 @@ pub fn compute_restrictions(bccx: &BorrowckCtxt,
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
|
||||
struct RestrictionsContext<'self> {
|
||||
bccx: &'self BorrowckCtxt,
|
||||
struct RestrictionsContext<'a> {
|
||||
bccx: &'a BorrowckCtxt,
|
||||
span: Span,
|
||||
cmt_original: mc::cmt,
|
||||
loan_region: ty::Region,
|
||||
}
|
||||
|
||||
impl<'self> RestrictionsContext<'self> {
|
||||
impl<'a> RestrictionsContext<'a> {
|
||||
fn restrict(&self,
|
||||
cmt: mc::cmt,
|
||||
restrictions: RestrictionSet) -> RestrictionResult {
|
||||
|
@ -77,12 +77,12 @@ pub trait DataFlowOperator {
|
||||
fn walk_closures(&self) -> bool;
|
||||
}
|
||||
|
||||
struct PropagationContext<'self, O> {
|
||||
dfcx: &'self mut DataFlowContext<O>,
|
||||
struct PropagationContext<'a, O> {
|
||||
dfcx: &'a mut DataFlowContext<O>,
|
||||
changed: bool
|
||||
}
|
||||
|
||||
struct LoopScope<'self> {
|
||||
struct LoopScope<'a> {
|
||||
loop_id: ast::NodeId,
|
||||
break_bits: ~[uint]
|
||||
}
|
||||
@ -363,7 +363,7 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
|
||||
impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
self.dfcx.tcx
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ struct LanguageItemCollector {
|
||||
item_refs: HashMap<&'static str, uint>,
|
||||
}
|
||||
|
||||
struct LanguageItemVisitor<'self> {
|
||||
this: &'self mut LanguageItemCollector,
|
||||
struct LanguageItemVisitor<'a> {
|
||||
this: &'a mut LanguageItemCollector,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for LanguageItemVisitor<'self> {
|
||||
impl<'a> Visitor<()> for LanguageItemVisitor<'a> {
|
||||
fn visit_item(&mut self, item: @ast::item, _: ()) {
|
||||
match extract(item.attrs) {
|
||||
Some(value) => {
|
||||
|
@ -352,7 +352,7 @@ pub fn get_lint_dict() -> LintDict {
|
||||
return map;
|
||||
}
|
||||
|
||||
struct Context<'self> {
|
||||
struct Context<'a> {
|
||||
// All known lint modes (string versions)
|
||||
dict: @LintDict,
|
||||
// Current levels of each lint warning
|
||||
@ -360,7 +360,7 @@ struct Context<'self> {
|
||||
// context we're checking in (used to access fields like sess)
|
||||
tcx: ty::ctxt,
|
||||
// Items exported by the crate; used by the missing_doc lint.
|
||||
exported_items: &'self privacy::ExportedItems,
|
||||
exported_items: &'a privacy::ExportedItems,
|
||||
// The id of the current `ast::struct_def` being walked.
|
||||
cur_struct_def_id: ast::NodeId,
|
||||
// Whether some ancestor of the current node was marked
|
||||
@ -376,7 +376,7 @@ struct Context<'self> {
|
||||
negated_expr_id: ast::NodeId
|
||||
}
|
||||
|
||||
impl<'self> Context<'self> {
|
||||
impl<'a> Context<'a> {
|
||||
fn get_level(&self, lint: lint) -> level {
|
||||
match self.cur.find(&(lint as uint)) {
|
||||
Some(&(lvl, _)) => lvl,
|
||||
@ -1234,7 +1234,7 @@ fn check_stability(cx: &Context, e: &ast::Expr) {
|
||||
cx.span_lint(lint, e.span, msg);
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for Context<'self> {
|
||||
impl<'a> Visitor<()> for Context<'a> {
|
||||
fn visit_item(&mut self, it: @ast::item, _: ()) {
|
||||
self.with_lint_attrs(it.attrs, |cx| {
|
||||
check_item_ctypes(cx, it);
|
||||
@ -1369,7 +1369,7 @@ impl<'self> Visitor<()> for Context<'self> {
|
||||
fn visit_ty(&mut self, _t: &ast::Ty, _: ()) {}
|
||||
}
|
||||
|
||||
impl<'self> IdVisitingOperation for Context<'self> {
|
||||
impl<'a> IdVisitingOperation for Context<'a> {
|
||||
fn visit_id(&self, id: ast::NodeId) {
|
||||
match self.tcx.sess.lints.pop(&id) {
|
||||
None => {}
|
||||
|
@ -30,7 +30,7 @@ use syntax::opt_vec;
|
||||
use syntax::visit;
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
type Context<'self> = (&'self method_map, &'self resolve::ExportMap2);
|
||||
type Context<'a> = (&'a method_map, &'a resolve::ExportMap2);
|
||||
|
||||
/// A set of AST nodes exported by the crate.
|
||||
pub type ExportedItems = HashSet<ast::NodeId>;
|
||||
@ -143,9 +143,9 @@ impl Visitor<()> for ParentVisitor {
|
||||
/// The embargo visitor, used to determine the exports of the ast
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct EmbargoVisitor<'self> {
|
||||
struct EmbargoVisitor<'a> {
|
||||
tcx: ty::ctxt,
|
||||
exp_map2: &'self resolve::ExportMap2,
|
||||
exp_map2: &'a resolve::ExportMap2,
|
||||
|
||||
// This flag is an indicator of whether the previous item in the
|
||||
// hierarchical chain was exported or not. This is the indicator of whether
|
||||
@ -167,7 +167,7 @@ struct EmbargoVisitor<'self> {
|
||||
reexports: HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for EmbargoVisitor<'self> {
|
||||
impl<'a> Visitor<()> for EmbargoVisitor<'a> {
|
||||
fn visit_item(&mut self, item: @ast::item, _: ()) {
|
||||
let orig_all_pub = self.prev_exported;
|
||||
match item.node {
|
||||
@ -308,12 +308,12 @@ impl<'self> Visitor<()> for EmbargoVisitor<'self> {
|
||||
/// The privacy visitor, where privacy checks take place (violations reported)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct PrivacyVisitor<'self> {
|
||||
struct PrivacyVisitor<'a> {
|
||||
tcx: ty::ctxt,
|
||||
curitem: ast::NodeId,
|
||||
in_fn: bool,
|
||||
in_foreign: bool,
|
||||
method_map: &'self method_map,
|
||||
method_map: &'a method_map,
|
||||
parents: HashMap<ast::NodeId, ast::NodeId>,
|
||||
external_exports: resolve::ExternalExports,
|
||||
last_private_map: resolve::LastPrivateMap,
|
||||
@ -325,7 +325,7 @@ enum PrivacyResult {
|
||||
DisallowedBy(ast::NodeId),
|
||||
}
|
||||
|
||||
impl<'self> PrivacyVisitor<'self> {
|
||||
impl<'a> PrivacyVisitor<'a> {
|
||||
// used when debugging
|
||||
fn nodestr(&self, id: ast::NodeId) -> ~str {
|
||||
ast_map::node_id_to_str(self.tcx.items, id, token::get_ident_interner())
|
||||
@ -601,7 +601,7 @@ impl<'self> PrivacyVisitor<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for PrivacyVisitor<'self> {
|
||||
impl<'a> Visitor<()> for PrivacyVisitor<'a> {
|
||||
fn visit_item(&mut self, item: @ast::item, _: ()) {
|
||||
// Do not check privacy inside items with the resolve_unexported
|
||||
// attribute. This is used for the test runner.
|
||||
|
@ -185,9 +185,9 @@ impl<T> ResolveResult<T> {
|
||||
}
|
||||
}
|
||||
|
||||
enum TypeParameters<'self> {
|
||||
enum TypeParameters<'a> {
|
||||
NoTypeParameters, //< No type parameters.
|
||||
HasTypeParameters(&'self Generics, //< Type parameters.
|
||||
HasTypeParameters(&'a Generics, //< Type parameters.
|
||||
NodeId, //< ID of the enclosing item
|
||||
|
||||
// The index to start numbering the type parameters at.
|
||||
@ -881,11 +881,11 @@ struct Resolver {
|
||||
used_imports: HashSet<NodeId>,
|
||||
}
|
||||
|
||||
struct BuildReducedGraphVisitor<'self> {
|
||||
resolver: &'self mut Resolver,
|
||||
struct BuildReducedGraphVisitor<'a> {
|
||||
resolver: &'a mut Resolver,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'self> {
|
||||
impl<'a> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'a> {
|
||||
|
||||
fn visit_item(&mut self, item:@item, context:ReducedGraphParent) {
|
||||
let p = self.resolver.build_reduced_graph_for_item(item, context);
|
||||
@ -913,9 +913,9 @@ impl<'self> Visitor<ReducedGraphParent> for BuildReducedGraphVisitor<'self> {
|
||||
|
||||
}
|
||||
|
||||
struct UnusedImportCheckVisitor<'self> { resolver: &'self Resolver }
|
||||
struct UnusedImportCheckVisitor<'a> { resolver: &'a Resolver }
|
||||
|
||||
impl<'self> Visitor<()> for UnusedImportCheckVisitor<'self> {
|
||||
impl<'a> Visitor<()> for UnusedImportCheckVisitor<'a> {
|
||||
fn visit_view_item(&mut self, vi:&view_item, _:()) {
|
||||
self.resolver.check_for_item_unused_imports(vi);
|
||||
visit::walk_view_item(self, vi, ());
|
||||
|
@ -36,10 +36,10 @@ struct LifetimeContext {
|
||||
named_region_map: @mut NamedRegionMap,
|
||||
}
|
||||
|
||||
enum ScopeChain<'self> {
|
||||
ItemScope(&'self OptVec<ast::Lifetime>),
|
||||
FnScope(ast::NodeId, &'self OptVec<ast::Lifetime>, &'self ScopeChain<'self>),
|
||||
BlockScope(ast::NodeId, &'self ScopeChain<'self>),
|
||||
enum ScopeChain<'a> {
|
||||
ItemScope(&'a OptVec<ast::Lifetime>),
|
||||
FnScope(ast::NodeId, &'a OptVec<ast::Lifetime>, &'a ScopeChain<'a>),
|
||||
BlockScope(ast::NodeId, &'a ScopeChain<'a>),
|
||||
RootScope
|
||||
}
|
||||
|
||||
@ -55,10 +55,10 @@ pub fn crate(sess: session::Session,
|
||||
ctxt.named_region_map
|
||||
}
|
||||
|
||||
impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
impl<'a> Visitor<&'a ScopeChain<'a>> for LifetimeContext {
|
||||
fn visit_item(&mut self,
|
||||
item: @ast::item,
|
||||
_: &'self ScopeChain<'self>) {
|
||||
_: &'a ScopeChain<'a>) {
|
||||
let scope = match item.node {
|
||||
ast::item_fn(..) | // fn lifetimes get added in visit_fn below
|
||||
ast::item_mod(..) |
|
||||
@ -87,7 +87,7 @@ impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
b: ast::P<ast::Block>,
|
||||
s: Span,
|
||||
n: ast::NodeId,
|
||||
scope: &'self ScopeChain<'self>) {
|
||||
scope: &'a ScopeChain<'a>) {
|
||||
match *fk {
|
||||
visit::fk_item_fn(_, generics, _, _) |
|
||||
visit::fk_method(_, generics, _) => {
|
||||
@ -105,7 +105,7 @@ impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
|
||||
fn visit_ty(&mut self,
|
||||
ty: &ast::Ty,
|
||||
scope: &'self ScopeChain<'self>) {
|
||||
scope: &'a ScopeChain<'a>) {
|
||||
match ty.node {
|
||||
ast::ty_closure(@ast::TyClosure { lifetimes: ref lifetimes, .. }) |
|
||||
ast::ty_bare_fn(@ast::TyBareFn { lifetimes: ref lifetimes, .. }) => {
|
||||
@ -123,7 +123,7 @@ impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
|
||||
fn visit_ty_method(&mut self,
|
||||
m: &ast::TypeMethod,
|
||||
scope: &'self ScopeChain<'self>) {
|
||||
scope: &'a ScopeChain<'a>) {
|
||||
let scope1 = FnScope(m.id, &m.generics.lifetimes, scope);
|
||||
self.check_lifetime_names(&m.generics.lifetimes);
|
||||
debug!("pushing fn scope id={} due to ty_method", m.id);
|
||||
@ -133,7 +133,7 @@ impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
|
||||
fn visit_block(&mut self,
|
||||
b: ast::P<ast::Block>,
|
||||
scope: &'self ScopeChain<'self>) {
|
||||
scope: &'a ScopeChain<'a>) {
|
||||
let scope1 = BlockScope(b.id, scope);
|
||||
debug!("pushing block scope {}", b.id);
|
||||
visit::walk_block(self, b, &scope1);
|
||||
@ -142,7 +142,7 @@ impl<'self> Visitor<&'self ScopeChain<'self>> for LifetimeContext {
|
||||
|
||||
fn visit_lifetime_ref(&mut self,
|
||||
lifetime_ref: &ast::Lifetime,
|
||||
scope: &'self ScopeChain<'self>) {
|
||||
scope: &'a ScopeChain<'a>) {
|
||||
if lifetime_ref.ident == special_idents::statik {
|
||||
self.insert_lifetime(lifetime_ref, ast::DefStaticRegion);
|
||||
return;
|
||||
|
@ -45,12 +45,12 @@ impl Subst for ty::t {
|
||||
}
|
||||
}
|
||||
|
||||
struct SubstFolder<'self> {
|
||||
struct SubstFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
substs: &'self ty::substs
|
||||
substs: &'a ty::substs
|
||||
}
|
||||
|
||||
impl<'self> TypeFolder for SubstFolder<'self> {
|
||||
impl<'a> TypeFolder for SubstFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_region(&mut self, r: ty::Region) -> ty::Region {
|
||||
|
@ -394,9 +394,9 @@ struct BindingInfo {
|
||||
type BindingsMap = HashMap<Ident, BindingInfo>;
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct ArmData<'self> {
|
||||
struct ArmData<'a> {
|
||||
bodycx: @mut Block,
|
||||
arm: &'self ast::Arm,
|
||||
arm: &'a ast::Arm,
|
||||
bindings_map: @BindingsMap
|
||||
}
|
||||
|
||||
@ -407,13 +407,13 @@ struct ArmData<'self> {
|
||||
* these pointers are stored in llmatch variables just before executing `data` arm.
|
||||
*/
|
||||
#[deriving(Clone)]
|
||||
struct Match<'self> {
|
||||
struct Match<'a> {
|
||||
pats: ~[@ast::Pat],
|
||||
data: ArmData<'self>,
|
||||
data: ArmData<'a>,
|
||||
bound_ptrs: ~[(Ident, ValueRef)]
|
||||
}
|
||||
|
||||
impl<'self> Repr for Match<'self> {
|
||||
impl<'a> Repr for Match<'a> {
|
||||
fn repr(&self, tcx: ty::ctxt) -> ~str {
|
||||
if tcx.sess.verbose() {
|
||||
// for many programs, this just take too long to serialize
|
||||
@ -477,7 +477,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) {
|
||||
}
|
||||
}
|
||||
|
||||
type enter_pat<'self> = 'self |@ast::Pat| -> Option<~[@ast::Pat]>;
|
||||
type enter_pat<'a> = 'a |@ast::Pat| -> Option<~[@ast::Pat]>;
|
||||
|
||||
fn enter_match<'r>(bcx: @mut Block,
|
||||
dm: DefMap,
|
||||
|
@ -130,16 +130,16 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
|
||||
_InsnCtxt { _x: () }
|
||||
}
|
||||
|
||||
struct StatRecorder<'self> {
|
||||
struct StatRecorder<'a> {
|
||||
ccx: @mut CrateContext,
|
||||
name: &'self str,
|
||||
name: &'a str,
|
||||
start: u64,
|
||||
istart: uint,
|
||||
}
|
||||
|
||||
impl<'self> StatRecorder<'self> {
|
||||
impl<'a> StatRecorder<'a> {
|
||||
pub fn new(ccx: @mut CrateContext,
|
||||
name: &'self str) -> StatRecorder<'self> {
|
||||
name: &'a str) -> StatRecorder<'a> {
|
||||
let start = if ccx.sess.trans_stats() {
|
||||
time::precise_time_ns()
|
||||
} else {
|
||||
@ -156,7 +156,7 @@ impl<'self> StatRecorder<'self> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'self> Drop for StatRecorder<'self> {
|
||||
impl<'a> Drop for StatRecorder<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.ccx.sess.trans_stats() {
|
||||
let end = time::precise_time_ns();
|
||||
@ -668,7 +668,7 @@ pub fn compare_scalar_values(cx: @mut Block,
|
||||
}
|
||||
}
|
||||
|
||||
pub type val_and_ty_fn<'self> = 'self |@mut Block, ValueRef, ty::t|
|
||||
pub type val_and_ty_fn<'a> = 'a |@mut Block, ValueRef, ty::t|
|
||||
-> @mut Block;
|
||||
|
||||
pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
|
||||
|
@ -14,7 +14,7 @@ use std::iter::{Filter, Map};
|
||||
|
||||
pub struct BasicBlock(BasicBlockRef);
|
||||
|
||||
pub type PredIterator<'self> = Map<'self, Value, BasicBlock, Filter<'self, Value, UserIterator>>;
|
||||
pub type PredIterator<'a> = Map<'a, Value, BasicBlock, Filter<'a, Value, UserIterator>>;
|
||||
|
||||
/**
|
||||
* Wrapper for LLVM BasicBlockRef
|
||||
|
@ -67,7 +67,7 @@ trait ClassList {
|
||||
fn is_ret_bysret(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<'self> ClassList for &'self [RegClass] {
|
||||
impl<'a> ClassList for &'a [RegClass] {
|
||||
fn is_pass_byval(&self) -> bool {
|
||||
if self.len() == 0 { return false; }
|
||||
|
||||
|
@ -750,9 +750,9 @@ pub fn trans_call_inner(in_cx: @mut Block,
|
||||
})
|
||||
}
|
||||
|
||||
pub enum CallArgs<'self> {
|
||||
ArgExprs(&'self [@ast::Expr]),
|
||||
ArgVals(&'self [ValueRef])
|
||||
pub enum CallArgs<'a> {
|
||||
ArgExprs(&'a [@ast::Expr]),
|
||||
ArgVals(&'a [ValueRef])
|
||||
}
|
||||
|
||||
pub fn trans_args(cx: @mut Block,
|
||||
|
@ -214,12 +214,12 @@ struct FunctionDebugContextData {
|
||||
source_locations_enabled: bool,
|
||||
}
|
||||
|
||||
enum VariableAccess<'self> {
|
||||
enum VariableAccess<'a> {
|
||||
// The llptr given is an alloca containing the variable's value
|
||||
DirectVariable { alloca: ValueRef },
|
||||
// The llptr given is an alloca containing the start of some pointer chain leading to the
|
||||
// variable's content.
|
||||
IndirectVariable { alloca: ValueRef, address_operations: &'self [ValueRef] }
|
||||
IndirectVariable { alloca: ValueRef, address_operations: &'a [ValueRef] }
|
||||
}
|
||||
|
||||
enum VariableKind {
|
||||
|
@ -641,7 +641,7 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
|
||||
return inf;
|
||||
}
|
||||
|
||||
pub type glue_helper<'self> = 'self |@mut Block, ValueRef, ty::t|
|
||||
pub type glue_helper<'a> = 'a |@mut Block, ValueRef, ty::t|
|
||||
-> @mut Block;
|
||||
|
||||
pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
|
||||
|
@ -16,7 +16,7 @@ pub trait LlvmRepr {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> ~str;
|
||||
}
|
||||
|
||||
impl<'self, T:LlvmRepr> LlvmRepr for &'self [T] {
|
||||
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> ~str {
|
||||
let reprs = self.map(|t| t.llrepr(ccx));
|
||||
format!("[{}]", reprs.connect(","))
|
||||
|
@ -539,7 +539,7 @@ pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (Val
|
||||
}
|
||||
}
|
||||
|
||||
pub type iter_vec_block<'self> = 'self |@mut Block, ValueRef, ty::t|
|
||||
pub type iter_vec_block<'a> = 'a |@mut Block, ValueRef, ty::t|
|
||||
-> @mut Block;
|
||||
|
||||
pub fn iter_vec_loop(bcx: @mut Block,
|
||||
|
@ -1408,13 +1408,13 @@ pub fn subst_tps(tcx: ctxt, tps: &[t], self_ty_opt: Option<t>, typ: t) -> t {
|
||||
let mut subst = TpsSubst { tcx: tcx, self_ty_opt: self_ty_opt, tps: tps };
|
||||
return subst.fold_ty(typ);
|
||||
|
||||
struct TpsSubst<'self> {
|
||||
struct TpsSubst<'a> {
|
||||
tcx: ctxt,
|
||||
self_ty_opt: Option<t>,
|
||||
tps: &'self [t],
|
||||
tps: &'a [t],
|
||||
}
|
||||
|
||||
impl<'self> TypeFolder for TpsSubst<'self> {
|
||||
impl<'a> TypeFolder for TpsSubst<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, t: ty::t) -> ty::t {
|
||||
|
@ -222,12 +222,12 @@ pub fn super_fold_trait_store<T:TypeFolder>(this: &mut T,
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Some sample folders
|
||||
|
||||
pub struct BottomUpFolder<'self> {
|
||||
pub struct BottomUpFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
fldop: 'self |ty::t| -> ty::t,
|
||||
fldop: 'a |ty::t| -> ty::t,
|
||||
}
|
||||
|
||||
impl<'self> TypeFolder for BottomUpFolder<'self> {
|
||||
impl<'a> TypeFolder for BottomUpFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: ty::t) -> ty::t {
|
||||
@ -239,17 +239,17 @@ impl<'self> TypeFolder for BottomUpFolder<'self> {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Region folder
|
||||
|
||||
pub struct RegionFolder<'self> {
|
||||
pub struct RegionFolder<'a> {
|
||||
tcx: ty::ctxt,
|
||||
fld_t: 'self |ty::t| -> ty::t,
|
||||
fld_r: 'self |ty::Region| -> ty::Region,
|
||||
fld_t: 'a |ty::t| -> ty::t,
|
||||
fld_r: 'a |ty::Region| -> ty::Region,
|
||||
}
|
||||
|
||||
impl<'self> RegionFolder<'self> {
|
||||
impl<'a> RegionFolder<'a> {
|
||||
pub fn general(tcx: ty::ctxt,
|
||||
fld_r: 'self |ty::Region| -> ty::Region,
|
||||
fld_t: 'self |ty::t| -> ty::t)
|
||||
-> RegionFolder<'self> {
|
||||
fld_r: 'a |ty::Region| -> ty::Region,
|
||||
fld_t: 'a |ty::t| -> ty::t)
|
||||
-> RegionFolder<'a> {
|
||||
RegionFolder {
|
||||
tcx: tcx,
|
||||
fld_t: fld_t,
|
||||
@ -257,8 +257,8 @@ impl<'self> RegionFolder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn regions(tcx: ty::ctxt, fld_r: 'self |ty::Region| -> ty::Region)
|
||||
-> RegionFolder<'self> {
|
||||
pub fn regions(tcx: ty::ctxt, fld_r: 'a |ty::Region| -> ty::Region)
|
||||
-> RegionFolder<'a> {
|
||||
fn noop(t: ty::t) -> ty::t { t }
|
||||
|
||||
RegionFolder {
|
||||
@ -269,7 +269,7 @@ impl<'self> RegionFolder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> TypeFolder for RegionFolder<'self> {
|
||||
impl<'a> TypeFolder for RegionFolder<'a> {
|
||||
fn tcx(&self) -> ty::ctxt { self.tcx }
|
||||
|
||||
fn fold_ty(&mut self, ty: ty::t) -> ty::t {
|
||||
|
@ -40,7 +40,7 @@
|
||||
* as it does not already appear in scope.
|
||||
*
|
||||
* Case (b) says that if you have a type:
|
||||
* type foo<'self> = ...;
|
||||
* type foo<'a> = ...;
|
||||
* type bar = fn(&foo, &a.foo)
|
||||
* The fully expanded version of type bar is:
|
||||
* type bar = fn(&'foo &, &a.foo<'a>)
|
||||
|
@ -167,13 +167,13 @@ pub fn lookup(
|
||||
return lcx.search(self_ty);
|
||||
}
|
||||
|
||||
pub struct LookupContext<'self> {
|
||||
pub struct LookupContext<'a> {
|
||||
fcx: @mut FnCtxt,
|
||||
expr: @ast::Expr,
|
||||
self_expr: @ast::Expr,
|
||||
callee_id: NodeId,
|
||||
m_name: ast::Name,
|
||||
supplied_tps: &'self [ty::t],
|
||||
supplied_tps: &'a [ty::t],
|
||||
impl_dups: @mut HashSet<DefId>,
|
||||
inherent_candidates: @mut ~[Candidate],
|
||||
extension_candidates: @mut ~[Candidate],
|
||||
@ -208,7 +208,7 @@ enum RcvrMatchCondition {
|
||||
RcvrMatchesIfSubtype(ty::t)
|
||||
}
|
||||
|
||||
impl<'self> LookupContext<'self> {
|
||||
impl<'a> LookupContext<'a> {
|
||||
fn search(&self, self_ty: ty::t) -> Option<method_map_entry> {
|
||||
let mut self_ty = self_ty;
|
||||
let mut autoderefs = 0;
|
||||
|
@ -918,7 +918,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
|
||||
// Create a substitution that maps the type parameters on the impl
|
||||
// to themselves and which replace any references to bound regions
|
||||
// in the self type with free regions. So, for example, if the
|
||||
// impl type is "&'self str", then this would replace the self
|
||||
// impl type is "&'a str", then this would replace the self
|
||||
// type with a free region `self`.
|
||||
let dummy_impl_tps: ~[ty::t] =
|
||||
impl_generics.type_param_defs.iter().enumerate().
|
||||
|
@ -85,17 +85,17 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
|
||||
}
|
||||
rr.fold_ty(ty);
|
||||
|
||||
struct RegionRelator<'self> {
|
||||
struct RegionRelator<'a> {
|
||||
tcx: ty::ctxt,
|
||||
stack: ~[ty::Region],
|
||||
relate_op: 'self |ty::Region, ty::Region|,
|
||||
relate_op: 'a |ty::Region, ty::Region|,
|
||||
}
|
||||
|
||||
// FIXME(#10151) -- Define more precisely when a region is
|
||||
// considered "nested". Consider taking variance into account as
|
||||
// well.
|
||||
|
||||
impl<'self> TypeFolder for RegionRelator<'self> {
|
||||
impl<'a> TypeFolder for RegionRelator<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
self.tcx
|
||||
}
|
||||
@ -124,7 +124,7 @@ pub fn relate_nested_regions(tcx: ty::ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> RegionRelator<'self> {
|
||||
impl<'a> RegionRelator<'a> {
|
||||
fn relate(&mut self, r_sub: ty::Region) {
|
||||
for &r in self.stack.iter() {
|
||||
if !r.is_bound() && !r_sub.is_bound() {
|
||||
|
@ -69,12 +69,12 @@ pub struct LocationInfo {
|
||||
|
||||
/// A vtable context includes an inference context, a crate context, and a
|
||||
/// callback function to call in case of type error.
|
||||
pub struct VtableContext<'self> {
|
||||
pub struct VtableContext<'a> {
|
||||
infcx: @mut infer::InferCtxt,
|
||||
param_env: &'self ty::ParameterEnvironment,
|
||||
param_env: &'a ty::ParameterEnvironment,
|
||||
}
|
||||
|
||||
impl<'self> VtableContext<'self> {
|
||||
impl<'a> VtableContext<'a> {
|
||||
pub fn tcx(&self) -> ty::ctxt { self.infcx.tcx }
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ pub trait LatticeValue {
|
||||
fn glb(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
|
||||
}
|
||||
|
||||
pub type LatticeOp<'self, T> =
|
||||
'self |cf: &CombineFields, a: &T, b: &T| -> cres<T>;
|
||||
pub type LatticeOp<'a, T> =
|
||||
'a |cf: &CombineFields, a: &T, b: &T| -> cres<T>;
|
||||
|
||||
impl LatticeValue for ty::t {
|
||||
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
|
||||
@ -405,7 +405,7 @@ pub fn super_lattice_tys<L:LatticeDir+TyLatticeDir+Combine>(this: &L,
|
||||
}
|
||||
}
|
||||
|
||||
pub type LatticeDirOp<'self, T> = 'self |a: &T, b: &T| -> cres<T>;
|
||||
pub type LatticeDirOp<'a, T> = 'a |a: &T, b: &T| -> cres<T>;
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum LatticeVarResult<V,T> {
|
||||
|
@ -406,7 +406,7 @@ Now let's consider two more function types. Here, we assume that the
|
||||
`self` lifetime is defined somewhere outside and hence is not a
|
||||
lifetime parameter bound by the function type (it "appears free"):
|
||||
|
||||
fn<a>(&'a int) <: |&'self int|? (Yes, a => self)
|
||||
fn<a>(&'a int) <: |&'a int|? (Yes, a => self)
|
||||
|
||||
This subtyping relation does in fact hold. To see why, you have to
|
||||
consider what subtyping means. One way to look at `T1 <: T2` is to
|
||||
@ -423,7 +423,7 @@ to the same thing: a function that accepts pointers with any lifetime
|
||||
|
||||
So, what if we reverse the order of the two function types, like this:
|
||||
|
||||
fn(&'self int) <: <a>|&'a int|? (No)
|
||||
fn(&'a int) <: <a>|&'a int|? (No)
|
||||
|
||||
Does the subtyping relationship still hold? The answer of course is
|
||||
no. In this case, the function accepts *only the lifetime `&self`*,
|
||||
@ -491,12 +491,12 @@ So far we have encountered no error, so the subtype check succeeds.
|
||||
|
||||
Now let's look first at the third example, which was:
|
||||
|
||||
3. fn(&'self T) <: <b>|&'b T|? No!
|
||||
3. fn(&'a T) <: <b>|&'b T|? No!
|
||||
|
||||
After steps 1 and 2 of the algorithm we will have replaced the types
|
||||
like so:
|
||||
|
||||
3. fn(&'self T) <: |&'x T|?
|
||||
3. fn(&'a T) <: |&'x T|?
|
||||
|
||||
This looks pretty much the same as before, except that on the LHS
|
||||
`&self` was not bound, and hence was left as-is and not replaced with
|
||||
|
@ -218,7 +218,7 @@ pub fn infer_variance(tcx: ty::ctxt,
|
||||
*
|
||||
* Terms are structured as a straightforward tree. Rather than rely on
|
||||
* GC, we allocate terms out of a bounded arena (the lifetime of this
|
||||
* arena is the lifetime 'self that is threaded around).
|
||||
* arena is the lifetime 'a that is threaded around).
|
||||
*
|
||||
* We assign a unique index to each type/region parameter whose variance
|
||||
* is to be inferred. We refer to such variables as "inferreds". An
|
||||
@ -226,17 +226,17 @@ pub fn infer_variance(tcx: ty::ctxt,
|
||||
* a variable.
|
||||
*/
|
||||
|
||||
type VarianceTermPtr<'self> = &'self VarianceTerm<'self>;
|
||||
type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
|
||||
|
||||
struct InferredIndex(uint);
|
||||
|
||||
enum VarianceTerm<'self> {
|
||||
enum VarianceTerm<'a> {
|
||||
ConstantTerm(ty::Variance),
|
||||
TransformTerm(VarianceTermPtr<'self>, VarianceTermPtr<'self>),
|
||||
TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>),
|
||||
InferredTerm(InferredIndex),
|
||||
}
|
||||
|
||||
impl<'self> ToStr for VarianceTerm<'self> {
|
||||
impl<'a> ToStr for VarianceTerm<'a> {
|
||||
fn to_str(&self) -> ~str {
|
||||
match *self {
|
||||
ConstantTerm(c1) => format!("{}", c1.to_str()),
|
||||
@ -251,9 +251,9 @@ impl<'self> ToStr for VarianceTerm<'self> {
|
||||
* The first pass over the crate simply builds up the set of inferreds.
|
||||
*/
|
||||
|
||||
struct TermsContext<'self> {
|
||||
struct TermsContext<'a> {
|
||||
tcx: ty::ctxt,
|
||||
arena: &'self Arena,
|
||||
arena: &'a Arena,
|
||||
|
||||
empty_variances: @ty::ItemVariances,
|
||||
|
||||
@ -262,17 +262,17 @@ struct TermsContext<'self> {
|
||||
inferred_map: HashMap<ast::NodeId, InferredIndex>,
|
||||
|
||||
// Maps from an InferredIndex to the info for that variable.
|
||||
inferred_infos: ~[InferredInfo<'self>],
|
||||
inferred_infos: ~[InferredInfo<'a>],
|
||||
}
|
||||
|
||||
enum ParamKind { TypeParam, RegionParam, SelfParam }
|
||||
|
||||
struct InferredInfo<'self> {
|
||||
struct InferredInfo<'a> {
|
||||
item_id: ast::NodeId,
|
||||
kind: ParamKind,
|
||||
index: uint,
|
||||
param_id: ast::NodeId,
|
||||
term: VarianceTermPtr<'self>,
|
||||
term: VarianceTermPtr<'a>,
|
||||
}
|
||||
|
||||
fn determine_parameters_to_be_inferred<'a>(tcx: ty::ctxt,
|
||||
@ -297,7 +297,7 @@ fn determine_parameters_to_be_inferred<'a>(tcx: ty::ctxt,
|
||||
terms_cx
|
||||
}
|
||||
|
||||
impl<'self> TermsContext<'self> {
|
||||
impl<'a> TermsContext<'a> {
|
||||
fn add_inferred(&mut self,
|
||||
item_id: ast::NodeId,
|
||||
kind: ParamKind,
|
||||
@ -326,7 +326,7 @@ impl<'self> TermsContext<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for TermsContext<'self> {
|
||||
impl<'a> Visitor<()> for TermsContext<'a> {
|
||||
fn visit_item(&mut self,
|
||||
item: @ast::item,
|
||||
(): ()) {
|
||||
@ -392,23 +392,23 @@ impl<'self> Visitor<()> for TermsContext<'self> {
|
||||
* We walk the set of items and, for each member, generate new constraints.
|
||||
*/
|
||||
|
||||
struct ConstraintContext<'self> {
|
||||
terms_cx: TermsContext<'self>,
|
||||
struct ConstraintContext<'a> {
|
||||
terms_cx: TermsContext<'a>,
|
||||
|
||||
// These are pointers to common `ConstantTerm` instances
|
||||
covariant: VarianceTermPtr<'self>,
|
||||
contravariant: VarianceTermPtr<'self>,
|
||||
invariant: VarianceTermPtr<'self>,
|
||||
bivariant: VarianceTermPtr<'self>,
|
||||
covariant: VarianceTermPtr<'a>,
|
||||
contravariant: VarianceTermPtr<'a>,
|
||||
invariant: VarianceTermPtr<'a>,
|
||||
bivariant: VarianceTermPtr<'a>,
|
||||
|
||||
constraints: ~[Constraint<'self>],
|
||||
constraints: ~[Constraint<'a>],
|
||||
}
|
||||
|
||||
/// Declares that the variable `decl_id` appears in a location with
|
||||
/// variance `variance`.
|
||||
struct Constraint<'self> {
|
||||
struct Constraint<'a> {
|
||||
inferred: InferredIndex,
|
||||
variance: &'self VarianceTerm<'self>,
|
||||
variance: &'a VarianceTerm<'a>,
|
||||
}
|
||||
|
||||
fn add_constraints_from_crate<'a>(terms_cx: TermsContext<'a>,
|
||||
@ -430,7 +430,7 @@ fn add_constraints_from_crate<'a>(terms_cx: TermsContext<'a>,
|
||||
constraint_cx
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for ConstraintContext<'self> {
|
||||
impl<'a> Visitor<()> for ConstraintContext<'a> {
|
||||
fn visit_item(&mut self,
|
||||
item: @ast::item,
|
||||
(): ()) {
|
||||
@ -506,7 +506,7 @@ impl<'self> Visitor<()> for ConstraintContext<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> ConstraintContext<'self> {
|
||||
impl<'a> ConstraintContext<'a> {
|
||||
fn tcx(&self) -> ty::ctxt {
|
||||
self.terms_cx.tcx
|
||||
}
|
||||
@ -529,7 +529,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
item_def_id: ast::DefId,
|
||||
kind: ParamKind,
|
||||
index: uint)
|
||||
-> VarianceTermPtr<'self> {
|
||||
-> VarianceTermPtr<'a> {
|
||||
/*!
|
||||
* Returns a variance term representing the declared variance of
|
||||
* the type/region parameter with the given id.
|
||||
@ -557,7 +557,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
|
||||
fn add_constraint(&mut self,
|
||||
index: InferredIndex,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
debug!("add_constraint(index={}, variance={})",
|
||||
*index, variance.to_str());
|
||||
self.constraints.push(Constraint { inferred: index,
|
||||
@ -565,18 +565,18 @@ impl<'self> ConstraintContext<'self> {
|
||||
}
|
||||
|
||||
fn contravariant(&mut self,
|
||||
variance: VarianceTermPtr<'self>)
|
||||
-> VarianceTermPtr<'self> {
|
||||
variance: VarianceTermPtr<'a>)
|
||||
-> VarianceTermPtr<'a> {
|
||||
self.xform(variance, self.contravariant)
|
||||
}
|
||||
|
||||
fn invariant(&mut self,
|
||||
variance: VarianceTermPtr<'self>)
|
||||
-> VarianceTermPtr<'self> {
|
||||
variance: VarianceTermPtr<'a>)
|
||||
-> VarianceTermPtr<'a> {
|
||||
self.xform(variance, self.invariant)
|
||||
}
|
||||
|
||||
fn constant_term(&self, v: ty::Variance) -> VarianceTermPtr<'self> {
|
||||
fn constant_term(&self, v: ty::Variance) -> VarianceTermPtr<'a> {
|
||||
match v {
|
||||
ty::Covariant => self.covariant,
|
||||
ty::Invariant => self.invariant,
|
||||
@ -586,9 +586,9 @@ impl<'self> ConstraintContext<'self> {
|
||||
}
|
||||
|
||||
fn xform(&mut self,
|
||||
v1: VarianceTermPtr<'self>,
|
||||
v2: VarianceTermPtr<'self>)
|
||||
-> VarianceTermPtr<'self> {
|
||||
v1: VarianceTermPtr<'a>,
|
||||
v2: VarianceTermPtr<'a>)
|
||||
-> VarianceTermPtr<'a> {
|
||||
match (*v1, *v2) {
|
||||
(_, ConstantTerm(ty::Covariant)) => {
|
||||
// Applying a "covariant" transform is always a no-op
|
||||
@ -609,7 +609,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
/// in a context with ambient variance `variance`
|
||||
fn add_constraints_from_ty(&mut self,
|
||||
ty: ty::t,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
|
||||
|
||||
match ty::get(ty).sty {
|
||||
@ -704,7 +704,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
/// appearing in a context with ambient variance `variance`
|
||||
fn add_constraints_from_vstore(&mut self,
|
||||
vstore: ty::vstore,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
match vstore {
|
||||
ty::vstore_slice(r) => {
|
||||
let contra = self.contravariant(variance);
|
||||
@ -722,7 +722,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
def_id: ast::DefId,
|
||||
generics: &ty::Generics,
|
||||
substs: &ty::substs,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
debug!("add_constraints_from_substs(def_id={:?})", def_id);
|
||||
|
||||
for (i, p) in generics.type_param_defs.iter().enumerate() {
|
||||
@ -749,7 +749,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
/// `sig` appearing in a context with ambient variance `variance`
|
||||
fn add_constraints_from_sig(&mut self,
|
||||
sig: &ty::FnSig,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
let contra = self.contravariant(variance);
|
||||
for &input in sig.inputs.iter() {
|
||||
self.add_constraints_from_ty(input, contra);
|
||||
@ -761,7 +761,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
/// context with ambient variance `variance`
|
||||
fn add_constraints_from_region(&mut self,
|
||||
region: ty::Region,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
match region {
|
||||
ty::ReEarlyBound(param_id, _, _) => {
|
||||
let index = self.inferred_index(param_id);
|
||||
@ -790,7 +790,7 @@ impl<'self> ConstraintContext<'self> {
|
||||
/// appearing in a context with ambient variance `variance`
|
||||
fn add_constraints_from_mt(&mut self,
|
||||
mt: &ty::mt,
|
||||
variance: VarianceTermPtr<'self>) {
|
||||
variance: VarianceTermPtr<'a>) {
|
||||
match mt.mutbl {
|
||||
ast::MutMutable => {
|
||||
let invar = self.invariant(variance);
|
||||
@ -813,9 +813,9 @@ impl<'self> ConstraintContext<'self> {
|
||||
* inferred is then written into the `variance_map` in the tcx.
|
||||
*/
|
||||
|
||||
struct SolveContext<'self> {
|
||||
terms_cx: TermsContext<'self>,
|
||||
constraints: ~[Constraint<'self>],
|
||||
struct SolveContext<'a> {
|
||||
terms_cx: TermsContext<'a>,
|
||||
constraints: ~[Constraint<'a>],
|
||||
|
||||
// Maps from an InferredIndex to the inferred value for that variable.
|
||||
solutions: ~[ty::Variance]
|
||||
@ -833,7 +833,7 @@ fn solve_constraints(constraints_cx: ConstraintContext) {
|
||||
solutions_cx.write();
|
||||
}
|
||||
|
||||
impl<'self> SolveContext<'self> {
|
||||
impl<'a> SolveContext<'a> {
|
||||
fn solve(&mut self) {
|
||||
// Propagate constraints until a fixed point is reached. Note
|
||||
// that the maximum number of iterations is 2C where C is the
|
||||
@ -925,7 +925,7 @@ impl<'self> SolveContext<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn evaluate(&self, term: VarianceTermPtr<'self>) -> ty::Variance {
|
||||
fn evaluate(&self, term: VarianceTermPtr<'a>) -> ty::Variance {
|
||||
match *term {
|
||||
ConstantTerm(v) => {
|
||||
v
|
||||
|
@ -69,12 +69,12 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] {
|
||||
fields.map(|f| f.expr)
|
||||
}
|
||||
|
||||
struct LoopQueryVisitor<'self> {
|
||||
p: 'self |&ast::Expr_| -> bool,
|
||||
struct LoopQueryVisitor<'a> {
|
||||
p: 'a |&ast::Expr_| -> bool,
|
||||
flag: bool,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for LoopQueryVisitor<'self> {
|
||||
impl<'a> Visitor<()> for LoopQueryVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: @ast::Expr, _: ()) {
|
||||
self.flag |= (self.p)(&e.node);
|
||||
match e.node {
|
||||
@ -97,12 +97,12 @@ pub fn loop_query(b: ast::P<ast::Block>, p: |&ast::Expr_| -> bool) -> bool {
|
||||
return v.flag;
|
||||
}
|
||||
|
||||
struct BlockQueryVisitor<'self> {
|
||||
p: 'self |@ast::Expr| -> bool,
|
||||
struct BlockQueryVisitor<'a> {
|
||||
p: 'a |@ast::Expr| -> bool,
|
||||
flag: bool,
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for BlockQueryVisitor<'self> {
|
||||
impl<'a> Visitor<()> for BlockQueryVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: @ast::Expr, _:()) {
|
||||
self.flag |= (self.p)(e);
|
||||
visit::walk_expr(self, e, ())
|
||||
|
@ -567,7 +567,7 @@ fn repr_vec<T:Repr>(tcx: ctxt, v: &[T]) -> ~str {
|
||||
vec_map_to_str(v, |t| t.repr(tcx))
|
||||
}
|
||||
|
||||
impl<'self, T:Repr> Repr for &'self [T] {
|
||||
impl<'a, T:Repr> Repr for &'a [T] {
|
||||
fn repr(&self, tcx: ctxt) -> ~str {
|
||||
repr_vec(tcx, *self)
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ impl Clean<Attribute> for ast::Attribute {
|
||||
}
|
||||
|
||||
// This is a rough approximation that gets us what we want.
|
||||
impl<'self> attr::AttrMetaMethods for &'self Attribute {
|
||||
impl<'a> attr::AttrMetaMethods for &'a Attribute {
|
||||
fn name(&self) -> @str {
|
||||
match **self {
|
||||
Word(ref n) | List(ref n, _) | NameValue(ref n, _) =>
|
||||
|
@ -17,10 +17,10 @@ use std::fmt;
|
||||
|
||||
/// Wrapper struct which will emit the HTML-escaped version of the contained
|
||||
/// string when passed to a format string.
|
||||
pub struct Escape<'self>(&'self str);
|
||||
pub struct Escape<'a>(&'a str);
|
||||
|
||||
impl<'self> fmt::Default for Escape<'self> {
|
||||
fn fmt(s: &Escape<'self>, fmt: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Escape<'a> {
|
||||
fn fmt(s: &Escape<'a>, fmt: &mut fmt::Formatter) {
|
||||
// Because the internet is always right, turns out there's not that many
|
||||
// characters to escape: http://stackoverflow.com/questions/7381974
|
||||
let pile_o_bits = s.as_slice();
|
||||
|
@ -33,7 +33,7 @@ pub struct VisSpace(Option<ast::visibility>);
|
||||
/// space after it.
|
||||
pub struct PuritySpace(ast::purity);
|
||||
/// Wrapper struct for properly emitting a method declaration.
|
||||
pub struct Method<'self>(&'self clean::SelfTy, &'self clean::FnDecl);
|
||||
pub struct Method<'a>(&'a clean::SelfTy, &'a clean::FnDecl);
|
||||
|
||||
impl fmt::Default for clean::Generics {
|
||||
fn fmt(g: &clean::Generics, f: &mut fmt::Formatter) {
|
||||
@ -393,8 +393,8 @@ impl fmt::Default for ~[clean::Argument] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> fmt::Default for Method<'self> {
|
||||
fn fmt(m: &Method<'self>, f: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Method<'a> {
|
||||
fn fmt(m: &Method<'a>, f: &mut fmt::Formatter) {
|
||||
let Method(selfty, d) = *m;
|
||||
let mut args = ~"";
|
||||
match *selfty {
|
||||
|
@ -18,10 +18,10 @@ pub struct Layout {
|
||||
crate: ~str,
|
||||
}
|
||||
|
||||
pub struct Page<'self> {
|
||||
title: &'self str,
|
||||
ty: &'self str,
|
||||
root_path: &'self str,
|
||||
pub struct Page<'a> {
|
||||
title: &'a str,
|
||||
ty: &'a str,
|
||||
root_path: &'a str,
|
||||
}
|
||||
|
||||
pub fn render<T: fmt::Default, S: fmt::Default>(
|
||||
|
@ -30,7 +30,7 @@ use std::vec;
|
||||
/// A unit struct which has the `fmt::Default` trait implemented. When
|
||||
/// formatted, this struct will emit the HTML corresponding to the rendered
|
||||
/// version of the contained markdown string.
|
||||
pub struct Markdown<'self>(&'self str);
|
||||
pub struct Markdown<'a>(&'a str);
|
||||
|
||||
static OUTPUT_UNIT: libc::size_t = 64;
|
||||
static MKDEXT_NO_INTRA_EMPHASIS: libc::c_uint = 1 << 0;
|
||||
@ -119,8 +119,8 @@ fn render(w: &mut io::Writer, s: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> fmt::Default for Markdown<'self> {
|
||||
fn fmt(md: &Markdown<'self>, fmt: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Markdown<'a> {
|
||||
fn fmt(md: &Markdown<'a>, fmt: &mut fmt::Formatter) {
|
||||
// This is actually common enough to special-case
|
||||
if md.len() == 0 { return; }
|
||||
render(fmt.buf, md.as_slice());
|
||||
|
@ -166,8 +166,8 @@ pub struct Cache {
|
||||
}
|
||||
|
||||
/// Helper struct to render all source code to HTML pages
|
||||
struct SourceCollector<'self> {
|
||||
cx: &'self mut Context,
|
||||
struct SourceCollector<'a> {
|
||||
cx: &'a mut Context,
|
||||
|
||||
/// Processed source-file paths
|
||||
seen: HashSet<~str>,
|
||||
@ -177,13 +177,13 @@ struct SourceCollector<'self> {
|
||||
|
||||
/// Wrapper struct to render the source code of a file. This will do things like
|
||||
/// adding line numbers to the left-hand side.
|
||||
struct Source<'self>(&'self str);
|
||||
struct Source<'a>(&'a str);
|
||||
|
||||
// Helper structs for rendering items/sidebars and carrying along contextual
|
||||
// information
|
||||
|
||||
struct Item<'self> { cx: &'self Context, item: &'self clean::Item, }
|
||||
struct Sidebar<'self> { cx: &'self Context, item: &'self clean::Item, }
|
||||
struct Item<'a> { cx: &'a Context, item: &'a clean::Item, }
|
||||
struct Sidebar<'a> { cx: &'a Context, item: &'a clean::Item, }
|
||||
|
||||
/// Struct representing one entry in the JS search index. These are all emitted
|
||||
/// by hand to a large JS file at the end of cache-creation.
|
||||
@ -380,7 +380,7 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
|
||||
return Unknown;
|
||||
}
|
||||
|
||||
impl<'self> DocFolder for SourceCollector<'self> {
|
||||
impl<'a> DocFolder for SourceCollector<'a> {
|
||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||
// If we're including source files, and we haven't seen this file yet,
|
||||
// then we need to render it out to the filesystem
|
||||
@ -406,7 +406,7 @@ impl<'self> DocFolder for SourceCollector<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> SourceCollector<'self> {
|
||||
impl<'a> SourceCollector<'a> {
|
||||
/// Renders the given filename into its corresponding HTML source file.
|
||||
fn emit_source(&mut self, filename: &str) -> bool {
|
||||
let p = Path::new(filename);
|
||||
@ -632,7 +632,7 @@ impl DocFolder for Cache {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Cache {
|
||||
impl<'a> Cache {
|
||||
fn generics(&mut self, generics: &clean::Generics) {
|
||||
for typ in generics.type_params.iter() {
|
||||
self.typarams.insert(typ.id, typ.name.clone());
|
||||
@ -862,7 +862,7 @@ fn shortty(item: &clean::Item) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Item<'self> {
|
||||
impl<'a> Item<'a> {
|
||||
fn ismodule(&self) -> bool {
|
||||
match self.item.inner {
|
||||
clean::ModuleItem(..) => true, _ => false
|
||||
@ -870,8 +870,8 @@ impl<'self> Item<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> fmt::Default for Item<'self> {
|
||||
fn fmt(it: &Item<'self>, fmt: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Item<'a> {
|
||||
fn fmt(it: &Item<'a>, fmt: &mut fmt::Formatter) {
|
||||
match attr::find_stability(it.item.attrs.iter()) {
|
||||
Some(stability) => {
|
||||
write!(fmt.buf,
|
||||
@ -1057,9 +1057,9 @@ fn item_module(w: &mut Writer, cx: &Context,
|
||||
|
||||
match myitem.inner {
|
||||
clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => {
|
||||
struct Initializer<'self>(&'self str);
|
||||
impl<'self> fmt::Default for Initializer<'self> {
|
||||
fn fmt(s: &Initializer<'self>, f: &mut fmt::Formatter) {
|
||||
struct Initializer<'a>(&'a str);
|
||||
impl<'a> fmt::Default for Initializer<'a> {
|
||||
fn fmt(s: &Initializer<'a>, f: &mut fmt::Formatter) {
|
||||
if s.len() == 0 { return; }
|
||||
write!(f.buf, "<code> = </code>");
|
||||
let tag = if s.contains("\n") { "pre" } else { "code" };
|
||||
@ -1563,8 +1563,8 @@ fn item_typedef(w: &mut Writer, it: &clean::Item, t: &clean::Typedef) {
|
||||
document(w, it);
|
||||
}
|
||||
|
||||
impl<'self> fmt::Default for Sidebar<'self> {
|
||||
fn fmt(s: &Sidebar<'self>, fmt: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Sidebar<'a> {
|
||||
fn fmt(s: &Sidebar<'a>, fmt: &mut fmt::Formatter) {
|
||||
let cx = s.cx;
|
||||
let it = s.item;
|
||||
write!(fmt.buf, "<p class='location'>");
|
||||
@ -1628,8 +1628,8 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
|
||||
return map;
|
||||
}
|
||||
|
||||
impl<'self> fmt::Default for Source<'self> {
|
||||
fn fmt(s: &Source<'self>, fmt: &mut fmt::Formatter) {
|
||||
impl<'a> fmt::Default for Source<'a> {
|
||||
fn fmt(s: &Source<'a>, fmt: &mut fmt::Formatter) {
|
||||
let lines = s.lines().len();
|
||||
let mut cols = 0;
|
||||
let mut tmp = lines;
|
||||
|
@ -76,12 +76,12 @@ pub fn strip_private(crate: clean::Crate) -> plugins::PluginResult {
|
||||
(crate, None)
|
||||
}
|
||||
|
||||
struct Stripper<'self> {
|
||||
retained: &'self mut HashSet<ast::NodeId>,
|
||||
exported_items: &'self HashSet<ast::NodeId>,
|
||||
struct Stripper<'a> {
|
||||
retained: &'a mut HashSet<ast::NodeId>,
|
||||
exported_items: &'a HashSet<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl<'self> fold::DocFolder for Stripper<'self> {
|
||||
impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
// These items can all get re-exported
|
||||
@ -150,8 +150,8 @@ impl<'self> fold::DocFolder for Stripper<'self> {
|
||||
}
|
||||
|
||||
// This stripper discards all private impls of traits
|
||||
struct ImplStripper<'self>(&'self HashSet<ast::NodeId>);
|
||||
impl<'self> fold::DocFolder for ImplStripper<'self> {
|
||||
struct ImplStripper<'a>(&'a HashSet<ast::NodeId>);
|
||||
impl<'a> fold::DocFolder for ImplStripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
clean::ImplItem(ref imp) => {
|
||||
|
@ -83,9 +83,9 @@ pub mod usage;
|
||||
/// A PkgScript represents user-supplied custom logic for
|
||||
/// special build hooks. This only exists for packages with
|
||||
/// an explicit package script.
|
||||
struct PkgScript<'self> {
|
||||
struct PkgScript<'a> {
|
||||
/// Uniquely identifies this package
|
||||
id: &'self PkgId,
|
||||
id: &'a PkgId,
|
||||
/// File path for the package script
|
||||
input: Path,
|
||||
/// The session to use *only* for compiling the custom
|
||||
@ -99,7 +99,7 @@ struct PkgScript<'self> {
|
||||
build_dir: Path
|
||||
}
|
||||
|
||||
impl<'self> PkgScript<'self> {
|
||||
impl<'a> PkgScript<'a> {
|
||||
/// Given the path name for a package script
|
||||
/// and a package ID, parse the package script into
|
||||
/// a PkgScript that we can then execute
|
||||
|
@ -427,18 +427,18 @@ pub fn compile_crate(ctxt: &BuildContext,
|
||||
compile_input(ctxt, exec, pkg_id, crate, workspace, deps, flags, cfgs, opt, what)
|
||||
}
|
||||
|
||||
struct ViewItemVisitor<'self> {
|
||||
context: &'self BuildContext,
|
||||
parent: &'self PkgId,
|
||||
parent_crate: &'self Path,
|
||||
struct ViewItemVisitor<'a> {
|
||||
context: &'a BuildContext,
|
||||
parent: &'a PkgId,
|
||||
parent_crate: &'a Path,
|
||||
sess: session::Session,
|
||||
exec: &'self mut workcache::Exec,
|
||||
c: &'self ast::Crate,
|
||||
save: 'self |Path|,
|
||||
deps: &'self mut DepMap
|
||||
exec: &'a mut workcache::Exec,
|
||||
c: &'a ast::Crate,
|
||||
save: 'a |Path|,
|
||||
deps: &'a mut DepMap
|
||||
}
|
||||
|
||||
impl<'self> Visitor<()> for ViewItemVisitor<'self> {
|
||||
impl<'a> Visitor<()> for ViewItemVisitor<'a> {
|
||||
fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) {
|
||||
use conditions::nonexistent_package::cond;
|
||||
|
||||
|
@ -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" }
|
||||
}
|
||||
|
||||
|
@ -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) }
|
||||
|
@ -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())
|
||||
|
@ -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)]
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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>],
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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; }
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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)}) }
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>,
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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 = ~"[";
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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(|| {
|
||||
|
@ -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)();
|
||||
}
|
||||
|
@ -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 {}
|
||||
|
@ -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 {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user