@@ -1813,13 +1813,15 @@ pub struct LookSet {
1813
1813
1814
1814
impl LookSet {
1815
1815
/// Create an empty set of look-around assertions.
1816
+ #[ inline]
1816
1817
pub fn empty ( ) -> LookSet {
1817
1818
LookSet { bits : 0 }
1818
1819
}
1819
1820
1820
1821
/// Create a full set of look-around assertions.
1821
1822
///
1822
1823
/// This set contains all possible look-around assertions.
1824
+ #[ inline]
1823
1825
pub fn full ( ) -> LookSet {
1824
1826
LookSet { bits : !0 }
1825
1827
}
@@ -1828,48 +1830,67 @@ impl LookSet {
1828
1830
///
1829
1831
/// This is a convenience routine for creating an empty set and inserting
1830
1832
/// one look-around assertions.
1833
+ #[ inline]
1831
1834
pub fn singleton ( look : Look ) -> LookSet {
1832
1835
let mut set = LookSet :: empty ( ) ;
1833
1836
set. insert ( look) ;
1834
1837
set
1835
1838
}
1836
1839
1837
1840
/// Returns the total number of look-around assertions in this set.
1841
+ #[ inline]
1838
1842
pub fn len ( & self ) -> usize {
1839
1843
// OK because max value always fits in a u8, which in turn always
1840
1844
// fits in a usize, regardless of target.
1841
1845
usize:: try_from ( self . bits . count_ones ( ) ) . unwrap ( )
1842
1846
}
1843
1847
1844
1848
/// Returns true if and only if this set is empty.
1849
+ #[ inline]
1845
1850
pub fn is_empty ( & self ) -> bool {
1846
1851
self . len ( ) == 0
1847
1852
}
1848
1853
1849
1854
/// Insert the given look-around assertions into this set. If the assertion
1850
1855
/// is already in the set, then this is a no-op.
1856
+ #[ inline]
1851
1857
pub fn insert ( & mut self , look : Look ) {
1852
1858
self . bits |= 1 << look. as_repr ( ) ;
1853
1859
}
1854
1860
1855
1861
/// Remove the given look-around assertion from this set. If it wasn't
1856
1862
/// previously in the set, then this is a no-op.
1863
+ #[ inline]
1857
1864
pub fn remove ( & mut self , look : Look ) {
1858
1865
self . bits &= !( 1 << look. as_repr ( ) ) ;
1859
1866
}
1860
1867
1861
1868
/// Returns true if and only if the given look-around assertion is in this
1862
1869
/// set.
1870
+ #[ inline]
1863
1871
pub fn contains ( & self , look : Look ) -> bool {
1864
1872
self . bits & ( 1 << look. as_repr ( ) ) != 0
1865
1873
}
1866
1874
1875
+ /// Returns true if and only if this set contains any word boundary or
1876
+ /// negated word boundary assertions. This include both Unicode and ASCII
1877
+ /// word boundaries.
1878
+ #[ inline]
1879
+ pub fn contains_word ( & self ) -> bool {
1880
+ self . contains ( Look :: WordAscii )
1881
+ || self . contains ( Look :: WordAsciiNegate )
1882
+ || self . contains ( Look :: WordUnicode )
1883
+ || self . contains ( Look :: WordUnicodeNegate )
1884
+ }
1885
+
1867
1886
/// Modifies this set to be the union of itself and the set given.
1887
+ #[ inline]
1868
1888
pub fn union ( & mut self , other : LookSet ) {
1869
1889
self . bits |= other. bits ;
1870
1890
}
1871
1891
1872
1892
/// Modifies this set to be the intersection of itself and the set given.
1893
+ #[ inline]
1873
1894
pub fn intersect ( & mut self , other : LookSet ) {
1874
1895
self . bits &= other. bits ;
1875
1896
}
0 commit comments