Skip to content

Commit e6a5a6b

Browse files
committed
---
yaml --- r: 41628 b: refs/heads/master c: 8f9a507 h: refs/heads/master v: v3
1 parent 9989b0c commit e6a5a6b

File tree

2 files changed

+61
-56
lines changed

2 files changed

+61
-56
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: dc7183ed0e5da6317d7b3cc3ea25ae30e1a91bcd
2+
refs/heads/master: 8f9a5079732aa22596ad27e4996189e34147fc1d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcore/vec.rs

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,94 +1539,96 @@ pub mod traits {
15391539
}
15401540

15411541
pub trait ConstVector {
1542-
pure fn is_empty() -> bool;
1543-
pure fn is_not_empty() -> bool;
1544-
pure fn len() -> uint;
1542+
pure fn is_empty(&self) -> bool;
1543+
pure fn is_not_empty(&self) -> bool;
1544+
pure fn len(&self) -> uint;
15451545
}
15461546

15471547
/// Extension methods for vectors
15481548
impl<T> &[const T]: ConstVector {
15491549
/// Returns true if a vector contains no elements
15501550
#[inline]
1551-
pure fn is_empty() -> bool { is_empty(self) }
1551+
pure fn is_empty(&self) -> bool { is_empty(*self) }
15521552
/// Returns true if a vector contains some elements
15531553
#[inline]
1554-
pure fn is_not_empty() -> bool { is_not_empty(self) }
1554+
pure fn is_not_empty(&self) -> bool { is_not_empty(*self) }
15551555
/// Returns the length of a vector
15561556
#[inline]
1557-
pure fn len() -> uint { len(self) }
1557+
pure fn len(&self) -> uint { len(*self) }
15581558
}
15591559

15601560
pub trait CopyableVector<T> {
1561-
pure fn head() -> T;
1562-
pure fn init() -> ~[T];
1563-
pure fn last() -> T;
1564-
pure fn slice(start: uint, end: uint) -> ~[T];
1565-
pure fn tail() -> ~[T];
1561+
pure fn head(&self) -> T;
1562+
pure fn init(&self) -> ~[T];
1563+
pure fn last(&self) -> T;
1564+
pure fn slice(&self, start: uint, end: uint) -> ~[T];
1565+
pure fn tail(&self) -> ~[T];
15661566
}
15671567

15681568
/// Extension methods for vectors
15691569
impl<T: Copy> &[const T]: CopyableVector<T> {
15701570
/// Returns the first element of a vector
15711571
#[inline]
1572-
pure fn head() -> T { head(self) }
1572+
pure fn head(&self) -> T { head(*self) }
15731573

15741574
/// Returns all but the last elemnt of a vector
15751575
#[inline]
1576-
pure fn init() -> ~[T] { init(self) }
1576+
pure fn init(&self) -> ~[T] { init(*self) }
15771577

15781578
/// Returns the last element of a `v`, failing if the vector is empty.
15791579
#[inline]
1580-
pure fn last() -> T { last(self) }
1580+
pure fn last(&self) -> T { last(*self) }
15811581

15821582
/// Returns a copy of the elements from [`start`..`end`) from `v`.
15831583
#[inline]
1584-
pure fn slice(start: uint, end: uint) -> ~[T] { slice(self, start, end) }
1584+
pure fn slice(&self, start: uint, end: uint) -> ~[T] {
1585+
slice(*self, start, end)
1586+
}
15851587

15861588
/// Returns all but the first element of a vector
15871589
#[inline]
1588-
pure fn tail() -> ~[T] { tail(self) }
1590+
pure fn tail(&self) -> ~[T] { tail(*self) }
15891591
}
15901592

