@@ -1539,94 +1539,96 @@ pub mod traits {
1539
1539
}
1540
1540
1541
1541
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 ;
1545
1545
}
1546
1546
1547
1547
/// Extension methods for vectors
1548
1548
impl < T > & [ const T ] : ConstVector {
1549
1549
/// Returns true if a vector contains no elements
1550
1550
#[ inline]
1551
- pure fn is_empty ( ) -> bool { is_empty ( self ) }
1551
+ pure fn is_empty ( & self ) -> bool { is_empty ( * self ) }
1552
1552
/// Returns true if a vector contains some elements
1553
1553
#[ inline]
1554
- pure fn is_not_empty ( ) -> bool { is_not_empty ( self ) }
1554
+ pure fn is_not_empty ( & self ) -> bool { is_not_empty ( * self ) }
1555
1555
/// Returns the length of a vector
1556
1556
#[ inline]
1557
- pure fn len ( ) -> uint { len ( self ) }
1557
+ pure fn len ( & self ) -> uint { len ( * self ) }
1558
1558
}
1559
1559
1560
1560
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 ] ;
1566
1566
}
1567
1567
1568
1568
/// Extension methods for vectors
1569
1569
impl < T : Copy > & [ const T ] : CopyableVector < T > {
1570
1570
/// Returns the first element of a vector
1571
1571
#[ inline]
1572
- pure fn head ( ) -> T { head ( self ) }
1572
+ pure fn head ( & self ) -> T { head ( * self ) }
1573
1573
1574
1574
/// Returns all but the last elemnt of a vector
1575
1575
#[ inline]
1576
- pure fn init ( ) -> ~[ T ] { init ( self ) }
1576
+ pure fn init ( & self ) -> ~[ T ] { init ( * self ) }
1577
1577
1578
1578
/// Returns the last element of a `v`, failing if the vector is empty.
1579
1579
#[ inline]
1580
- pure fn last ( ) -> T { last ( self ) }
1580
+ pure fn last ( & self ) -> T { last ( * self ) }
1581
1581
1582
1582
/// Returns a copy of the elements from [`start`..`end`) from `v`.
1583
1583
#[ 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
+ }
1585
1587
1586
1588
/// Returns all but the first element of a vector
1587
1589
#[ inline]
1588
- pure fn tail ( ) -> ~[ T ] { tail ( self ) }
1590
+ pure fn tail ( & self ) -> ~[ T ] { tail ( * self ) }
1589
1591
}
1590
1592
1591
1593
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 ] ;
1600
1602
}
1601
1603
1602
1604
/// Extension methods for vectors
1603
1605
impl < T > & [ T ] : ImmutableVector < T > {
1604
1606
/// Return a slice that points into another slice.
1605
1607
#[ 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)
1608
1610
}
1609
1611
1610
1612
/// Reduce a vector from right to left
1611
1613
#[ 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)
1614
1616
}
1615
1617
1616
1618
/// Apply a function to each element of a vector and return the results
1617
1619
#[ 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) }
1619
1621
1620
1622
/**
1621
1623
* Apply a function to the index and value of each element in the vector
1622
1624
* and return the results
1623
1625
*/
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)
1626
1628
}
1627
1629
1628
1630
#[ inline]
1629
- fn map_r < U > ( f : fn ( x : & T ) -> U ) -> ~[ U ] {
1631
+ fn map_r < U > ( & self , f : fn ( x : & T ) -> U ) -> ~[ U ] {
1630
1632
let mut r = ~[ ] ;
1631
1633
let mut i = 0 ;
1632
1634
while i < self . len ( ) {
@@ -1641,16 +1643,16 @@ impl<T> &[T]: ImmutableVector<T> {
1641
1643
*
1642
1644
* If the vector is empty, true is returned.
1643
1645
*/
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)
1646
1648
}
1647
1649
/**
1648
1650
* Apply a function to each element of a vector and return a concatenation
1649
1651
* of each result vector
1650
1652
*/
1651
1653
#[ 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)
1654
1656
}
1655
1657
/**
1656
1658
* Apply a function to each element of a vector and return the results
@@ -1659,16 +1661,17 @@ impl<T> &[T]: ImmutableVector<T> {
1659
1661
* the resulting vector.
1660
1662
*/
1661
1663
#[ 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)
1664
1666
}
1667
+
1665
1668
}
1666
1669
1667
1670
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 > ;
1672
1675
}
1673
1676
1674
1677
impl < T : Eq > & [ T ] : ImmutableEqVector < T > {
@@ -1680,14 +1683,14 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
1680
1683
* elements then none is returned.
1681
1684
*/
1682
1685
#[ 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)
1685
1688
}
1686
1689
1687
1690
/// Find the first index containing a matching value
1688
1691
#[ 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)
1691
1694
}
1692
1695
1693
1696
/**
@@ -1698,21 +1701,21 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
1698
1701
* returned. If `f` matches no elements then none is returned.
1699
1702
*/
1700
1703
#[ 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)
1703
1706
}
1704
1707
1705
1708
/// Find the last index containing a matching value
1706
1709
#[ 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)
1709
1712
}
1710
1713
}
1711
1714
1712
1715
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 ] ;
1714
1717
1715
- pure fn rfind ( f : fn ( t : & T ) -> bool ) -> Option < T > ;
1718
+ pure fn rfind ( & self , f : fn ( t : & T ) -> bool ) -> Option < T > ;
1716
1719
}
1717
1720
1718
1721
/// Extension methods for vectors
@@ -1725,8 +1728,8 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
1725
1728
* containing only those elements for which `f` returned true.
1726
1729
*/
1727
1730
#[ 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)
1730
1733
}
1731
1734
1732
1735
/**
@@ -1737,7 +1740,9 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
1737
1740
* returned. If `f` matches no elements then none is returned.
1738
1741
*/
1739
1742
#[ 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
+ }
1741
1746
}
1742
1747
1743
1748
pub trait OwnedVector < T > {
0 commit comments