mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
librustc: Modify all code to use new lifetime binder syntax
This commit is contained in:
parent
15688eaf28
commit
8b56a8380b
@ -1116,7 +1116,7 @@ static bit2: uint = 1 << 1;
|
||||
static bits: [uint, ..2] = [bit1, bit2];
|
||||
static string: &'static str = "bitstring";
|
||||
|
||||
struct BitsNStrings {
|
||||
struct BitsNStrings<'self> {
|
||||
mybits: [uint, ..2],
|
||||
mystring: &'self str
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ For example, we could write a subroutine like this:
|
||||
|
||||
~~~
|
||||
struct Point {x: float, y: float}
|
||||
fn get_x(p: &'r Point) -> &'r float { &p.x }
|
||||
fn get_x<'r>(p: &'r Point) -> &'r float { &p.x }
|
||||
~~~
|
||||
|
||||
Here, the function `get_x()` returns a pointer into the structure it
|
||||
@ -571,8 +571,8 @@ function:
|
||||
# Rectangle(Point, Size) // upper-left, dimensions
|
||||
# }
|
||||
# fn compute_area(shape: &Shape) -> float { 0f }
|
||||
fn select<T>(shape: &'r Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
fn select<'r, T>(shape: &'r Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
if compute_area(shape) > threshold {a} else {b}
|
||||
}
|
||||
~~~
|
||||
@ -591,12 +591,12 @@ example:
|
||||
# Rectangle(Point, Size) // upper-left, dimensions
|
||||
# }
|
||||
# fn compute_area(shape: &Shape) -> float { 0f }
|
||||
# fn select<T>(shape: &Shape, threshold: float,
|
||||
# a: &'r T, b: &'r T) -> &'r T {
|
||||
# fn select<'r, T>(shape: &Shape, threshold: float,
|
||||
# a: &'r T, b: &'r T) -> &'r T {
|
||||
# if compute_area(shape) > threshold {a} else {b}
|
||||
# }
|
||||
// -+ r
|
||||
fn select_based_on_unit_circle<T>( // |-+ B
|
||||
fn select_based_on_unit_circle<'r, T>( // |-+ B
|
||||
threshold: float, a: &'r T, b: &'r T) -> &'r T { // | |
|
||||
// | |
|
||||
let shape = Circle(Point {x: 0., y: 0.}, 1.); // | |
|
||||
@ -628,8 +628,8 @@ returned. Here is how the new `select()` might look:
|
||||
# Rectangle(Point, Size) // upper-left, dimensions
|
||||
# }
|
||||
# fn compute_area(shape: &Shape) -> float { 0f }
|
||||
fn select<T>(shape: &'tmp Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
fn select<'r, 'tmp, T>(shape: &'tmp Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
if compute_area(shape) > threshold {a} else {b}
|
||||
}
|
||||
~~~
|
||||
@ -647,8 +647,8 @@ concise to just omit the named lifetime for `shape` altogether:
|
||||
# Rectangle(Point, Size) // upper-left, dimensions
|
||||
# }
|
||||
# fn compute_area(shape: &Shape) -> float { 0f }
|
||||
fn select<T>(shape: &Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
fn select<'r, T>(shape: &Shape, threshold: float,
|
||||
a: &'r T, b: &'r T) -> &'r T {
|
||||
if compute_area(shape) > threshold {a} else {b}
|
||||
}
|
||||
~~~
|
||||
|
@ -174,7 +174,7 @@ pub mod traits {
|
||||
use kinds::Copy;
|
||||
use ops::Add;
|
||||
|
||||
impl<T:Copy> Add<&'self const [T],@[T]> for @[T] {
|
||||
impl<'self,T:Copy> Add<&'self const [T],@[T]> for @[T] {
|
||||
#[inline(always)]
|
||||
fn add(&self, rhs: & &'self const [T]) -> @[T] {
|
||||
append(*self, (*rhs))
|
||||
|
@ -61,17 +61,19 @@ pub unsafe fn transmute<L, G>(thing: L) -> G {
|
||||
|
||||
/// Coerce an immutable reference to be mutable.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_mut<T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
|
||||
pub unsafe fn transmute_mut<'a,T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
|
||||
|
||||
/// Coerce a mutable reference to be immutable.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_immut<T>(ptr: &'a mut T) -> &'a T {
|
||||
pub unsafe fn transmute_immut<'a,T>(ptr: &'a mut T) -> &'a T {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
||||
/// Coerce a borrowed pointer to have an arbitrary associated region.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_region<T>(ptr: &'a T) -> &'b T { transmute(ptr) }
|
||||
pub unsafe fn transmute_region<'a,'b,T>(ptr: &'a T) -> &'b T {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
||||
/// Coerce an immutable reference to be mutable.
|
||||
#[inline(always)]
|
||||
@ -87,19 +89,19 @@ pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T {
|
||||
|
||||
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_mut_region<T>(ptr: &'a mut T) -> &'b mut T {
|
||||
pub unsafe fn transmute_mut_region<'a,'b,T>(ptr: &'a mut T) -> &'b mut T {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
||||
/// Transforms lifetime of the second pointer to match the first.
|
||||
#[inline(always)]
|
||||
pub unsafe fn copy_lifetime<S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
|
||||
pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
|
||||
transmute_region(ptr)
|
||||
}
|
||||
|
||||
/// Transforms lifetime of the second pointer to match the first.
|
||||
#[inline(always)]
|
||||
pub unsafe fn copy_lifetime_vec<S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
|
||||
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
|
||||
transmute_region(ptr)
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ use cast::transmute;
|
||||
* NB: These must match the representation in the C++ runtime.
|
||||
*/
|
||||
|
||||
type DropGlue = &'self fn(**TypeDesc, *c_void);
|
||||
type FreeGlue = &'self fn(**TypeDesc, *c_void);
|
||||
type DropGlue<'self> = &'self fn(**TypeDesc, *c_void);
|
||||
type FreeGlue<'self> = &'self fn(**TypeDesc, *c_void);
|
||||
|
||||
type TaskID = uintptr_t;
|
||||
|
||||
|
@ -22,12 +22,12 @@ pub struct Handler<T, U> {
|
||||
prev: Option<@Handler<T, U>>,
|
||||
}
|
||||
|
||||
pub struct Condition<T, U> {
|
||||
pub struct Condition<'self, T, U> {
|
||||
name: &'static str,
|
||||
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
|
||||
}
|
||||
|
||||
pub impl<T, U> Condition<'self, T, U> {
|
||||
pub impl<'self, T, U> Condition<'self, T, U> {
|
||||
fn trap(&self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
|
||||
unsafe {
|
||||
let p : *RustClosure = ::cast::transmute(&h);
|
||||
@ -66,12 +66,12 @@ pub impl<T, U> Condition<'self, T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
struct Trap<T, U> {
|
||||
struct Trap<'self, T, U> {
|
||||
cond: &'self Condition<'self, T, U>,
|
||||
handler: @Handler<T, U>
|
||||
}
|
||||
|
||||
pub impl<T, U> Trap<'self, T, U> {
|
||||
pub impl<'self, T, U> Trap<'self, T, U> {
|
||||
fn in<V>(&self, inner: &'self fn() -> V) -> V {
|
||||
unsafe {
|
||||
let _g = Guard { cond: self.cond };
|
||||
@ -82,12 +82,12 @@ pub impl<T, U> Trap<'self, T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
struct Guard<T, U> {
|
||||
struct Guard<'self, T, U> {
|
||||
cond: &'self Condition<'self, T, U>
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<T, U> Drop for Guard<'self, T, U> {
|
||||
impl<'self, T, U> Drop for Guard<'self, T, U> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
debug!("Guard: popping handler from TLS");
|
||||
|
@ -124,7 +124,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
|
||||
return None;
|
||||
}
|
||||
|
||||
type Visitor = &'self fn(root: **Word, tydesc: *Word) -> bool;
|
||||
type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
|
||||
|
||||
// Walks the list of roots for the given safe point, and calls visitor
|
||||
// on each root.
|
||||
|
@ -278,9 +278,8 @@ pub mod linear {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K:Hash + IterBytes + Eq,V>
|
||||
BaseIter<(&'self K, &'self V)> for LinearMap<K, V>
|
||||
{
|
||||
impl<'self,K:Hash + IterBytes + Eq,V>
|
||||
BaseIter<(&'self K, &'self V)> for LinearMap<K, V> {
|
||||
/// Visit all key-value pairs
|
||||
fn each(&self, blk: &fn(&(&'self K, &'self V)) -> bool) {
|
||||
for uint::range(0, self.buckets.len()) |i| {
|
||||
@ -315,7 +314,7 @@ pub mod linear {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K:Hash + IterBytes + Eq,V> Map<K, V> for LinearMap<K, V> {
|
||||
impl<'self,K:Hash + IterBytes + Eq,V> Map<K, V> for LinearMap<K, V> {
|
||||
/// Return true if the map contains a value for the specified key
|
||||
fn contains_key(&self, k: &K) -> bool {
|
||||
match self.bucket_for_key(k) {
|
||||
|
@ -616,12 +616,12 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> {
|
||||
|
||||
|
||||
// Byte readers
|
||||
pub struct BytesReader {
|
||||
pub struct BytesReader<'self> {
|
||||
bytes: &'self [u8],
|
||||
mut pos: uint
|
||||
}
|
||||
|
||||
impl Reader for BytesReader<'self> {
|
||||
impl<'self> Reader for BytesReader<'self> {
|
||||
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
|
||||
let count = uint::min(len, self.bytes.len() - self.pos);
|
||||
|
||||
|
@ -20,7 +20,7 @@ use option::{None, Option, Some};
|
||||
use vec;
|
||||
|
||||
/// A function used to initialize the elements of a sequence
|
||||
pub type InitOp<T> = &'self fn(uint) -> T;
|
||||
pub type InitOp<'self,T> = &'self fn(uint) -> T;
|
||||
|
||||
pub trait BaseIter<A> {
|
||||
fn each(&self, blk: &fn(v: &A) -> bool);
|
||||
|
@ -439,7 +439,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
|
||||
let p = unsafe { &*p_ };
|
||||
|
||||
#[unsafe_destructor]
|
||||
struct DropState {
|
||||
struct DropState<'self> {
|
||||
p: &'self PacketHeader,
|
||||
|
||||
drop {
|
||||
|
@ -178,7 +178,7 @@ pub fn to_uint<T>(thing: &T) -> uint {
|
||||
|
||||
/// Determine if two borrowed pointers point to the same thing.
|
||||
#[inline(always)]
|
||||
pub fn ref_eq<T>(thing: &'a T, other: &'b T) -> bool {
|
||||
pub fn ref_eq<'a,'b,T>(thing: &'a T, other: &'b T) -> bool {
|
||||
to_uint(thing) == to_uint(other)
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ impl<T> Ord for *const T {
|
||||
|
||||
// Equality for region pointers
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> Eq for &'self const T {
|
||||
impl<'self,T:Eq> Eq for &'self const T {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: & &'self const T) -> bool {
|
||||
return *(*self) == *(*other);
|
||||
@ -325,7 +325,7 @@ impl<T:Eq> Eq for &'self const T {
|
||||
|
||||
// Comparison for region pointers
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> Ord for &'self const T {
|
||||
impl<'self,T:Ord> Ord for &'self const T {
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: & &'self const T) -> bool {
|
||||
*(*self) < *(*other)
|
||||
|
@ -53,7 +53,7 @@ pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
|
||||
* If the result is an error
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn get_ref<T, U>(res: &'a Result<T, U>) -> &'a T {
|
||||
pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
|
||||
match *res {
|
||||
Ok(ref t) => t,
|
||||
Err(ref the_err) => unsafe {
|
||||
|
@ -321,7 +321,7 @@ pub fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_watcher_data<H, W: Watcher + NativeHandle<*H>>(
|
||||
pub fn get_watcher_data<'r, H, W: Watcher + NativeHandle<*H>>(
|
||||
watcher: &'r mut W) -> &'r mut WatcherData {
|
||||
|
||||
unsafe {
|
||||
|
@ -58,7 +58,7 @@ impl ToStr for ~str {
|
||||
#[inline(always)]
|
||||
fn to_str(&self) -> ~str { from_slice(*self) }
|
||||
}
|
||||
impl ToStr for &'self str {
|
||||
impl<'self> ToStr for &'self str {
|
||||
#[inline(always)]
|
||||
fn to_str(&self) -> ~str { from_slice(*self) }
|
||||
}
|
||||
@ -293,7 +293,7 @@ pub fn shift_char(s: &mut ~str) -> char {
|
||||
* If the string does not contain any characters
|
||||
*/
|
||||
#[inline]
|
||||
pub fn slice_shift_char(s: &'a str) -> (char, &'a str) {
|
||||
pub fn slice_shift_char<'a>(s: &'a str) -> (char, &'a str) {
|
||||
let CharRange {ch, next} = char_range_at(s, 0u);
|
||||
let next_s = unsafe { raw::slice_bytes(s, next, len(s)) };
|
||||
return (ch, next_s);
|
||||
@ -313,7 +313,7 @@ pub fn unshift_char(s: &mut ~str, ch: char) {
|
||||
* * chars_to_trim - A vector of chars
|
||||
*
|
||||
*/
|
||||
pub fn trim_left_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
pub fn trim_left_chars<'a>(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
if chars_to_trim.is_empty() { return s; }
|
||||
|
||||
match find(s, |c| !chars_to_trim.contains(&c)) {
|
||||
@ -331,7 +331,7 @@ pub fn trim_left_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
* * chars_to_trim - A vector of chars
|
||||
*
|
||||
*/
|
||||
pub fn trim_right_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
pub fn trim_right_chars<'a>(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
if chars_to_trim.is_empty() { return s; }
|
||||
|
||||
match rfind(s, |c| !chars_to_trim.contains(&c)) {
|
||||
@ -352,12 +352,12 @@ pub fn trim_right_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
* * chars_to_trim - A vector of chars
|
||||
*
|
||||
*/
|
||||
pub fn trim_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
pub fn trim_chars<'a>(s: &'a str, chars_to_trim: &[char]) -> &'a str {
|
||||
trim_left_chars(trim_right_chars(s, chars_to_trim), chars_to_trim)
|
||||
}
|
||||
|
||||
/// Returns a string with leading whitespace removed
|
||||
pub fn trim_left(s: &'a str) -> &'a str {
|
||||
pub fn trim_left<'a>(s: &'a str) -> &'a str {
|
||||
match find(s, |c| !char::is_whitespace(c)) {
|
||||
None => "",
|
||||
Some(first) => unsafe { raw::slice_bytes(s, first, len(s)) }
|
||||
@ -365,7 +365,7 @@ pub fn trim_left(s: &'a str) -> &'a str {
|
||||
}
|
||||
|
||||
/// Returns a string with trailing whitespace removed
|
||||
pub fn trim_right(s: &'a str) -> &'a str {
|
||||
pub fn trim_right<'a>(s: &'a str) -> &'a str {
|
||||
match rfind(s, |c| !char::is_whitespace(c)) {
|
||||
None => "",
|
||||
Some(last) => {
|
||||
@ -376,7 +376,7 @@ pub fn trim_right(s: &'a str) -> &'a str {
|
||||
}
|
||||
|
||||
/// Returns a string with leading and trailing whitespace removed
|
||||
pub fn trim(s: &'a str) -> &'a str { trim_left(trim_right(s)) }
|
||||
pub fn trim<'a>(s: &'a str) -> &'a str { trim_left(trim_right(s)) }
|
||||
|
||||
/*
|
||||
Section: Transforming strings
|
||||
@ -418,7 +418,7 @@ pub fn to_chars(s: &str) -> ~[char] {
|
||||
* Returns a slice pointing at `n` characters starting from byte offset
|
||||
* `begin`.
|
||||
*/
|
||||
pub fn substr(s: &'a str, begin: uint, n: uint) -> &'a str {
|
||||
pub fn substr<'a>(s: &'a str, begin: uint, n: uint) -> &'a str {
|
||||
slice(s, begin, begin + count_bytes(s, begin, n))
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ pub fn substr(s: &'a str, begin: uint, n: uint) -> &'a str {
|
||||
* Fails when `begin` and `end` do not point to valid characters or beyond
|
||||
* the last character of the string
|
||||
*/
|
||||
pub fn slice(s: &'a str, begin: uint, end: uint) -> &'a str {
|
||||
pub fn slice<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
|
||||
fail_unless!(is_char_boundary(s, begin));
|
||||
fail_unless!(is_char_boundary(s, end));
|
||||
unsafe { raw::slice_bytes(s, begin, end) }
|
||||
@ -528,7 +528,7 @@ fn each_split_inner(s: &'a str, sepfn: &fn(cc: char) -> bool, count: uint,
|
||||
}
|
||||
|
||||
// See Issue #1932 for why this is a naive search
|
||||
fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) {
|
||||
fn iter_matches<'a,'b>(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) {
|
||||
let sep_len = len(sep), l = len(s);
|
||||
fail_unless!(sep_len > 0u);
|
||||
let mut i = 0u, match_start = 0u, match_i = 0u;
|
||||
@ -555,7 +555,9 @@ fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) {
|
||||
fn iter_between_matches<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
f: &fn(uint, uint) -> bool) {
|
||||
let mut last_end = 0u;
|
||||
for iter_matches(s, sep) |from, to| {
|
||||
if !f(last_end, from) { return; }
|
||||
@ -575,13 +577,17 @@ fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint) -> bool) {
|
||||
* fail_unless!(v == ["", "XXX", "YYY", ""]);
|
||||
* ~~~
|
||||
*/
|
||||
pub fn each_split_str(s: &'a str, sep: &'b str, it: &fn(&'a str) -> bool) {
|
||||
pub fn each_split_str<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
for iter_between_matches(s, sep) |from, to| {
|
||||
if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn each_split_str_nonempty(s: &'a str, sep: &'b str, it: &fn(&'a str) -> bool) {
|
||||
pub fn each_split_str_nonempty<'a,'b>(s: &'a str,
|
||||
sep: &'b str,
|
||||
it: &fn(&'a str) -> bool) {
|
||||
for iter_between_matches(s, sep) |from, to| {
|
||||
if to > from {
|
||||
if !it( unsafe { raw::slice_bytes(s, from, to) } ) { return; }
|
||||
@ -823,7 +829,7 @@ fn cmp(a: &str, b: &str) -> Ordering {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl TotalOrd for &'self str {
|
||||
impl<'self> TotalOrd for &'self str {
|
||||
fn cmp(&self, other: & &'self str) -> Ordering { cmp(*self, *other) }
|
||||
}
|
||||
|
||||
@ -869,7 +875,7 @@ fn gt(a: &str, b: &str) -> bool {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl Eq for &'self str {
|
||||
impl<'self> Eq for &'self str {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: & &'self str) -> bool {
|
||||
eq_slice((*self), (*other))
|
||||
@ -911,7 +917,7 @@ impl Ord for ~str {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl Ord for &'self str {
|
||||
impl<'self> Ord for &'self str {
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: & &'self str) -> bool { lt((*self), (*other)) }
|
||||
#[inline(always)]
|
||||
@ -935,7 +941,7 @@ impl Ord for @str {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl Equiv<~str> for &'self str {
|
||||
impl<'self> Equiv<~str> for &'self str {
|
||||
#[inline(always)]
|
||||
fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) }
|
||||
}
|
||||
@ -1370,7 +1376,7 @@ pub fn rfind_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool) -> O
|
||||
}
|
||||
|
||||
// Utility used by various searching functions
|
||||
fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool {
|
||||
fn match_at<'a,'b>(haystack: &'a str, needle: &'b str, at: uint) -> bool {
|
||||
let mut i = at;
|
||||
for each(needle) |c| { if haystack[i] != c { return false; } i += 1u; }
|
||||
return true;
|
||||
@ -1389,7 +1395,7 @@ fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool {
|
||||
* An `option` containing the byte index of the first matching substring
|
||||
* or `none` if there is no match
|
||||
*/
|
||||
pub fn find_str(haystack: &'a str, needle: &'b str) -> Option<uint> {
|
||||
pub fn find_str<'a,'b>(haystack: &'a str, needle: &'b str) -> Option<uint> {
|
||||
find_str_between(haystack, needle, 0u, len(haystack))
|
||||
}
|
||||
|
||||
@ -1412,7 +1418,10 @@ pub fn find_str(haystack: &'a str, needle: &'b str) -> Option<uint> {
|
||||
*
|
||||
* `start` must be less than or equal to `len(s)`
|
||||
*/
|
||||
pub fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) -> Option<uint> {
|
||||
pub fn find_str_from<'a,'b>(haystack: &'a str,
|
||||
needle: &'b str,
|
||||
start: uint)
|
||||
-> Option<uint> {
|
||||
find_str_between(haystack, needle, start, len(haystack))
|
||||
}
|
||||
|
||||
@ -1436,8 +1445,11 @@ pub fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) -> Option<
|
||||
* `start` must be less than or equal to `end` and `end` must be less than
|
||||
* or equal to `len(s)`.
|
||||
*/
|
||||
pub fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, end:uint)
|
||||
-> Option<uint> {
|
||||
pub fn find_str_between<'a,'b>(haystack: &'a str,
|
||||
needle: &'b str,
|
||||
start: uint,
|
||||
end:uint)
|
||||
-> Option<uint> {
|
||||
// See Issue #1932 for why this is a naive search
|
||||
fail_unless!(end <= len(haystack));
|
||||
let needle_len = len(needle);
|
||||
@ -1461,7 +1473,7 @@ pub fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, end:uin
|
||||
* * haystack - The string to look in
|
||||
* * needle - The string to look for
|
||||
*/
|
||||
pub fn contains(haystack: &'a str, needle: &'b str) -> bool {
|
||||
pub fn contains<'a,'b>(haystack: &'a str, needle: &'b str) -> bool {
|
||||
find_str(haystack, needle).is_some()
|
||||
}
|
||||
|
||||
@ -1485,7 +1497,7 @@ pub fn contains_char(haystack: &str, needle: char) -> bool {
|
||||
* * haystack - The string to look in
|
||||
* * needle - The string to look for
|
||||
*/
|
||||
pub fn starts_with(haystack: &'a str, needle: &'b str) -> bool {
|
||||
pub fn starts_with<'a,'b>(haystack: &'a str, needle: &'b str) -> bool {
|
||||
let haystack_len = len(haystack), needle_len = len(needle);
|
||||
if needle_len == 0u { true }
|
||||
else if needle_len > haystack_len { false }
|
||||
@ -1500,7 +1512,7 @@ pub fn starts_with(haystack: &'a str, needle: &'b str) -> bool {
|
||||
* * haystack - The string to look in
|
||||
* * needle - The string to look for
|
||||
*/
|
||||
pub fn ends_with(haystack: &'a str, needle: &'b str) -> bool {
|
||||
pub fn ends_with<'a,'b>(haystack: &'a str, needle: &'b str) -> bool {
|
||||
let haystack_len = len(haystack), needle_len = len(needle);
|
||||
if needle_len == 0u { true }
|
||||
else if needle_len > haystack_len { false }
|
||||
@ -1681,7 +1693,7 @@ pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
|
||||
}
|
||||
|
||||
/// Counts the number of bytes taken by the `n` in `s` starting from `start`.
|
||||
pub fn count_bytes(s: &'b str, start: uint, n: uint) -> uint {
|
||||
pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
|
||||
fail_unless!(is_char_boundary(s, start));
|
||||
let mut end = start, cnt = n;
|
||||
let l = len(s);
|
||||
@ -1921,7 +1933,7 @@ pub fn as_bytes<T>(s: &const ~str, f: &fn(&~[u8]) -> T) -> T {
|
||||
*
|
||||
* The byte slice does not include the null terminator.
|
||||
*/
|
||||
pub fn as_bytes_slice(s: &'a str) -> &'a [u8] {
|
||||
pub fn as_bytes_slice<'a>(s: &'a str) -> &'a [u8] {
|
||||
unsafe {
|
||||
let (ptr, len): (*u8, uint) = ::cast::reinterpret_cast(&s);
|
||||
let outgoing_tuple: (*u8, uint) = (ptr, len - 1);
|
||||
@ -2229,7 +2241,7 @@ pub mod traits {
|
||||
use ops::Add;
|
||||
use str::append;
|
||||
|
||||
impl Add<&'self str,~str> for ~str {
|
||||
impl<'self> Add<&'self str,~str> for ~str {
|
||||
#[inline(always)]
|
||||
fn add(&self, rhs: & &'self str) -> ~str {
|
||||
append(copy *self, (*rhs))
|
||||
@ -2243,7 +2255,7 @@ pub mod traits {}
|
||||
pub trait StrSlice<'self> {
|
||||
fn all(&self, it: &fn(char) -> bool) -> bool;
|
||||
fn any(&self, it: &fn(char) -> bool) -> bool;
|
||||
fn contains(&self, needle: &'a str) -> bool;
|
||||
fn contains<'a>(&self, needle: &'a str) -> bool;
|
||||
fn contains_char(&self, needle: char) -> bool;
|
||||
fn each(&self, it: &fn(u8) -> bool);
|
||||
fn eachi(&self, it: &fn(uint, u8) -> bool);
|
||||
@ -2262,8 +2274,8 @@ pub trait StrSlice<'self> {
|
||||
fn slice(&self, begin: uint, end: uint) -> &'self str;
|
||||
fn each_split(&self, sepfn: &fn(char) -> bool, it: &fn(&'self str) -> bool);
|
||||
fn each_split_char(&self, sep: char, it: &fn(&'self str) -> bool);
|
||||
fn each_split_str(&self, sep: &'a str, it: &fn(&'self str) -> bool);
|
||||
fn starts_with(&self, needle: &'a str) -> bool;
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool);
|
||||
fn starts_with<'a>(&self, needle: &'a str) -> bool;
|
||||
fn substr(&self, begin: uint, n: uint) -> &'self str;
|
||||
fn to_lower(&self) -> ~str;
|
||||
fn to_upper(&self) -> ~str;
|
||||
@ -2283,7 +2295,7 @@ pub trait StrSlice<'self> {
|
||||
}
|
||||
|
||||
/// Extension methods for strings
|
||||
impl StrSlice<'self> for &'self str {
|
||||
impl<'self> StrSlice<'self> for &'self str {
|
||||
/**
|
||||
* Return true if a predicate matches all characters or if the string
|
||||
* contains no characters
|
||||
@ -2298,7 +2310,7 @@ impl StrSlice<'self> for &'self str {
|
||||
fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) }
|
||||
/// Returns true if one string contains another
|
||||
#[inline]
|
||||
fn contains(&self, needle: &'a str) -> bool {
|
||||
fn contains<'a>(&self, needle: &'a str) -> bool {
|
||||
contains(*self, needle)
|
||||
}
|
||||
/// Returns true if a string contains a char
|
||||
@ -2397,12 +2409,12 @@ impl StrSlice<'self> for &'self str {
|
||||
* string
|
||||
*/
|
||||
#[inline]
|
||||
fn each_split_str(&self, sep: &'a str, it: &fn(&'self str) -> bool) {
|
||||
fn each_split_str<'a>(&self, sep: &'a str, it: &fn(&'self str) -> bool) {
|
||||
each_split_str(*self, sep, it)
|
||||
}
|
||||
/// Returns true if one string starts with another
|
||||
#[inline]
|
||||
fn starts_with(&self, needle: &'a str) -> bool {
|
||||
fn starts_with<'a>(&self, needle: &'a str) -> bool {
|
||||
starts_with(*self, needle)
|
||||
}
|
||||
/**
|
||||
@ -2710,7 +2722,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_split_str() {
|
||||
fn t(s: &str, sep: &'a str, u: &[~str]) {
|
||||
fn t<'a>(s: &str, sep: &'a str, u: &[~str]) {
|
||||
let mut v = ~[];
|
||||
for each_split_str(s, sep) |s| { v.push(s.to_owned()) }
|
||||
fail_unless!(vec::all2(v, u, |a,b| a == b));
|
||||
|
@ -19,7 +19,7 @@ use libc::{c_void, c_char, size_t};
|
||||
use repr;
|
||||
use str;
|
||||
|
||||
pub type FreeGlue = &'self fn(*TypeDesc, *c_void);
|
||||
pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void);
|
||||
|
||||
// Corresponds to runtime type_desc type
|
||||
pub struct TypeDesc {
|
||||
|
@ -44,7 +44,7 @@ use task::rt;
|
||||
*
|
||||
* These two cases aside, the interface is safe.
|
||||
*/
|
||||
pub type LocalDataKey<T> = &'self fn(v: @T);
|
||||
pub type LocalDataKey<'self,T> = &'self fn(v: @T);
|
||||
|
||||
/**
|
||||
* Remove a task-local data value from the table, returning the
|
||||
|
@ -122,7 +122,7 @@ struct TaskGroupData {
|
||||
}
|
||||
type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
|
||||
|
||||
type TaskGroupInner = &'self mut Option<TaskGroupData>;
|
||||
type TaskGroupInner<'self> = &'self mut Option<TaskGroupData>;
|
||||
|
||||
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
|
||||
fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
|
||||
|
@ -19,7 +19,7 @@ use io::Writer;
|
||||
use option::{None, Option, Some};
|
||||
use str;
|
||||
|
||||
pub type Cb = &'self fn(buf: &const [u8]) -> bool;
|
||||
pub type Cb<'self> = &'self fn(buf: &const [u8]) -> bool;
|
||||
|
||||
/**
|
||||
* A trait to implement in order to make a type hashable;
|
||||
@ -197,7 +197,7 @@ impl IterBytes for int {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:IterBytes> IterBytes for &'self [A] {
|
||||
impl<'self,A:IterBytes> IterBytes for &'self [A] {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
for (*self).each |elt| {
|
||||
@ -231,7 +231,7 @@ impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
|
||||
}
|
||||
|
||||
// Move this to vec, probably.
|
||||
fn borrow<A>(a: &'x [A]) -> &'x [A] {
|
||||
fn borrow<'x,A>(a: &'x [A]) -> &'x [A] {
|
||||
a
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ pub fn iter_bytes_7<A: IterBytes,
|
||||
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
|
||||
impl IterBytes for &'self str {
|
||||
impl<'self> IterBytes for &'self str {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(*self) |bytes| {
|
||||
@ -389,7 +389,7 @@ impl<A:IterBytes> IterBytes for Option<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:IterBytes> IterBytes for &'self A {
|
||||
impl<'self,A:IterBytes> IterBytes for &'self A {
|
||||
#[inline(always)]
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
|
@ -69,7 +69,7 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:ToStr> ToStr for &'self [A] {
|
||||
impl<'self,A:ToStr> ToStr for &'self [A] {
|
||||
#[inline(always)]
|
||||
fn to_str(&self) -> ~str {
|
||||
unsafe {
|
||||
|
@ -28,7 +28,7 @@ pub struct TrieMap<T> {
|
||||
priv length: uint
|
||||
}
|
||||
|
||||
impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
impl<'self,T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
/// Visit all key-value pairs in order
|
||||
#[inline(always)]
|
||||
fn each(&self, f: &fn(&(uint, &'self T)) -> bool) {
|
||||
@ -38,7 +38,7 @@ impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl<T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
impl<'self,T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
/// Visit all key-value pairs in reverse order
|
||||
#[inline(always)]
|
||||
fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) {
|
||||
@ -282,7 +282,8 @@ fn chunk(n: uint, idx: uint) -> uint {
|
||||
(n >> sh) & MASK
|
||||
}
|
||||
|
||||
fn find_mut<T>(child: &'r mut Child<T>, key: uint, idx: uint) -> Option<&'r mut T> {
|
||||
fn find_mut<'r, T>(child: &'r mut Child<T>, key: uint, idx: uint)
|
||||
-> Option<&'r mut T> {
|
||||
unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker
|
||||
(match *child {
|
||||
External(_, ref value) => Some(cast::transmute_mut(value)),
|
||||
|
@ -71,7 +71,7 @@ pub trait ExtendedTupleOps<A,B> {
|
||||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
|
||||
}
|
||||
|
||||
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
|
||||
impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
|
||||
#[inline(always)]
|
||||
fn zip(&self) -> ~[(A, B)] {
|
||||
match *self {
|
||||
|
@ -170,7 +170,7 @@ pub unsafe fn get_shared_mutable_state<T:Owned>(
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
pub unsafe fn get_shared_immutable_state<T:Owned>(
|
||||
pub unsafe fn get_shared_immutable_state<'a,T:Owned>(
|
||||
rc: &'a SharedMutableState<T>) -> &'a T {
|
||||
unsafe {
|
||||
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
|
||||
|
@ -31,7 +31,7 @@ pub trait Finally<T> {
|
||||
fn finally(&self, dtor: &fn()) -> T;
|
||||
}
|
||||
|
||||
impl<T> Finally<T> for &'self fn() -> T {
|
||||
impl<'self,T> Finally<T> for &'self fn() -> T {
|
||||
fn finally(&self, dtor: &fn()) -> T {
|
||||
let _d = Finallyalizer {
|
||||
dtor: dtor
|
||||
|
@ -42,7 +42,7 @@ use sys::Closure;
|
||||
#[cfg(test)] use task::spawn;
|
||||
#[cfg(test)] use uint;
|
||||
|
||||
pub type GlobalDataKey<T> = &'self fn(v: T);
|
||||
pub type GlobalDataKey<'self,T> = &'self fn(v: T);
|
||||
|
||||
pub unsafe fn global_data_clone_create<T:Owned + Clone>(
|
||||
key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
|
||||
|
@ -225,46 +225,46 @@ pub fn build_sized_opt<A>(size: Option<uint>,
|
||||
// Accessors
|
||||
|
||||
/// Returns the first element of a vector
|
||||
pub fn head<T>(v: &'r [T]) -> &'r T {
|
||||
pub fn head<'r,T>(v: &'r [T]) -> &'r T {
|
||||
if v.len() == 0 { fail!(~"head: empty vector") }
|
||||
&v[0]
|
||||
}
|
||||
|
||||
/// Returns `Some(x)` where `x` is the first element of the slice `v`,
|
||||
/// or `None` if the vector is empty.
|
||||
pub fn head_opt<T>(v: &'r [T]) -> Option<&'r T> {
|
||||
pub fn head_opt<'r,T>(v: &'r [T]) -> Option<&'r T> {
|
||||
if v.len() == 0 { None } else { Some(&v[0]) }
|
||||
}
|
||||
|
||||
/// Returns a vector containing all but the first element of a slice
|
||||
pub fn tail<T>(v: &'r [T]) -> &'r [T] { slice(v, 1, v.len()) }
|
||||
pub fn tail<'r,T>(v: &'r [T]) -> &'r [T] { slice(v, 1, v.len()) }
|
||||
|
||||
/// Returns a vector containing all but the first `n` elements of a slice
|
||||
pub fn tailn<T>(v: &'r [T], n: uint) -> &'r [T] { slice(v, n, v.len()) }
|
||||
pub fn tailn<'r,T>(v: &'r [T], n: uint) -> &'r [T] { slice(v, n, v.len()) }
|
||||
|
||||
/// Returns a vector containing all but the last element of a slice
|
||||
pub fn init<T>(v: &'r [T]) -> &'r [T] { slice(v, 0, v.len() - 1) }
|
||||
pub fn init<'r,T>(v: &'r [T]) -> &'r [T] { slice(v, 0, v.len() - 1) }
|
||||
|
||||
/// Returns a vector containing all but the last `n' elements of a slice
|
||||
pub fn initn<T>(v: &'r [T], n: uint) -> &'r [T] {
|
||||
pub fn initn<'r,T>(v: &'r [T], n: uint) -> &'r [T] {
|
||||
slice(v, 0, v.len() - n)
|
||||
}
|
||||
|
||||
/// Returns the last element of the slice `v`, failing if the slice is empty.
|
||||
pub fn last<T>(v: &'r [T]) -> &'r T {
|
||||
pub fn last<'r,T>(v: &'r [T]) -> &'r T {
|
||||
if v.len() == 0 { fail!(~"last: empty vector") }
|
||||
&v[v.len() - 1]
|
||||
}
|
||||
|
||||
/// Returns `Some(x)` where `x` is the last element of the slice `v`, or
|
||||
/// `None` if the vector is empty.
|
||||
pub fn last_opt<T>(v: &'r [T]) -> Option<&'r T> {
|
||||
pub fn last_opt<'r,T>(v: &'r [T]) -> Option<&'r T> {
|
||||
if v.len() == 0 { None } else { Some(&v[v.len() - 1]) }
|
||||
}
|
||||
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline(always)]
|
||||
pub fn slice<T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
|
||||
pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
|
||||
fail_unless!(start <= end);
|
||||
fail_unless!(end <= len(v));
|
||||
do as_imm_buf(v) |p, _len| {
|
||||
@ -278,7 +278,8 @@ pub fn slice<T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
|
||||
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline(always)]
|
||||
pub fn mut_slice<T>(v: &'r mut [T], start: uint, end: uint) -> &'r mut [T] {
|
||||
pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint)
|
||||
-> &'r mut [T] {
|
||||
fail_unless!(start <= end);
|
||||
fail_unless!(end <= v.len());
|
||||
do as_mut_buf(v) |p, _len| {
|
||||
@ -292,8 +293,8 @@ pub fn mut_slice<T>(v: &'r mut [T], start: uint, end: uint) -> &'r mut [T] {
|
||||
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline(always)]
|
||||
pub fn const_slice<T>(v: &'r const [T], start: uint, end: uint)
|
||||
-> &'r const [T] {
|
||||
pub fn const_slice<'r,T>(v: &'r const [T], start: uint, end: uint)
|
||||
-> &'r const [T] {
|
||||
fail_unless!(start <= end);
|
||||
fail_unless!(end <= len(v));
|
||||
do as_const_buf(v) |p, _len| {
|
||||
@ -1343,7 +1344,7 @@ pub fn reversed<T:Copy>(v: &const [T]) -> ~[T] {
|
||||
* ~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn each<T>(v: &'r [T], f: &fn(&'r T) -> bool) {
|
||||
pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) {
|
||||
// ^^^^
|
||||
// NB---this CANNOT be &const [T]! The reason
|
||||
// is that you are passing it to `f()` using
|
||||
@ -1367,7 +1368,7 @@ pub fn each<T>(v: &'r [T], f: &fn(&'r T) -> bool) {
|
||||
/// a vector with mutable contents and you would like
|
||||
/// to mutate the contents as you iterate.
|
||||
#[inline(always)]
|
||||
pub fn each_mut<T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) {
|
||||
pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) {
|
||||
let mut i = 0;
|
||||
let n = v.len();
|
||||
while i < n {
|
||||
@ -1398,7 +1399,7 @@ pub fn each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn eachi<T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) {
|
||||
pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) {
|
||||
let mut i = 0;
|
||||
for each(v) |p| {
|
||||
if !f(i, p) { return; }
|
||||
@ -1412,7 +1413,7 @@ pub fn eachi<T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn each_reverse<T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
|
||||
pub fn each_reverse<'r,T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
|
||||
eachi_reverse(v, |_i, v| blk(v))
|
||||
}
|
||||
|
||||
@ -1422,7 +1423,7 @@ pub fn each_reverse<T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub fn eachi_reverse<T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) {
|
||||
pub fn eachi_reverse<'r,T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) {
|
||||
let mut i = v.len();
|
||||
while i > 0 {
|
||||
i -= 1;
|
||||
@ -1560,7 +1561,7 @@ fn eq<T:Eq>(a: &[T], b: &[T]) -> bool {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> Eq for &'self [T] {
|
||||
impl<'self,T:Eq> Eq for &'self [T] {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: & &'self [T]) -> bool { eq((*self), (*other)) }
|
||||
#[inline(always)]
|
||||
@ -1585,7 +1586,7 @@ impl<T:Eq> Eq for @[T] {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> Equiv<~[T]> for &'self [T] {
|
||||
impl<'self,T:Eq> Equiv<~[T]> for &'self [T] {
|
||||
#[inline(always)]
|
||||
fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) }
|
||||
}
|
||||
@ -1607,7 +1608,7 @@ fn cmp<T: TotalOrd>(a: &[T], b: &[T]) -> Ordering {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: TotalOrd> TotalOrd for &'self [T] {
|
||||
impl<'self,T:TotalOrd> TotalOrd for &'self [T] {
|
||||
#[inline(always)]
|
||||
fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) }
|
||||
}
|
||||
@ -1644,7 +1645,7 @@ fn ge<T:Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) }
|
||||
fn gt<T:Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> Ord for &'self [T] {
|
||||
impl<'self,T:Ord> Ord for &'self [T] {
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) }
|
||||
#[inline(always)]
|
||||
@ -1685,7 +1686,7 @@ pub mod traits {
|
||||
use ops::Add;
|
||||
use vec::append;
|
||||
|
||||
impl<T:Copy> Add<&'self const [T],~[T]> for ~[T] {
|
||||
impl<'self,T:Copy> Add<&'self const [T],~[T]> for ~[T] {
|
||||
#[inline(always)]
|
||||
fn add(&self, rhs: & &'self const [T]) -> ~[T] {
|
||||
append(copy *self, (*rhs))
|
||||
@ -1693,7 +1694,7 @@ pub mod traits {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Container for &'self const [T] {
|
||||
impl<'self,T> Container for &'self const [T] {
|
||||
/// Returns true if a vector contains no elements
|
||||
#[inline]
|
||||
fn is_empty(&const self) -> bool { is_empty(*self) }
|
||||
@ -1708,7 +1709,7 @@ pub trait CopyableVector<T> {
|
||||
}
|
||||
|
||||
/// Extension methods for vectors
|
||||
impl<T: Copy> CopyableVector<T> for &'self const [T] {
|
||||
impl<'self,T:Copy> CopyableVector<T> for &'self const [T] {
|
||||
/// Returns a copy of `v`.
|
||||
#[inline]
|
||||
fn to_owned(&self) -> ~[T] {
|
||||
@ -1747,7 +1748,7 @@ pub trait ImmutableVector<T> {
|
||||
}
|
||||
|
||||
/// Extension methods for vectors
|
||||
impl<T> ImmutableVector<T> for &'self [T] {
|
||||
impl<'self,T> ImmutableVector<T> for &'self [T] {
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline]
|
||||
fn slice(&self, start: uint, end: uint) -> &'self [T] {
|
||||
@ -1862,7 +1863,7 @@ pub trait ImmutableEqVector<T:Eq> {
|
||||
fn rposition_elem(&self, t: &T) -> Option<uint>;
|
||||
}
|
||||
|
||||
impl<T:Eq> ImmutableEqVector<T> for &'self [T] {
|
||||
impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
|
||||
/**
|
||||
* Find the first index matching some predicate
|
||||
*
|
||||
@ -1907,7 +1908,7 @@ pub trait ImmutableCopyableVector<T> {
|
||||
}
|
||||
|
||||
/// Extension methods for vectors
|
||||
impl<T:Copy> ImmutableCopyableVector<T> for &'self [T] {
|
||||
impl<'self,T:Copy> ImmutableCopyableVector<T> for &'self [T] {
|
||||
/**
|
||||
* Construct a new vector from the elements of a vector for which some
|
||||
* predicate holds.
|
||||
@ -2309,7 +2310,7 @@ pub mod bytes {
|
||||
// ___________________________________________________________________________
|
||||
// ITERATION TRAIT METHODS
|
||||
|
||||
impl<A> iter::BaseIter<A> for &'self [A] {
|
||||
impl<'self,A> iter::BaseIter<A> for &'self [A] {
|
||||
#[inline(always)]
|
||||
fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) }
|
||||
#[inline(always)]
|
||||
@ -2332,7 +2333,7 @@ impl<A> iter::BaseIter<A> for @[A] {
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl<A> iter::MutableIter<A> for &'self mut [A] {
|
||||
impl<'self,A> iter::MutableIter<A> for &'self mut [A] {
|
||||
#[inline(always)]
|
||||
fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) {
|
||||
each_mut(*self, blk)
|
||||
@ -2355,7 +2356,7 @@ impl<A> iter::MutableIter<A> for @mut [A] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> iter::ExtendedIter<A> for &'self [A] {
|
||||
impl<'self,A> iter::ExtendedIter<A> for &'self [A] {
|
||||
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
iter::eachi(self, blk)
|
||||
}
|
||||
@ -2432,7 +2433,7 @@ impl<A> iter::ExtendedIter<A> for @[A] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:Eq> iter::EqIter<A> for &'self [A] {
|
||||
impl<'self,A:Eq> iter::EqIter<A> for &'self [A] {
|
||||
pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
|
||||
pub fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
||||
}
|
||||
@ -2449,7 +2450,7 @@ impl<A:Eq> iter::EqIter<A> for @[A] {
|
||||
pub fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
||||
}
|
||||
|
||||
impl<A:Copy> iter::CopyableIter<A> for &'self [A] {
|
||||
impl<'self,A:Copy> iter::CopyableIter<A> for &'self [A] {
|
||||
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] {
|
||||
iter::filter_to_vec(self, pred)
|
||||
}
|
||||
@ -2481,7 +2482,7 @@ impl<A:Copy> iter::CopyableIter<A> for @[A] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &'self [A] {
|
||||
impl<'self,A:Copy + Ord> iter::CopyableOrderedIter<A> for &'self [A] {
|
||||
fn min(&self) -> A { iter::min(self) }
|
||||
fn max(&self) -> A { iter::max(self) }
|
||||
}
|
||||
@ -2498,7 +2499,7 @@ impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] {
|
||||
fn max(&self) -> A { iter::max(self) }
|
||||
}
|
||||
|
||||
impl<A:Copy> iter::CopyableNonstrictIter<A> for &'self [A] {
|
||||
impl<'self,A:Copy> iter::CopyableNonstrictIter<A> for &'self [A] {
|
||||
fn each_val(&const self, f: &fn(A) -> bool) {
|
||||
let mut i = 0;
|
||||
while i < self.len() {
|
||||
|
@ -37,12 +37,12 @@ impl ValidUsage {
|
||||
}
|
||||
}
|
||||
|
||||
enum Action {
|
||||
enum Action<'self> {
|
||||
Exec(&'self str),
|
||||
Call(&'self fn(args: &[~str]) -> ValidUsage)
|
||||
}
|
||||
|
||||
enum UsageSource {
|
||||
enum UsageSource<'self> {
|
||||
UsgExec(&'self str),
|
||||
UsgStr(&'self str)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: &fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
None
|
||||
}
|
||||
|
||||
pub type GetCrateDataCb = &'self fn(ast::crate_num) -> cmd;
|
||||
pub type GetCrateDataCb<'self> = &'self fn(ast::crate_num) -> cmd;
|
||||
|
||||
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
@ -547,7 +547,7 @@ pub fn get_item_path(intr: @ident_interner, cdata: cmd, id: ast::node_id)
|
||||
item_path(intr, lookup_item(id, cdata.data))
|
||||
}
|
||||
|
||||
pub type decode_inlined_item = &'self fn(
|
||||
pub type decode_inlined_item<'self> = &'self fn(
|
||||
cdata: @cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
path: ast_map::path,
|
||||
|
@ -21,7 +21,7 @@ use core::result::Result;
|
||||
use core::result;
|
||||
use core::str;
|
||||
|
||||
pub type pick<T> = &'self fn(path: &Path) -> Option<T>;
|
||||
pub type pick<'self, T> = &'self fn(path: &Path) -> Option<T>;
|
||||
|
||||
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
|
||||
if path.file_path() == file { option::Some(copy *path) }
|
||||
|
@ -49,7 +49,8 @@ pub enum DefIdSource {
|
||||
// Identifies a type parameter (`fn foo<X>() { ... }`).
|
||||
TypeParameter
|
||||
}
|
||||
type conv_did = &'self fn(source: DefIdSource, ast::def_id) -> ast::def_id;
|
||||
type conv_did<'self> =
|
||||
&'self fn(source: DefIdSource, ast::def_id) -> ast::def_id;
|
||||
|
||||
pub struct PState {
|
||||
data: @~[u8],
|
||||
|
@ -63,7 +63,7 @@ pub impl BorrowckCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
struct PreserveCtxt {
|
||||
struct PreserveCtxt<'self> {
|
||||
bccx: &'self BorrowckCtxt,
|
||||
|
||||
// the region scope for which we must preserve the memory
|
||||
|
@ -311,7 +311,7 @@ fn LanguageItemCollector<'r>(crate: @crate,
|
||||
}
|
||||
}
|
||||
|
||||
struct LanguageItemCollector {
|
||||
struct LanguageItemCollector<'self> {
|
||||
items: &'self mut LanguageItems,
|
||||
|
||||
crate: @crate,
|
||||
|
@ -889,14 +889,14 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
|
||||
!ident.contains_char('_')
|
||||
}
|
||||
|
||||
fn ident_without_trailing_underscores(ident: &'r str) -> &'r str {
|
||||
fn ident_without_trailing_underscores<'r>(ident: &'r str) -> &'r str {
|
||||
match str::rfind(ident, |c| c != '_') {
|
||||
Some(idx) => str::slice(ident, 0, idx + 1),
|
||||
None => ident, // all underscores
|
||||
}
|
||||
}
|
||||
|
||||
fn ident_without_leading_underscores(ident: &'r str) -> &'r str {
|
||||
fn ident_without_leading_underscores<'r>(ident: &'r str) -> &'r str {
|
||||
match str::find(ident, |c| c != '_') {
|
||||
Some(idx) => str::slice(ident, idx, ident.len()),
|
||||
None => ident // all underscores
|
||||
|
@ -325,7 +325,7 @@ pub struct BindingInfo {
|
||||
|
||||
pub type BindingsMap = LinearMap<ident, BindingInfo>;
|
||||
|
||||
pub struct ArmData {
|
||||
pub struct ArmData<'self> {
|
||||
bodycx: block,
|
||||
arm: &'self ast::arm,
|
||||
bindings_map: BindingsMap
|
||||
@ -393,7 +393,7 @@ pub fn expand_nested_bindings<'r>(bcx: block,
|
||||
}
|
||||
}
|
||||
|
||||
pub type enter_pat = &'self fn(@ast::pat) -> Option<~[@ast::pat]>;
|
||||
pub type enter_pat<'self> = &'self fn(@ast::pat) -> Option<~[@ast::pat]>;
|
||||
|
||||
pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
|
||||
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
|
||||
@ -610,13 +610,13 @@ pub fn enter_opt<'r>(bcx: block,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enter_rec_or_struct(bcx: block,
|
||||
dm: DefMap,
|
||||
m: &[@Match<'r>],
|
||||
col: uint,
|
||||
fields: &[ast::ident],
|
||||
val: ValueRef)
|
||||
-> ~[@Match<'r>] {
|
||||
pub fn enter_rec_or_struct<'r>(bcx: block,
|
||||
dm: DefMap,
|
||||
m: &[@Match<'r>],
|
||||
col: uint,
|
||||
fields: &[ast::ident],
|
||||
val: ValueRef)
|
||||
-> ~[@Match<'r>] {
|
||||
debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)",
|
||||
bcx.to_str(),
|
||||
matches_to_str(bcx, m),
|
||||
|
@ -560,7 +560,7 @@ pub fn trans_call_inner(
|
||||
}
|
||||
|
||||
|
||||
pub enum CallArgs {
|
||||
pub enum CallArgs<'self> {
|
||||
ArgExprs(&'self [@ast::expr]),
|
||||
ArgVals(&'self [ValueRef])
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ pub fn get_base_and_len(bcx: block,
|
||||
|
||||
pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result;
|
||||
|
||||
pub type iter_vec_block = &'self fn(block, ValueRef, ty::t) -> block;
|
||||
pub type iter_vec_block<'self> = &'self fn(block, ValueRef, ty::t) -> block;
|
||||
|
||||
pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
|
||||
fill: ValueRef, f: iter_vec_block) -> block {
|
||||
|
@ -152,7 +152,7 @@ pub fn lookup(
|
||||
return mme;
|
||||
}
|
||||
|
||||
pub struct LookupContext {
|
||||
pub struct LookupContext<'self> {
|
||||
fcx: @mut FnCtxt,
|
||||
expr: @ast::expr,
|
||||
self_expr: @ast::expr,
|
||||
|
@ -566,10 +566,11 @@ pub impl CoherenceChecker {
|
||||
}
|
||||
}
|
||||
|
||||
fn can_unify_universally_quantified(&self,
|
||||
a: &'a UniversalQuantificationResult,
|
||||
b: &'a UniversalQuantificationResult)
|
||||
-> bool {
|
||||
fn can_unify_universally_quantified<'a>
|
||||
(&self,
|
||||
a: &'a UniversalQuantificationResult,
|
||||
b: &'a UniversalQuantificationResult)
|
||||
-> bool {
|
||||
let mut might_unify = true;
|
||||
let _ = do self.inference_context.probe {
|
||||
let result = self.inference_context.sub(true, dummy_sp())
|
||||
|
@ -56,7 +56,8 @@ pub trait LatticeValue {
|
||||
fn glb(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
|
||||
}
|
||||
|
||||
pub type LatticeOp<T> = &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
|
||||
pub type LatticeOp<'self, T> =
|
||||
&'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
|
||||
|
||||
impl LatticeValue for ty::t {
|
||||
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
|
||||
@ -374,7 +375,7 @@ pub fn super_lattice_tys<L:LatticeDir + TyLatticeDir + Combine>(
|
||||
}
|
||||
}
|
||||
|
||||
pub type LatticeDirOp<T> = &'self fn(a: &T, b: &T) -> cres<T>;
|
||||
pub type LatticeDirOp<'self, T> = &'self fn(a: &T, b: &T) -> cres<T>;
|
||||
|
||||
pub enum LatticeVarResult<V,T> {
|
||||
VarResult(V),
|
||||
|
@ -35,8 +35,8 @@ pub struct Node<V, T> {
|
||||
}
|
||||
|
||||
pub trait UnifyVid<T> {
|
||||
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<Self, T>;
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<Self, T>;
|
||||
}
|
||||
|
||||
pub impl InferCtxt {
|
||||
@ -235,14 +235,14 @@ pub impl InferCtxt {
|
||||
// ______________________________________________________________________
|
||||
|
||||
impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
|
||||
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> {
|
||||
return &mut infcx.ty_var_bindings;
|
||||
}
|
||||
}
|
||||
|
||||
impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
|
||||
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> {
|
||||
return &mut infcx.int_var_bindings;
|
||||
}
|
||||
@ -255,7 +255,7 @@ impl SimplyUnifiable for IntVarValue {
|
||||
}
|
||||
|
||||
impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
|
||||
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
|
||||
fn appropriate_vals_and_bindings<'v>(infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> {
|
||||
return &mut infcx.float_var_bindings;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ pub struct Ctxt {
|
||||
ast_map: ast_map::map
|
||||
}
|
||||
|
||||
type SrvOwner<T> = &'self fn(srv: Srv) -> T;
|
||||
type SrvOwner<'self,T> = &'self fn(srv: Srv) -> T;
|
||||
pub type CtxtHandler<T> = ~fn(ctxt: Ctxt) -> T;
|
||||
type Parser = ~fn(Session, s: ~str) -> @ast::crate;
|
||||
|
||||
|
@ -95,7 +95,7 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
|
||||
* Access the underlying data in an atomically reference counted
|
||||
* wrapper.
|
||||
*/
|
||||
pub fn get<T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
|
||||
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
|
||||
unsafe { get_shared_immutable_state(&rc.x) }
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ pub impl<T:Owned> MutexARC<T> {
|
||||
|
||||
/// As access(), but with a condvar, as sync::mutex.lock_cond().
|
||||
#[inline(always)]
|
||||
unsafe fn access_cond<U>(
|
||||
unsafe fn access_cond<'x, 'c, U>(
|
||||
&self,
|
||||
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U
|
||||
{
|
||||
@ -239,7 +239,7 @@ impl Drop for PoisonOnFail {
|
||||
}
|
||||
}
|
||||
|
||||
fn PoisonOnFail(failed: &'r mut bool) -> PoisonOnFail {
|
||||
fn PoisonOnFail<'r>(failed: &'r mut bool) -> PoisonOnFail {
|
||||
PoisonOnFail {
|
||||
failed: ptr::to_mut_unsafe_ptr(failed)
|
||||
}
|
||||
@ -313,7 +313,9 @@ pub impl<T:Const + Owned> RWARC<T> {
|
||||
}
|
||||
/// As write(), but with a condvar, as sync::rwlock.write_cond().
|
||||
#[inline(always)]
|
||||
fn write_cond<U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U {
|
||||
fn write_cond<'x, 'c, U>(&self,
|
||||
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
|
||||
-> U {
|
||||
unsafe {
|
||||
let state = get_shared_mutable_state(&self.x);
|
||||
do (*borrow_rwlock(state)).write_cond |cond| {
|
||||
@ -375,7 +377,7 @@ pub impl<T:Const + Owned> RWARC<T> {
|
||||
}
|
||||
|
||||
/// To be called inside of the write_downgrade block.
|
||||
fn downgrade(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> {
|
||||
fn downgrade<'a>(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> {
|
||||
// The rwlock should assert that the token belongs to us for us.
|
||||
let state = unsafe { get_shared_immutable_state(&self.x) };
|
||||
let RWWriteMode {
|
||||
@ -420,7 +422,7 @@ pub struct RWReadMode<'self, T> {
|
||||
token: sync::RWlockReadMode<'self>,
|
||||
}
|
||||
|
||||
pub impl<T:Const + Owned> RWWriteMode<'self, T> {
|
||||
pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
|
||||
/// Access the pre-downgrade RWARC in write mode.
|
||||
fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
|
||||
match *self {
|
||||
@ -436,7 +438,9 @@ pub impl<T:Const + Owned> RWWriteMode<'self, T> {
|
||||
}
|
||||
}
|
||||
/// Access the pre-downgrade RWARC in write mode with a condvar.
|
||||
fn write_cond<U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U {
|
||||
fn write_cond<'x, 'c, U>(&self,
|
||||
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
|
||||
-> U {
|
||||
match *self {
|
||||
RWWriteMode {
|
||||
data: ref data,
|
||||
@ -458,7 +462,7 @@ pub impl<T:Const + Owned> RWWriteMode<'self, T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub impl<T:Const + Owned> RWReadMode<'self, T> {
|
||||
pub impl<'self, T:Const + Owned> RWReadMode<'self, T> {
|
||||
/// Access the post-downgrade rwlock in read mode.
|
||||
fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
|
||||
match *self {
|
||||
|
@ -24,7 +24,7 @@ static CHARS: [char * 64] = [
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
||||
];
|
||||
|
||||
impl ToBase64 for &'self [u8] {
|
||||
impl<'self> ToBase64 for &'self [u8] {
|
||||
fn to_base64(&self) -> ~str {
|
||||
let mut s = ~"";
|
||||
unsafe {
|
||||
@ -73,7 +73,7 @@ impl ToBase64 for &'self [u8] {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToBase64 for &'self str {
|
||||
impl<'self> ToBase64 for &'self str {
|
||||
fn to_base64(&self) -> ~str {
|
||||
str::to_bytes(*self).to_base64()
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ fn grow<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] {
|
||||
rv
|
||||
}
|
||||
|
||||
fn get<T>(elts: &'r [Option<T>], i: uint) -> &'r T {
|
||||
fn get<'r, T>(elts: &'r [Option<T>], i: uint) -> &'r T {
|
||||
match elts[i] { Some(ref t) => t, _ => fail!() }
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ pub mod flatteners {
|
||||
fn from_writer(w: @Writer) -> Self;
|
||||
}
|
||||
|
||||
impl FromReader for json::Decoder<'self> {
|
||||
impl<'self> FromReader for json::Decoder<'self> {
|
||||
fn from_reader(r: @Reader) -> json::Decoder<'self> {
|
||||
match json::from_reader(r) {
|
||||
Ok(json) => {
|
||||
|
@ -741,7 +741,7 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Decoder {
|
||||
pub struct Decoder<'self> {
|
||||
priv json: Json,
|
||||
priv mut stack: ~[&'self Json],
|
||||
}
|
||||
@ -750,7 +750,7 @@ pub fn Decoder(json: Json) -> Decoder {
|
||||
Decoder { json: json, stack: ~[] }
|
||||
}
|
||||
|
||||
priv impl Decoder<'self> {
|
||||
priv impl<'self> Decoder<'self> {
|
||||
fn peek(&self) -> &'self Json {
|
||||
if vec::uniq_len(&const self.stack) == 0 {
|
||||
self.stack.push(&self.json);
|
||||
@ -766,7 +766,7 @@ priv impl Decoder<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
impl serialize::Decoder for Decoder<'self> {
|
||||
impl<'self> serialize::Decoder for Decoder<'self> {
|
||||
fn read_nil(&self) -> () {
|
||||
debug!("read_nil");
|
||||
match *self.pop() {
|
||||
|
@ -213,7 +213,7 @@ impl<D:Decoder> Decodable<D> for i64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder> Encodable<S> for &'self str {
|
||||
impl<'self, S:Encoder> Encodable<S> for &'self str {
|
||||
fn encode(&self, s: &S) { s.emit_borrowed_str(*self) }
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ impl<D:Decoder> Decodable<D> for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
|
||||
impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
|
||||
fn encode(&self, s: &S) {
|
||||
s.emit_borrowed(|| (**self).encode(s))
|
||||
}
|
||||
@ -316,7 +316,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] {
|
||||
impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] {
|
||||
fn encode(&self, s: &S) {
|
||||
do s.emit_borrowed_vec(self.len()) {
|
||||
for self.eachi |i, e| {
|
||||
|
@ -22,7 +22,7 @@ pub struct SmallIntMap<T> {
|
||||
priv v: ~[Option<T>],
|
||||
}
|
||||
|
||||
impl<V> BaseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
impl<'self, V> BaseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
/// Visit all key-value pairs in order
|
||||
fn each(&self, it: &fn(&(uint, &'self V)) -> bool) {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
@ -36,7 +36,7 @@ impl<V> BaseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl<V> ReverseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
impl<'self, V> ReverseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
/// Visit all key-value pairs in reverse order
|
||||
fn each_reverse(&self, it: &fn(&(uint, &'self V)) -> bool) {
|
||||
for uint::range_rev(self.v.len(), 0) |i| {
|
||||
|
@ -16,7 +16,7 @@ use core::util;
|
||||
use core::vec::{len, push};
|
||||
use core::vec;
|
||||
|
||||
type Le<T> = &'self fn(v1: &T, v2: &T) -> bool;
|
||||
type Le<'self, T> = &'self fn(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<T:Copy + Ord + Eq> Sort for &'self mut [T] {
|
||||
impl<'self, T:Copy + Ord + Eq> Sort for &'self mut [T] {
|
||||
fn qsort(self) { quick_sort3(self); }
|
||||
}
|
||||
|
||||
@ -1188,7 +1188,7 @@ mod big_tests {
|
||||
}
|
||||
}
|
||||
|
||||
struct LVal {
|
||||
struct LVal<'self> {
|
||||
val: uint,
|
||||
key: &'self fn(@uint),
|
||||
}
|
||||
@ -1209,16 +1209,16 @@ mod big_tests {
|
||||
}
|
||||
|
||||
impl<'self> Ord for LVal<'self> {
|
||||
fn lt(&self, other: &'a LVal<'self>) -> bool {
|
||||
fn lt<'a>(&self, other: &'a LVal<'self>) -> bool {
|
||||
(*self).val < other.val
|
||||
}
|
||||
fn le(&self, other: &'a LVal<'self>) -> bool {
|
||||
fn le<'a>(&self, other: &'a LVal<'self>) -> bool {
|
||||
(*self).val <= other.val
|
||||
}
|
||||
fn gt(&self, other: &'a LVal<'self>) -> bool {
|
||||
fn gt<'a>(&self, other: &'a LVal<'self>) -> bool {
|
||||
(*self).val > other.val
|
||||
}
|
||||
fn ge(&self, other: &'a LVal<'self>) -> bool {
|
||||
fn ge<'a>(&self, other: &'a LVal<'self>) -> bool {
|
||||
(*self).val >= other.val
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub trait Stats {
|
||||
fn median_abs_dev_pct(self) -> f64;
|
||||
}
|
||||
|
||||
impl Stats for &'self [f64] {
|
||||
impl<'self> Stats for &'self [f64] {
|
||||
fn sum(self) -> f64 {
|
||||
vec::foldl(0.0, self, |p,q| p + *q)
|
||||
}
|
||||
|
@ -162,12 +162,12 @@ pub impl Sem<~[Waitqueue]> {
|
||||
|
||||
// FIXME(#3588) should go inside of access()
|
||||
#[doc(hidden)]
|
||||
type SemRelease = SemReleaseGeneric<'self, ()>;
|
||||
type SemAndSignalRelease = SemReleaseGeneric<'self, ~[Waitqueue]>;
|
||||
struct SemReleaseGeneric<Q> { sem: &'self Sem<Q> }
|
||||
type SemRelease<'self> = SemReleaseGeneric<'self, ()>;
|
||||
type SemAndSignalRelease<'self> = SemReleaseGeneric<'self, ~[Waitqueue]>;
|
||||
struct SemReleaseGeneric<'self, Q> { sem: &'self Sem<Q> }
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
|
||||
impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
self.sem.release();
|
||||
@ -175,14 +175,14 @@ impl<Q:Owned> Drop for SemReleaseGeneric<'self, Q> {
|
||||
}
|
||||
}
|
||||
|
||||
fn SemRelease(sem: &'r Sem<()>) -> SemRelease<'r> {
|
||||
fn SemRelease<'r>(sem: &'r Sem<()>) -> SemRelease<'r> {
|
||||
SemReleaseGeneric {
|
||||
sem: sem
|
||||
}
|
||||
}
|
||||
|
||||
fn SemAndSignalRelease(sem: &'r Sem<~[Waitqueue]>)
|
||||
-> SemAndSignalRelease<'r> {
|
||||
fn SemAndSignalRelease<'r>(sem: &'r Sem<~[Waitqueue]>)
|
||||
-> SemAndSignalRelease<'r> {
|
||||
SemReleaseGeneric {
|
||||
sem: sem
|
||||
}
|
||||
@ -194,7 +194,7 @@ pub struct Condvar<'self> { priv sem: &'self Sem<~[Waitqueue]> }
|
||||
#[unsafe_destructor]
|
||||
impl<'self> Drop for Condvar<'self> { fn finalize(&self) {} }
|
||||
|
||||
pub impl Condvar<'self> {
|
||||
pub impl<'self> Condvar<'self> {
|
||||
/**
|
||||
* Atomically drop the associated lock, and block until a signal is sent.
|
||||
*
|
||||
@ -260,7 +260,7 @@ pub impl Condvar<'self> {
|
||||
// This is needed for a failing condition variable to reacquire the
|
||||
// mutex during unwinding. As long as the wrapper (mutex, etc) is
|
||||
// bounded in when it gets released, this shouldn't hang forever.
|
||||
struct SemAndSignalReacquire {
|
||||
struct SemAndSignalReacquire<'self> {
|
||||
sem: &'self Sem<~[Waitqueue]>,
|
||||
}
|
||||
|
||||
@ -276,8 +276,8 @@ pub impl Condvar<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn SemAndSignalReacquire(sem: &'r Sem<~[Waitqueue]>)
|
||||
-> SemAndSignalReacquire<'r> {
|
||||
fn SemAndSignalReacquire<'r>(sem: &'r Sem<~[Waitqueue]>)
|
||||
-> SemAndSignalReacquire<'r> {
|
||||
SemAndSignalReacquire {
|
||||
sem: sem
|
||||
}
|
||||
@ -615,7 +615,7 @@ pub impl RWlock {
|
||||
|
||||
// FIXME(#3588) should go inside of read()
|
||||
#[doc(hidden)]
|
||||
struct RWlockReleaseRead {
|
||||
struct RWlockReleaseRead<'self> {
|
||||
lock: &'self RWlock,
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ fn RWlockReleaseRead<'r>(lock: &'r RWlock) -> RWlockReleaseRead<'r> {
|
||||
// FIXME(#3588) should go inside of downgrade()
|
||||
#[doc(hidden)]
|
||||
#[unsafe_destructor]
|
||||
struct RWlockReleaseDowngrade {
|
||||
struct RWlockReleaseDowngrade<'self> {
|
||||
lock: &'self RWlock,
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ pub struct RWlockWriteMode<'self> { priv lock: &'self RWlock }
|
||||
impl<'self> Drop for RWlockWriteMode<'self> { fn finalize(&self) {} }
|
||||
|
||||
/// The "read permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWlockReadMode { priv lock: &'self RWlock }
|
||||
pub struct RWlockReadMode<'self> { priv lock: &'self RWlock }
|
||||
#[unsafe_destructor]
|
||||
impl<'self> Drop for RWlockReadMode<'self> { fn finalize(&self) {} }
|
||||
|
||||
|
@ -198,7 +198,7 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||
}
|
||||
|
||||
/// Lazy forward iterator over a map
|
||||
pub struct TreeMapIterator<K, V> {
|
||||
pub struct TreeMapIterator<'self, K, V> {
|
||||
priv stack: ~[&'self ~TreeNode<K, V>],
|
||||
priv node: &'self Option<~TreeNode<K, V>>
|
||||
}
|
||||
@ -537,24 +537,25 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
fn each<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&'r K, &'r V)) -> bool) {
|
||||
fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&'r K, &'r V)) -> bool) {
|
||||
for node.each |x| {
|
||||
each(&x.left, f);
|
||||
if f(&(&x.key, &x.value)) { each(&x.right, f) }
|
||||
}
|
||||
}
|
||||
|
||||
fn each_reverse<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&'r K, &'r V)) -> bool) {
|
||||
fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&'r K, &'r V)) -> bool) {
|
||||
for node.each |x| {
|
||||
each_reverse(&x.right, f);
|
||||
if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) }
|
||||
}
|
||||
}
|
||||
|
||||
fn mutate_values<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
|
||||
f: &fn(&'r K, &'r mut V) -> bool) -> bool {
|
||||
fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
|
||||
f: &fn(&'r K, &'r mut V) -> bool)
|
||||
-> bool {
|
||||
match *node {
|
||||
Some(~TreeNode{key: ref key, value: ref mut value, left: ref mut left,
|
||||
right: ref mut right, _}) => {
|
||||
@ -590,7 +591,9 @@ fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_mut<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, key: &K) -> Option<&'r mut V> {
|
||||
fn find_mut<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
|
||||
key: &K)
|
||||
-> Option<&'r mut V> {
|
||||
match *node {
|
||||
Some(ref mut x) => {
|
||||
match key.cmp(&x.key) {
|
||||
|
@ -892,6 +892,7 @@ impl to_bytes::IterBytes for Onceness {
|
||||
pub struct TyClosure {
|
||||
sigil: Sigil,
|
||||
region: Option<@Lifetime>,
|
||||
lifetimes: OptVec<Lifetime>,
|
||||
purity: purity,
|
||||
onceness: Onceness,
|
||||
decl: fn_decl
|
||||
|
@ -34,16 +34,18 @@ pub mod clone;
|
||||
pub mod eq;
|
||||
pub mod iter_bytes;
|
||||
|
||||
type ExpandDerivingStructDefFn = &'self fn(@ext_ctxt,
|
||||
span,
|
||||
x: &struct_def,
|
||||
ident,
|
||||
y: &Generics) -> @item;
|
||||
type ExpandDerivingEnumDefFn = &'self fn(@ext_ctxt,
|
||||
span,
|
||||
x: &enum_def,
|
||||
ident,
|
||||
y: &Generics) -> @item;
|
||||
type ExpandDerivingStructDefFn<'self> = &'self fn(@ext_ctxt,
|
||||
span,
|
||||
x: &struct_def,
|
||||
ident,
|
||||
y: &Generics)
|
||||
-> @item;
|
||||
type ExpandDerivingEnumDefFn<'self> = &'self fn(@ext_ctxt,
|
||||
span,
|
||||
x: &enum_def,
|
||||
ident,
|
||||
y: &Generics)
|
||||
-> @item;
|
||||
|
||||
pub fn expand_meta_deriving(cx: @ext_ctxt,
|
||||
_span: span,
|
||||
|
@ -609,7 +609,8 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
|
||||
purity: f.purity,
|
||||
region: f.region,
|
||||
onceness: f.onceness,
|
||||
decl: fold_fn_decl(&f.decl, fld)
|
||||
decl: fold_fn_decl(&f.decl, fld),
|
||||
lifetimes: f.lifetimes,
|
||||
})
|
||||
}
|
||||
ty_bare_fn(ref f) => {
|
||||
|
@ -362,10 +362,11 @@ pub impl Parser {
|
||||
|
||||
let purity = self.parse_purity();
|
||||
self.expect_keyword(&~"fn");
|
||||
let (decl, _) = self.parse_ty_fn_decl();
|
||||
return ty_bare_fn(@TyBareFn {
|
||||
abi: RustAbi,
|
||||
purity: purity,
|
||||
decl: self.parse_ty_fn_decl()
|
||||
decl: decl
|
||||
});
|
||||
}
|
||||
|
||||
@ -400,12 +401,15 @@ pub impl Parser {
|
||||
ObsoletePostFnTySigil);
|
||||
}
|
||||
|
||||
let (decl, lifetimes) = self.parse_ty_fn_decl();
|
||||
|
||||
return ty_closure(@TyClosure {
|
||||
sigil: sigil,
|
||||
region: region,
|
||||
purity: purity,
|
||||
onceness: onceness,
|
||||
decl: self.parse_ty_fn_decl()
|
||||
decl: decl,
|
||||
lifetimes: lifetimes,
|
||||
});
|
||||
|
||||
fn parse_onceness(self: &Parser) -> Onceness {
|
||||
@ -424,7 +428,7 @@ pub impl Parser {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_ty_fn_decl(&self) -> fn_decl {
|
||||
fn parse_ty_fn_decl(&self) -> (fn_decl, OptVec<ast::Lifetime>) {
|
||||
/*
|
||||
|
||||
(fn) <'lt> (S) -> T
|
||||
@ -435,10 +439,14 @@ pub impl Parser {
|
||||
Lifetimes
|
||||
|
||||
*/
|
||||
if self.eat(&token::LT) {
|
||||
let _lifetimes = self.parse_lifetimes();
|
||||
let lifetimes = if self.eat(&token::LT) {
|
||||
let lifetimes = self.parse_lifetimes();
|
||||
self.expect_gt();
|
||||
}
|
||||
lifetimes
|
||||
} else {
|
||||
opt_vec::Empty
|
||||
};
|
||||
|
||||
let inputs = self.parse_unspanned_seq(
|
||||
&token::LPAREN,
|
||||
&token::RPAREN,
|
||||
@ -446,7 +454,12 @@ pub impl Parser {
|
||||
|p| p.parse_arg_general(false)
|
||||
);
|
||||
let (ret_style, ret_ty) = self.parse_ret_ty();
|
||||
ast::fn_decl { inputs: inputs, output: ret_ty, cf: ret_style }
|
||||
let decl = ast::fn_decl {
|
||||
inputs: inputs,
|
||||
output: ret_ty,
|
||||
cf: ret_style
|
||||
};
|
||||
(decl, lifetimes)
|
||||
}
|
||||
|
||||
fn parse_trait_methods(&self) -> ~[trait_method] {
|
||||
|
@ -18,7 +18,7 @@ trait Stuff {
|
||||
fn printme(self);
|
||||
}
|
||||
|
||||
impl Stuff for &'self mut Foo {
|
||||
impl<'self> Stuff for &'self mut Foo {
|
||||
fn printme(self) {
|
||||
io::println(fmt!("%d", self.x));
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ trait MyIter {
|
||||
fn test_mut(&mut self);
|
||||
}
|
||||
|
||||
impl MyIter for &'self [int] {
|
||||
impl<'self> MyIter for &'self [int] {
|
||||
fn test_mut(&mut self) { }
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct defer {
|
||||
struct defer<'self> {
|
||||
x: &'self [&'self str],
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for defer<'self> {
|
||||
impl<'self> Drop for defer<'self> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
error!("%?", self.x);
|
||||
@ -21,7 +21,7 @@ impl Drop for defer<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
fn defer(x: &'r [&'r str]) -> defer<'r> {
|
||||
fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
|
||||
defer {
|
||||
x: x
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct boxedFn { theFn: &'self fn() -> uint }
|
||||
struct boxedFn<'self> { theFn: &'self fn() -> uint }
|
||||
|
||||
fn createClosure (closedUint: uint) -> boxedFn {
|
||||
let theFn: @fn() -> uint = || closedUint;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct thing<Q> {
|
||||
struct thing<'self, Q> {
|
||||
x: &'self Q
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
// except according to those terms.
|
||||
|
||||
#[legacy_mode]
|
||||
struct Foo {
|
||||
struct Foo<'self> {
|
||||
s: &'self str,
|
||||
u: ~()
|
||||
}
|
||||
|
||||
pub impl Foo<'self> {
|
||||
pub impl<'self> Foo<'self> {
|
||||
fn get_s(&self) -> &'self str {
|
||||
self.s
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// n.b. This should be a run-pass test, but for now I'm testing
|
||||
// that we don't see an "unknown scope" error.
|
||||
fn vec_peek<T>(v: &'r [T]) -> Option< (&'r T, &'r [T]) > {
|
||||
fn vec_peek<'r, T>(v: &'r [T]) -> Option< (&'r T, &'r [T]) > {
|
||||
if v.len() == 0 {
|
||||
None
|
||||
} else {
|
||||
|
@ -12,6 +12,6 @@
|
||||
|
||||
fn main() {
|
||||
fn bar(n: int) {
|
||||
let _x: [int * n]; //~ ERROR expected constant expr for vector length: Non-constant path in constant expr
|
||||
let _x: [int, ..n]; //~ ERROR expected constant expr for vector length: Non-constant path in constant expr
|
||||
}
|
||||
}
|
||||
|
@ -12,18 +12,18 @@
|
||||
// nominal types (but not on other types) and that they are type
|
||||
// checked.
|
||||
|
||||
struct an_enum(&'self int);
|
||||
struct a_class { x:&'self int }
|
||||
struct an_enum<'self>(&'self int);
|
||||
struct a_class<'self> { x:&'self int }
|
||||
|
||||
fn a_fn1(e: an_enum<'a>) -> an_enum<'b> {
|
||||
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
|
||||
return e; //~ ERROR mismatched types: expected `an_enum/&'b ` but found `an_enum/&'a `
|
||||
}
|
||||
|
||||
fn a_fn3(e: a_class<'a>) -> a_class<'b> {
|
||||
fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
|
||||
return e; //~ ERROR mismatched types: expected `a_class/&'b ` but found `a_class/&'a `
|
||||
}
|
||||
|
||||
fn a_fn4(e: int<'a>) -> int<'b> {
|
||||
fn a_fn4<'a,'b>(e: int<'a>) -> int<'b> {
|
||||
//~^ ERROR region parameters are not allowed on this type
|
||||
//~^^ ERROR region parameters are not allowed on this type
|
||||
return e;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#[legacy_modes];
|
||||
|
||||
enum ast {
|
||||
enum ast<'self> {
|
||||
num(uint),
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum ast {
|
||||
enum ast<'self> {
|
||||
num(uint),
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
||||
fn mk_add_bad1(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
|
||||
fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
|
||||
add(x, y) //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ enum ast<'self> {
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
||||
fn mk_add_bad2(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast {
|
||||
fn mk_add_bad2<'a>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast {
|
||||
add(x, y)
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ trait deref {
|
||||
fn get(self) -> int;
|
||||
}
|
||||
|
||||
impl deref for &'self int {
|
||||
impl<'self> deref for &'self int {
|
||||
fn get(self) -> int {
|
||||
*self
|
||||
}
|
||||
|
@ -11,47 +11,47 @@
|
||||
fn of<T>() -> @fn(T) { fail!(); }
|
||||
fn subtype<T>(x: @fn(T)) { fail!(); }
|
||||
|
||||
fn test_fn<T>(_x: &'x T, _y: &'y T, _z: &'z T) {
|
||||
fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
|
||||
// Here, x, y, and z are free. Other letters
|
||||
// are bound. Note that the arrangement
|
||||
// subtype::<T1>(of::<T2>()) will typecheck
|
||||
// iff T1 <: T2.
|
||||
|
||||
subtype::<&fn(&'a T)>(
|
||||
of::<&fn(&'a T)>());
|
||||
subtype::<&fn<'a>(&'a T)>(
|
||||
of::<&fn<'a>(&'a T)>());
|
||||
|
||||
subtype::<&fn(&'a T)>(
|
||||
of::<&fn(&'b T)>());
|
||||
subtype::<&fn<'a>(&'a T)>(
|
||||
of::<&fn<'b>(&'b T)>());
|
||||
|
||||
subtype::<&fn(&'b T)>(
|
||||
of::<&fn(&'x T)>());
|
||||
subtype::<&fn<'b>(&'b T)>(
|
||||
of::<&fn<'x>(&'x T)>());
|
||||
|
||||
subtype::<&fn(&'x T)>(
|
||||
of::<&fn(&'b T)>()); //~ ERROR mismatched types
|
||||
subtype::<&fn<'x>(&'x T)>(
|
||||
of::<&fn<'b>(&'b T)>()); //~ ERROR mismatched types
|
||||
|
||||
subtype::<&fn(&'a T, &'b T)>(
|
||||
of::<&fn(&'a T, &'a T)>());
|
||||
subtype::<&fn<'a,'b>(&'a T, &'b T)>(
|
||||
of::<&fn<'a>(&'a T, &'a T)>());
|
||||
|
||||
subtype::<&fn(&'a T, &'a T)>(
|
||||
of::<&fn(&'a T, &'b T)>()); //~ ERROR mismatched types
|
||||
subtype::<&fn<'a>(&'a T, &'a T)>(
|
||||
of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
|
||||
|
||||
subtype::<&fn(&'a T, &'b T)>(
|
||||
of::<&fn(&'x T, &'y T)>());
|
||||
subtype::<&fn<'a,'b>(&'a T, &'b T)>(
|
||||
of::<&fn<'x,'y>(&'x T, &'y T)>());
|
||||
|
||||
subtype::<&fn(&'x T, &'y T)>(
|
||||
of::<&fn(&'a T, &'b T)>()); //~ ERROR mismatched types
|
||||
subtype::<&fn<'x,'y>(&'x T, &'y T)>(
|
||||
of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
|
||||
|
||||
subtype::<&fn(&'x T) -> @fn(&'a T)>(
|
||||
of::<&fn(&'x T) -> @fn(&'a T)>());
|
||||
subtype::<&fn<'x,'a>(&'x T) -> @fn(&'a T)>(
|
||||
of::<&fn<'x,'a>(&'x T) -> @fn(&'a T)>());
|
||||
|
||||
subtype::<&fn(&'a T) -> @fn(&'a T)>(
|
||||
of::<&fn(&'a T) -> @fn(&'b T)>()); //~ ERROR mismatched types
|
||||
subtype::<&fn<'a>(&'a T) -> @fn(&'a T)>(
|
||||
of::<&fn<'a,'b>(&'a T) -> @fn(&'b T)>()); //~ ERROR mismatched types
|
||||
|
||||
subtype::<&fn(&'a T) -> @fn(&'a T)>(
|
||||
of::<&fn(&'x T) -> @fn(&'b T)>()); //~ ERROR mismatched types
|
||||
subtype::<&fn<'a>(&'a T) -> @fn(&'a T)>(
|
||||
of::<&fn<'x,'b>(&'x T) -> @fn(&'b T)>()); //~ ERROR mismatched types
|
||||
|
||||
subtype::<&fn(&'a T) -> @fn(&'b T)>(
|
||||
of::<&fn(&'a T) -> @fn(&'a T)>());
|
||||
subtype::<&fn<'a,'b>(&'a T) -> @fn(&'b T)>(
|
||||
of::<&fn<'a>(&'a T) -> @fn(&'a T)>());
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Before fn subtyping was properly implemented,
|
||||
// we reported errors in this case:
|
||||
|
||||
fn not_ok(a: &uint, b: &'b uint) {
|
||||
fn not_ok<'b>(a: &uint, b: &'b uint) {
|
||||
let mut g: @fn(x: &uint) = |x: &'b uint| {};
|
||||
//~^ ERROR mismatched types
|
||||
g(a);
|
||||
|
@ -18,11 +18,11 @@ mod argparse {
|
||||
value: uint
|
||||
}
|
||||
|
||||
pub fn flag(name: &'r str, desc: &'r str) -> Flag<'r> {
|
||||
pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> {
|
||||
Flag { name: name, desc: desc, max_count: 1, value: 0 }
|
||||
}
|
||||
|
||||
pub impl Flag<'self> {
|
||||
pub impl<'self> Flag<'self> {
|
||||
fn set_desc(self, s: &str) -> Flag<'self> {
|
||||
Flag { //~ ERROR cannot infer an appropriate lifetime
|
||||
name: self.name,
|
||||
|
@ -10,15 +10,15 @@
|
||||
|
||||
enum yes0<'lt> {
|
||||
// This will eventually be legal (and in fact the only way):
|
||||
X3(&'lt uint) //~ ERROR Illegal lifetime 'lt: only 'self is allowed allowed as part of a type declaration
|
||||
X3(&'lt uint) //~ ERROR Illegal lifetime 'lt: this lifetime must be declared
|
||||
}
|
||||
|
||||
enum yes1 {
|
||||
enum yes1<'self> {
|
||||
X4(&'self uint)
|
||||
}
|
||||
|
||||
enum yes2 {
|
||||
X5(&'foo uint) //~ ERROR Illegal lifetime 'foo: only 'self is allowed allowed as part of a type declaration
|
||||
X5(&'foo uint) //~ ERROR Illegal lifetime 'foo: this lifetime must be declared
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -17,7 +17,7 @@ struct yes1<'self> {
|
||||
}
|
||||
|
||||
struct yes2<'self> {
|
||||
x: &'foo uint, //~ ERROR Illegal lifetime 'foo: only 'self is allowed allowed as part of a type declaration
|
||||
x: &'foo uint, //~ ERROR Illegal lifetime 'foo: this lifetime must be declared
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -8,16 +8,16 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct item_ty_yes0 {
|
||||
struct item_ty_yes0<'self> {
|
||||
x: &'self uint
|
||||
}
|
||||
|
||||
struct item_ty_yes1 {
|
||||
struct item_ty_yes1<'self> {
|
||||
x: &'self uint
|
||||
}
|
||||
|
||||
struct item_ty_yes2 {
|
||||
x: &'a uint //~ ERROR only 'self is allowed
|
||||
x: &'a uint //~ ERROR this lifetime must be declared
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct parameterized1 {
|
||||
struct parameterized1<'self> {
|
||||
g: &'self fn()
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ struct point {
|
||||
y: int,
|
||||
}
|
||||
|
||||
fn x_coord(p: &'r point) -> &'r int {
|
||||
fn x_coord<'r>(p: &'r point) -> &'r int {
|
||||
return &p.x;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn borrow<T>(x: &'r T) -> &'r T {x}
|
||||
fn borrow<'r, T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
fn foo(cond: &fn() -> bool, box: &fn() -> @int) {
|
||||
let mut y: ∫
|
||||
|
@ -8,13 +8,13 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn select(x: &'r int, y: &'r int) -> &'r int { x }
|
||||
fn select<'r>(x: &'r int, y: &'r int) -> &'r int { x }
|
||||
|
||||
fn with<T>(f: &fn(x: &int) -> T) -> T {
|
||||
f(&20)
|
||||
}
|
||||
|
||||
fn manip(x: &'a int) -> int {
|
||||
fn manip<'a>(x: &'a int) -> int {
|
||||
let z = do with |y| { select(x, y) };
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
*z
|
||||
|
@ -8,19 +8,19 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct contravariant {
|
||||
struct contravariant<'self> {
|
||||
f: &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: contravariant<'r>) {
|
||||
fn to_same_lifetime<'r>(bi: contravariant<'r>) {
|
||||
let bj: contravariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: contravariant<'r>) {
|
||||
fn to_shorter_lifetime<'r>(bi: contravariant<'r>) {
|
||||
let bj: contravariant<'blk> = bi;
|
||||
}
|
||||
|
||||
fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant<'static> {
|
||||
fn to_longer_lifetime<'r>(bi: contravariant<'r>) -> contravariant<'static> {
|
||||
bi //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
//
|
||||
// You can upcast to a *larger region* but not a smaller one.
|
||||
|
||||
struct covariant {
|
||||
struct covariant<'self> {
|
||||
f: @fn(x: &'self int) -> int
|
||||
}
|
||||
|
||||
|
@ -8,19 +8,15 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
struct invariant<'self> {
|
||||
f: @mut &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
fn to_same_lifetime<'r>(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
|
||||
bi //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
|
@ -12,15 +12,11 @@ struct invariant<'self> {
|
||||
f: @mut [&'self int]
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
fn to_same_lifetime<'r>(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
|
||||
bi //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,7 @@ fn to_same_lifetime<'r>(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
|
||||
bi //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
|
@ -12,15 +12,11 @@ struct invariant<'self> {
|
||||
f: @fn() -> @mut &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
fn to_same_lifetime<'r>(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
|
||||
bi //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn ignore<T>(_t: T) {}
|
||||
fn ignore(_f: &fn<'z>(&'z int) -> &'z int) {}
|
||||
|
||||
fn nested() {
|
||||
let y = 3;
|
||||
ignore(|z: &'z int| -> &'z int {
|
||||
ignore(|z| {
|
||||
if false { &y } else { z } //~ ERROR illegal borrow
|
||||
});
|
||||
}
|
||||
|
@ -10,17 +10,17 @@
|
||||
|
||||
fn ignore<T>(t: T) {}
|
||||
|
||||
fn nested(x: &'x int) {
|
||||
fn nested<'x>(x: &'x int) {
|
||||
let y = 3;
|
||||
let mut ay = &y; //~ ERROR cannot infer an appropriate lifetime
|
||||
|
||||
ignore(|z: &'z int| {
|
||||
ignore::<&fn<'z>(&'z int)>(|z| {
|
||||
ay = x;
|
||||
ay = &y; //~ ERROR cannot infer an appropriate lifetime
|
||||
ay = z;
|
||||
});
|
||||
|
||||
ignore(|z: &'z int| -> &'z int {
|
||||
ignore::<&fn<'z>(&'z int) -> &'z int>(|z| {
|
||||
if false { return x; } //~ ERROR mismatched types
|
||||
if false { return ay; }
|
||||
return z;
|
||||
|
@ -12,11 +12,11 @@
|
||||
// some point regions-ret-borrowed reported an error but this file did
|
||||
// not, due to special hardcoding around the anonymous region.
|
||||
|
||||
fn with<R>(f: &fn(x: &'a int) -> R) -> R {
|
||||
fn with<'a, R>(f: &fn(x: &'a int) -> R) -> R {
|
||||
f(&3)
|
||||
}
|
||||
|
||||
fn return_it() -> &'a int {
|
||||
fn return_it<'a>() -> &'a int {
|
||||
with(|o| o) //~ ERROR mismatched types
|
||||
//~^ ERROR reference is not valid outside of its lifetime
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f(_x : &'a int) -> &'a int {
|
||||
fn f<'a>(_x : &'a int) -> &'a int {
|
||||
return &3; //~ ERROR illegal borrow
|
||||
}
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn with<T>(t: T, f: &fn(T)) { f(t) }
|
||||
|
||||
fn nested<'x>(x: &'x int) { // (1)
|
||||
do with(
|
||||
|x: &'x int, // Refers to the region `x` at (1)
|
||||
y: &'y int, // A fresh region `y` (2)
|
||||
z: &fn<'z>(x: &'x int, // Refers to `x` at (1)
|
||||
y: &'y int, // Refers to `y` at (2)
|
||||
z: &'z int) -> &'z int| // A fresh region `z` (3)
|
||||
-> &'x int {
|
||||
if false { return z(x, y, x); }
|
||||
|
||||
if false { return z(x, y, y); }
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
|
||||
return z(y, x, x);
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
) |foo| {
|
||||
|
||||
let a: &'x int = foo(x, x, |_x, _y, z| z );
|
||||
let b: &'x int = foo(x, a, |_x, _y, z| z );
|
||||
let c: &'x int = foo(a, a, |_x, _y, z| z );
|
||||
|
||||
let z = 3i;
|
||||
let d: &'x int = foo(x, x, |_x, _y, z| z );
|
||||
let e: &'x int = foo(x, &z, |_x, _y, z| z );
|
||||
|
||||
// This would result in an error, but it is not reported by typeck
|
||||
// anymore but rather borrowck. Therefore, it doesn't end up
|
||||
// getting printed out since compilation fails after typeck.
|
||||
//
|
||||
// let f: &'x int = foo(&z, &z, |_x, _y, z| z ); // ERROR mismatched types: expected `&'x int` but found
|
||||
|
||||
foo(x, &z, |x, _y, _z| x); //~ ERROR mismatched types: expected `&'z int` but found `&'x int`
|
||||
|
||||
// Note: originally I had foo(x, &z, ...) here, but in that
|
||||
// case the region inferencer deduced that this was valid if
|
||||
// &y==&static, and so inference would succeed but borrow
|
||||
// check would fail because the lifetime of &z is not &static.
|
||||
foo(x, x, |_x, y, _z| y); //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -12,7 +12,7 @@ struct closure_box<'self> {
|
||||
cl: &'self fn()
|
||||
}
|
||||
|
||||
fn box_it(x: &'r fn()) -> closure_box<'r> {
|
||||
fn box_it<'r>(x: &'r fn()) -> closure_box<'r> {
|
||||
closure_box {cl: x}
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ trait get_ctxt {
|
||||
fn get_ctxt(&self) -> &ctxt;
|
||||
}
|
||||
|
||||
struct has_ctxt { c: &'self ctxt }
|
||||
struct has_ctxt<'self> { c: &'self ctxt }
|
||||
|
||||
impl get_ctxt for has_ctxt<'self> {
|
||||
impl<'self> get_ctxt for has_ctxt<'self> {
|
||||
|
||||
// Here an error occurs because we used `&self` but
|
||||
// the definition used `&`:
|
||||
|
@ -16,7 +16,7 @@ trait iterable<A> {
|
||||
fn iterate(&self, blk: &fn(x: &A) -> bool);
|
||||
}
|
||||
|
||||
impl<A> iterable<A> for &'self [A] {
|
||||
impl<'self,A> iterable<A> for &'self [A] {
|
||||
fn iterate(&self, f: &fn(x: &A) -> bool) {
|
||||
for vec::each(*self) |e| {
|
||||
if !f(e) { break; }
|
||||
|
@ -16,12 +16,12 @@ trait MyIter {
|
||||
fn test_const(&const self);
|
||||
}
|
||||
|
||||
impl MyIter for &'self [int] {
|
||||
impl<'self> MyIter for &'self [int] {
|
||||
fn test_imm(&self) { fail_unless!(self[0] == 1) }
|
||||
fn test_const(&const self) { fail_unless!(self[0] == 1) }
|
||||
}
|
||||
|
||||
impl MyIter for &'self str {
|
||||
impl<'self> MyIter for &'self str {
|
||||
fn test_imm(&self) { fail_unless!(*self == "test") }
|
||||
fn test_const(&const self) { fail_unless!(*self == "test") }
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ trait Foo {
|
||||
fn foo(self);
|
||||
}
|
||||
|
||||
impl Foo for &'self [int] {
|
||||
impl<'self> Foo for &'self [int] {
|
||||
fn foo(self) {}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn borrow<T>(x: &'r T) -> &'r T {x}
|
||||
fn borrow<'r,T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
struct Rec { f: @int }
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo(s: &'r uint) -> bool {
|
||||
fn foo<'r>(s: &'r uint) -> bool {
|
||||
match s {
|
||||
&3 => true,
|
||||
_ => false
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn select(x: &'r Option<int>, y: &'r Option<int>) -> &'r Option<int> {
|
||||
fn select<'r>(x: &'r Option<int>, y: &'r Option<int>) -> &'r Option<int> {
|
||||
match (x, y) {
|
||||
(&None, &None) => x,
|
||||
(&Some(_), _) => x,
|
||||
|
@ -49,7 +49,7 @@ pub impl<T> cat<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> BaseIter<(int, &'self T)> for cat<T> {
|
||||
impl<'self,T> BaseIter<(int, &'self T)> for cat<T> {
|
||||
fn each(&self, f: &fn(&(int, &'self T)) -> bool) {
|
||||
let mut n = int::abs(self.meows);
|
||||
while n > 0 {
|
||||
|
@ -2,7 +2,7 @@ trait Reverser {
|
||||
fn reverse(&self);
|
||||
}
|
||||
|
||||
impl Reverser for &'self mut [uint] {
|
||||
impl<'self> Reverser for &'self mut [uint] {
|
||||
fn reverse(&self) {
|
||||
vec::reverse(*self);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user