15911593
pub trait ImmutableVector<T> {
1592-
pure fn view(start: uint, end: uint) -> &self/[T];
1593-
pure fn foldr<U: Copy>(z: U, p: fn(t: &T, u: U) -> U) -> U;
1594-
pure fn map<U>(f: fn(t: &T) -> U) -> ~[U];
1595-
pure fn mapi<U>(f: fn(uint, t: &T) -> U) -> ~[U];
1596-
fn map_r<U>(f: fn(x: &T) -> U) -> ~[U];
1597-
pure fn alli(f: fn(uint, t: &T) -> bool) -> bool;
1598-
pure fn flat_map<U>(f: fn(t: &T) -> ~[U]) -> ~[U];
1599-
pure fn filter_map<U: Copy>(f: fn(t: &T) -> Option<U>) -> ~[U];
1594+
pure fn view(&self, start: uint, end: uint) -> &self/[T];
1595+
pure fn foldr<U: Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U;
1596+
pure fn map<U>(&self, f: fn(t: &T) -> U) -> ~[U];
1597+
pure fn mapi<U>(&self, f: fn(uint, t: &T) -> U) -> ~[U];
1598+
fn map_r<U>(&self, f: fn(x: &T) -> U) -> ~[U];
1599+
pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool;
1600+
pure fn flat_map<U>(&self, f: fn(t: &T) -> ~[U]) -> ~[U];
1601+
pure fn filter_map<U: Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U];
16001602
}
16011603

16021604
/// Extension methods for vectors
16031605
impl<T> &[T]: ImmutableVector<T> {
16041606
/// Return a slice that points into another slice.
16051607
#[inline]
1606-
pure fn view(start: uint, end: uint) -> &self/[T] {
1607-
view(self, start, end)
1608+
pure fn view(&self, start: uint, end: uint) -> &self/[T] {
1609+
view(*self, start, end)
16081610
}
16091611

16101612
/// Reduce a vector from right to left
16111613
#[inline]
1612-
pure fn foldr<U: Copy>(z: U, p: fn(t: &T, u: U) -> U) -> U {
1613-
foldr(self, z, p)
1614+
pure fn foldr<U: Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U {
1615+
foldr(*self, z, p)
16141616
}
16151617

16161618
/// Apply a function to each element of a vector and return the results
16171619
#[inline]
1618-
pure fn map<U>(f: fn(t: &T) -> U) -> ~[U] { map(self, f) }
1620+
pure fn map<U>(&self, f: fn(t: &T) -> U) -> ~[U] { map(*self, f) }
16191621

16201622
/**
16211623
* Apply a function to the index and value of each element in the vector
16221624
* and return the results
16231625
*/
1624-
pure fn mapi<U>(f: fn(uint, t: &T) -> U) -> ~[U] {
1625-
mapi(self, f)
1626+
pure fn mapi<U>(&self, f: fn(uint, t: &T) -> U) -> ~[U] {
1627+
mapi(*self, f)
16261628
}
16271629

16281630
#[inline]
1629-
fn map_r<U>(f: fn(x: &T) -> U) -> ~[U] {
1631+
fn map_r<U>(&self, f: fn(x: &T) -> U) -> ~[U] {
16301632
let mut r = ~[];
16311633
let mut i = 0;
16321634
while i < self.len() {
@@ -1641,16 +1643,16 @@ impl<T> &[T]: ImmutableVector<T> {
16411643
*
16421644
* If the vector is empty, true is returned.
16431645
*/
1644-
pure fn alli(f: fn(uint, t: &T) -> bool) -> bool {
1645-
alli(self, f)
1646+
pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool {
1647+
alli(*self, f)
16461648
}
16471649
/**
16481650
* Apply a function to each element of a vector and return a concatenation
16491651
* of each result vector
16501652
*/
16511653
#[inline]
1652-
pure fn flat_map<U>(f: fn(t: &T) -> ~[U]) -> ~[U] {
1653-
flat_map(self, f)
1654+
pure fn flat_map<U>(&self, f: fn(t: &T) -> ~[U]) -> ~[U] {
1655+
flat_map(*self, f)
16541656
}
16551657
/**
16561658
* Apply a function to each element of a vector and return the results
@@ -1659,16 +1661,17 @@ impl<T> &[T]: ImmutableVector<T> {
16591661
* the resulting vector.
16601662
*/
16611663
#[inline]
1662-
pure fn filter_map<U: Copy>(f: fn(t: &T) -> Option<U>) -> ~[U] {
1663-
filter_map(self, f)
1664+
pure fn filter_map<U: Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U] {
1665+
filter_map(*self, f)
16641666
}
1667+
16651668
}
16661669

16671670
pub trait ImmutableEqVector<T: Eq> {
1668-
pure fn position(f: fn(t: &T) -> bool) -> Option<uint>;
1669-
pure fn position_elem(t: &T) -> Option<uint>;
1670-
pure fn rposition(f: fn(t: &T) -> bool) -> Option<uint>;
1671-
pure fn rposition_elem(t: &T) -> Option<uint>;
1671+
pure fn position(&self, f: fn(t: &T) -> bool) -> Option<uint>;
1672+
pure fn position_elem(&self, t: &T) -> Option<uint>;
1673+
pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option<uint>;
1674+
pure fn rposition_elem(&self, t: &T) -> Option<uint>;
16721675
}
16731676

16741677
impl<T: Eq> &[T]: ImmutableEqVector<T> {
@@ -1680,14 +1683,14 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
16801683
* elements then none is returned.
16811684
*/
16821685
#[inline]
1683-
pure fn position(f: fn(t: &T) -> bool) -> Option<uint> {
1684-
position(self, f)
1686+
pure fn position(&self, f: fn(t: &T) -> bool) -> Option<uint> {
1687+
position(*self, f)
16851688
}
16861689

16871690
/// Find the first index containing a matching value
16881691
#[inline]
1689-
pure fn position_elem(x: &T) -> Option<uint> {
1690-
position_elem(self, x)
1692+
pure fn position_elem(&self, x: &T) -> Option<uint> {
1693+
position_elem(*self, x)
16911694
}
16921695

16931696
/**
@@ -1698,21 +1701,21 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
16981701
* returned. If `f` matches no elements then none is returned.
16991702
*/
17001703
#[inline]
1701-
pure fn rposition(f: fn(t: &T) -> bool) -> Option<uint> {
1702-
rposition(self, f)
1704+
pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option<uint> {
1705+
rposition(*self, f)
17031706
}
17041707

17051708
/// Find the last index containing a matching value
17061709
#[inline]
1707-
pure fn rposition_elem(t: &T) -> Option<uint> {
1708-
rposition_elem(self, t)
1710+
pure fn rposition_elem(&self, t: &T) -> Option<uint> {
1711+
rposition_elem(*self, t)
17091712
}
17101713
}
17111714

17121715
pub trait ImmutableCopyableVector<T> {
1713-
pure fn filter(f: fn(t: &T) -> bool) -> ~[T];
1716+
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T];
17141717

1715-
pure fn rfind(f: fn(t: &T) -> bool) -> Option<T>;
1718+
pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T>;
17161719
}
17171720

17181721
/// Extension methods for vectors
@@ -1725,8 +1728,8 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
17251728
* containing only those elements for which `f` returned true.
17261729
*/
17271730
#[inline]
1728-
pure fn filter(f: fn(t: &T) -> bool) -> ~[T] {
1729-
filter(self, f)
1731+
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T] {
1732+
filter(*self, f)
17301733
}
17311734

17321735
/**
@@ -1737,7 +1740,9 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
17371740
* returned. If `f` matches no elements then none is returned.
17381741
*/
17391742
#[inline]
1740-
pure fn rfind(f: fn(t: &T) -> bool) -> Option<T> { rfind(self, f) }
1743+
pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T> {
1744+
rfind(*self, f)
1745+
}
17411746
}
17421747

17431748
pub trait OwnedVector<T> {

0 commit comments

Comments
 (0)