Lines Matching +full:method +full:- +full:complexity
25 /// A short-hand constructor for building a `&[u8]`.
71 pub fn B<'a, B: ?Sized + AsRef<[u8]>>(bytes: &'a B) -> &'a [u8] { in B()
77 fn as_bytes(&self) -> &[u8] { in as_bytes()
82 fn as_bytes_mut(&mut self) -> &mut [u8] { in as_bytes_mut()
94 /// A method for accessing the raw bytes of this type. This is always a
95 /// no-op and callers shouldn't care about it. This only exists for making
98 fn as_bytes(&self) -> &[u8]; in as_bytes()
100 /// A method for accessing the raw bytes of this type, mutably. This is
101 /// always a no-op and callers shouldn't care about it. This only exists
104 fn as_bytes_mut(&mut self) -> &mut [u8]; in as_bytes_mut()
111 /// shows its bytes as a normal string. For invalid UTF-8, hex escape
124 fn as_bstr(&self) -> &BStr { in as_bstr()
133 /// shows its bytes as a normal string. For invalid UTF-8, hex escape
147 fn as_bstr_mut(&mut self) -> &mut BStr { in as_bstr_mut()
153 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
154 /// this returns `None` if the given OS string is not valid UTF-8. (For
156 /// arbitrary 16-bit integers. Not all such sequences can be transcoded to
157 /// valid UTF-8.)
169 /// let bs = <[u8]>::from_os_str(os_str).expect("should be valid UTF-8");
174 fn from_os_str(os_str: &OsStr) -> Option<&[u8]> { in from_os_str()
177 fn imp(os_str: &OsStr) -> Option<&[u8]> { in from_os_str()
185 fn imp(os_str: &OsStr) -> Option<&[u8]> { in from_os_str()
194 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
195 /// this returns `None` if the given path is not valid UTF-8. (For example,
196 /// on Windows, file paths are allowed to be a sequence of arbitrary 16-bit
197 /// integers. Not all such sequences can be transcoded to valid UTF-8.)
209 /// let bs = <[u8]>::from_path(path).expect("should be valid UTF-8");
214 fn from_path(path: &Path) -> Option<&[u8]> { in from_path()
218 /// Safely convert this byte string into a `&str` if it's valid UTF-8.
220 /// If this byte string is not valid UTF-8, then an error is returned. The
225 /// of the [`to_str_lossy`](trait.ByteSlice.html#method.to_str_lossy) or
226 /// [`to_str_lossy_into`](trait.ByteSlice.html#method.to_str_lossy_into)
236 /// # fn example() -> Result<(), bstr::Utf8Error> {
247 fn to_str(&self) -> Result<&str, Utf8Error> { in to_str()
256 /// valid UTF-8.
260 /// Callers *must* ensure that this byte string is valid UTF-8 before
261 /// calling this method. Converting a byte string into a `&str` that is
262 /// not valid UTF-8 is considered undefined behavior.
265 /// UTF-8 validity of the byte string is already known and it is
266 /// undesirable to pay the cost of an additional UTF-8 validation check
267 /// that [`to_str`](trait.ByteSlice.html#method.to_str) performs.
277 /// // valid UTF-8 by the Rust compiler.
282 unsafe fn to_str_unchecked(&self) -> &str { in to_str_unchecked()
286 /// Convert this byte string to a valid UTF-8 string by replacing invalid
287 /// UTF-8 bytes with the Unicode replacement codepoint (`U+FFFD`).
289 /// If the byte string is already valid UTF-8, then no copying or
291 /// the byte string is not valid UTF-8, then an owned string buffer is
294 /// This method uses the "substitution of maximal subparts" (Unicode
298 /// If there were previous bytes that represented a prefix of a well-formed
305 /// [Public Review Issue #121](http://www.unicode.org/review/pr-121.html).
333 /// // \xF1\x80\x80 is a valid 3-byte code unit prefix.
334 /// // \xE1\x80 is a valid 2-byte code unit prefix.
335 /// // \xC2 is a valid 1-byte code unit prefix.
347 fn to_str_lossy(&self) -> Cow<str> { in to_str_lossy()
361 // that all of `valid` is valid UTF-8. in to_str_lossy()
373 /// buffer, while replacing invalid UTF-8 code unit sequences with the
376 /// This method uses the same "substitution of maximal subparts" strategy
378 /// [`to_str_lossy`](trait.ByteSlice.html#method.to_str_lossy) method.
383 /// valid UTF-8.
411 // that all of `bytes` is valid UTF-8. in to_str_lossy_into()
418 // that all of `valid` is valid UTF-8. in to_str_lossy_into()
432 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
433 /// this returns a UTF-8 decoding error if this byte string is not valid
434 /// UTF-8. (For example, on Windows, file paths are allowed to be a
435 /// sequence of arbitrary 16-bit integers. There is no obvious mapping from
436 /// an arbitrary sequence of 8-bit integers to an arbitrary sequence of
437 /// 16-bit integers.)
446 /// let os_str = b"foo".to_os_str().expect("should be valid UTF-8");
451 fn to_os_str(&self) -> Result<&OsStr, Utf8Error> { in to_os_str()
454 fn imp(bytes: &[u8]) -> Result<&OsStr, Utf8Error> { in to_os_str()
462 fn imp(bytes: &[u8]) -> Result<&OsStr, Utf8Error> { in to_os_str()
471 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
472 /// this will perform a UTF-8 check and lossily convert this byte string
473 /// into valid UTF-8 using the Unicode replacement codepoint.
476 /// non-Unix systems such as Windows, where file paths are an arbitrary
477 /// sequence of 16-bit integers.
491 fn to_os_str_lossy(&self) -> Cow<OsStr> { in to_os_str_lossy()
494 fn imp(bytes: &[u8]) -> Cow<OsStr> { in to_os_str_lossy()
502 fn imp(bytes: &[u8]) -> Cow<OsStr> { in to_os_str_lossy()
516 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
517 /// this returns a UTF-8 decoding error if this byte string is not valid
518 /// UTF-8. (For example, on Windows, file paths are allowed to be a
519 /// sequence of arbitrary 16-bit integers. There is no obvious mapping from
520 /// an arbitrary sequence of 8-bit integers to an arbitrary sequence of
521 /// 16-bit integers.)
530 /// let path = b"foo".to_path().expect("should be valid UTF-8");
535 fn to_path(&self) -> Result<&Path, Utf8Error> { in to_path()
541 /// On Unix, this always succeeds and is zero cost. On non-Unix systems,
542 /// this will perform a UTF-8 check and lossily convert this byte string
543 /// into valid UTF-8 using the Unicode replacement codepoint.
546 /// non-Unix systems such as Windows, where file paths are an arbitrary
547 /// sequence of 16-bit integers.
562 fn to_path_lossy(&self) -> Cow<Path> { in to_path_lossy()
590 fn repeatn(&self, n: usize) -> Vec<u8> { in repeatn()
613 fn contains_str<B: AsRef<[u8]>>(&self, needle: B) -> bool { in contains_str()
631 fn starts_with_str<B: AsRef<[u8]>>(&self, prefix: B) -> bool { in starts_with_str()
649 fn ends_with_str<B: AsRef<[u8]>>(&self, suffix: B) -> bool { in ends_with_str()
662 /// # Complexity
664 /// This routine is guaranteed to have worst case linear time complexity
669 /// complexity.
684 fn find<B: AsRef<[u8]>>(&self, needle: B) -> Option<usize> { in find()
698 /// # Complexity
700 /// This routine is guaranteed to have worst case linear time complexity
705 /// complexity.
721 fn rfind<B: AsRef<[u8]>>(&self, needle: B) -> Option<usize> { in rfind()
725 /// Returns an iterator of the non-overlapping occurrences of the given
729 /// # Complexity
731 /// This routine is guaranteed to have worst case linear time complexity
736 /// complexity.
766 ) -> Find<'a> { in find_iter()
770 /// Returns an iterator of the non-overlapping occurrences of the given
774 /// # Complexity
776 /// This routine is guaranteed to have worst case linear time complexity
781 /// complexity.
811 ) -> FindReverse<'a> { in rfind_iter()
829 fn find_byte(&self, byte: u8) -> Option<usize> { in find_byte()
847 fn rfind_byte(&self, byte: u8) -> Option<usize> { in rfind_byte()
857 /// UTF-8 sequences will not be matched.
871 fn find_char(&self, ch: char) -> Option<usize> { in find_char()
881 /// UTF-8 sequences will not be matched.
895 fn rfind_char(&self, ch: char) -> Option<usize> { in rfind_char()
911 /// # Complexity
913 /// This routine is guaranteed to have worst case linear time complexity
918 /// complexity.
932 fn find_byteset<B: AsRef<[u8]>>(&self, byteset: B) -> Option<usize> { in find_byteset()
948 /// # Complexity
950 /// This routine is guaranteed to have worst case linear time complexity
955 /// complexity.
969 fn find_not_byteset<B: AsRef<[u8]>>(&self, byteset: B) -> Option<usize> { in find_not_byteset()
985 /// # Complexity
987 /// This routine is guaranteed to have worst case linear time complexity
992 /// complexity.
1006 fn rfind_byteset<B: AsRef<[u8]>>(&self, byteset: B) -> Option<usize> { in rfind_byteset()
1022 /// # Complexity
1024 /// This routine is guaranteed to have worst case linear time complexity
1029 /// complexity.
1043 fn rfind_not_byteset<B: AsRef<[u8]>>(&self, byteset: B) -> Option<usize> { in rfind_not_byteset()
1070 fn fields(&self) -> Fields { in fields()
1077 /// If this byte string is not valid UTF-8, then the given closure will
1078 /// be called with a Unicode replacement codepoint when invalid UTF-8
1102 fn fields_with<F: FnMut(char) -> bool>(&self, f: F) -> FieldsWith<F> { in fields_with()
1172 /// // Splitting by an empty string is not UTF-8 aware. Elements yielded
1173 /// // may not be valid UTF-8!
1193 /// [`fields`](#method.fields) instead.
1198 ) -> Split<'a> { in split_str()
1269 /// // Splitting by an empty string is not UTF-8 aware. Elements yielded
1270 /// // may not be valid UTF-8!
1292 ) -> SplitReverse<'a> { in rsplit_str()
1336 ) -> SplitN<'a> { in splitn_str()
1382 ) -> SplitNReverse<'a> { in rsplitn_str()
1390 /// allocation, use [`replace_into`](#method.replace_into) instead.
1426 ) -> Vec<u8> { in replace()
1436 /// allocation, use [`replacen_into`](#method.replacen_into) instead.
1473 ) -> Vec<u8> { in replacen()
1485 /// API, use [`replace`](#method.replace) instead.
1549 /// API, use [`replacen`](#method.replacen) instead.
1622 fn bytes(&self) -> Bytes { in bytes()
1627 /// If invalid UTF-8 is encountered, then the Unicode replacement codepoint
1652 fn chars(&self) -> Chars { in chars()
1658 /// UTF-8 is encountered, then the Unicode replacement codepoint is yielded
1663 /// invalid UTF-8, this iterator provides both the corresponding starting
1665 /// is necessary to slice the original byte string when invalid UTF-8 bytes
1707 fn char_indices(&self) -> CharIndices { in char_indices()
1711 /// Iterate over chunks of valid UTF-8.
1713 /// The iterator returned yields chunks of valid UTF-8 separated by invalid
1714 /// UTF-8 bytes, if they exist. Invalid UTF-8 bytes are always 1-3 bytes,
1717 /// [`ByteSlice::to_str_lossy`](trait.ByteSlice.html#method.to_str_lossy)
1718 /// method.
1744 fn utf8_chunks(&self) -> Utf8Chunks { in utf8_chunks()
1749 /// If invalid UTF-8 is encountered, then the Unicode replacement codepoint
1776 fn graphemes(&self) -> Graphemes { in graphemes()
1782 /// UTF-8 is encountered, then the Unicode replacement codepoint is yielded
1799 /// This example shows what happens when invalid UTF-8 is enountered. Note
1820 fn grapheme_indices(&self) -> GraphemeIndices { in grapheme_indices()
1825 /// UTF-8 is encountered, then the Unicode replacement codepoint is yielded
1829 /// [`words_with_breaks`](trait.ByteSlice.html#method.words_with_breaks),
1837 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
1838 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
1856 fn words(&self) -> Words { in words()
1864 /// [`words_with_break_indices`](trait.ByteSlice.html#method.words_with_break_indices),
1872 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
1873 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
1894 fn word_indices(&self) -> WordIndices { in word_indices()
1901 /// codepoint substitutions if invalid UTF-8 is encountered).
1904 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
1905 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
1924 fn words_with_breaks(&self) -> WordsWithBreaks { in words_with_breaks()
1931 /// (modulo Unicode replacement codepoint substitutions if invalid UTF-8 is
1935 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
1936 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
1961 fn words_with_break_indices(&self) -> WordsWithBreakIndices { in words_with_break_indices()
1970 /// substitutions if invalid UTF-8 is encountered).
1973 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
1974 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
1993 fn sentences(&self) -> Sentences { in sentences()
2003 /// substitutions if invalid UTF-8 is encountered).
2006 /// yields `&str` elements. When invalid UTF-8 is encountered, replacement
2007 /// codepoints are [substituted](index.html#handling-of-invalid-utf-8).
2027 fn sentence_indices(&self) -> SentenceIndices { in sentence_indices()
2058 fn lines(&self) -> Lines { in lines()
2102 fn lines_with_terminator(&self) -> LinesWithTerminator { in lines_with_terminator()
2124 fn trim(&self) -> &[u8] { in trim()
2145 fn trim_start(&self) -> &[u8] { in trim_start()
2167 fn trim_end(&self) -> &[u8] { in trim_end()
2186 fn trim_with<F: FnMut(char) -> bool>(&self, mut trim: F) -> &[u8] { in trim_with()
2204 fn trim_start_with<F: FnMut(char) -> bool>(&self, mut trim: F) -> &[u8] { in trim_start_with()
2227 fn trim_end_with<F: FnMut(char) -> bool>(&self, mut trim: F) -> &[u8] { in trim_end_with()
2242 /// If invalid UTF-8 is seen, or if a character has no lowercase variant,
2251 /// [`to_lowercase_into`](#method.to_lowercase_into) instead.
2273 /// Invalid UTF-8 remains as is:
2283 fn to_lowercase(&self) -> Vec<u8> { in to_lowercase()
2295 /// If invalid UTF-8 is seen, or if a character has no lowercase variant,
2304 /// convenience, then use [`to_lowercase`](#method.to_lowercase) instead.
2332 /// Invalid UTF-8 remains as is:
2371 /// letters `A-Z` are converted to `a-z`. All other bytes remain unchanged.
2376 /// [`make_ascii_lowercase`](#method.make_ascii_lowercase) to perform
2390 /// Invalid UTF-8 remains as is:
2400 fn to_ascii_lowercase(&self) -> Vec<u8> { in to_ascii_lowercase()
2407 /// letters `A-Z` are converted to `a-z`. All other bytes remain unchanged.
2411 /// [`to_ascii_lowercase`](#method.to_ascii_lowercase) instead.
2425 /// Invalid UTF-8 remains as is:
2445 /// If invalid UTF-8 is seen, or if a character has no uppercase variant,
2454 /// [`to_uppercase_into`](#method.to_uppercase_into) instead.
2476 /// Invalid UTF-8 remains as is:
2486 fn to_uppercase(&self) -> Vec<u8> { in to_uppercase()
2498 /// If invalid UTF-8 is seen, or if a character has no uppercase variant,
2507 /// convenience, then use [`to_uppercase`](#method.to_uppercase) instead.
2535 /// Invalid UTF-8 remains as is:
2571 /// letters `a-z` are converted to `A-Z`. All other bytes remain unchanged.
2576 /// [`make_ascii_uppercase`](#method.make_ascii_uppercase) to perform
2590 /// Invalid UTF-8 remains as is:
2600 fn to_ascii_uppercase(&self) -> Vec<u8> { in to_ascii_uppercase()
2607 /// letters `a-z` are converted to `A-Z`. All other bytes remain unchanged.
2611 /// [`to_ascii_uppercase`](#method.to_ascii_uppercase) instead.
2625 /// Invalid UTF-8 remains as is:
2642 /// byte string contains valid UTF-8 that isn't ASCII, then reversing the
2643 /// string will likely result in invalid UTF-8 and otherwise non-sensical
2646 /// Note that this is equivalent to the generic `[u8]::reverse` method.
2647 /// This method is provided to permit callers to explicitly differentiate
2668 /// If this byte string is valid UTF-8, then its reversal by codepoint
2669 /// is also guaranteed to be valid UTF-8.
2689 /// [`reverse_graphemes`](#method.reverse_graphemes) instead.
2750 /// If this byte string is valid UTF-8, then its reversal by grapheme
2751 /// is also guaranteed to be valid UTF-8.
2826 fn is_ascii(&self) -> bool { in is_ascii()
2830 /// Returns true if and only if the entire byte string is valid UTF-8.
2833 /// invalid UTF-8 byte is, then use the [`to_str`](#method.to_str) method.
2854 fn is_utf8(&self) -> bool { in is_utf8()
2858 /// Returns the last byte in this byte string, if it's non-empty. If this
2875 fn last_byte(&self) -> Option<u8> { in last_byte()
2880 /// Returns the index of the first non-ASCII byte in this byte string (if
2896 fn find_non_ascii_byte(&self) -> Option<usize> { in find_non_ascii_byte()
2952 let count = src_end - src_start; in copy_within_str()
2954 dest <= self.as_bytes().len() - count, in copy_within_str()
2977 /// concern when it's necessary to re-use the same needle to search multiple
2979 /// [`ByteSlice::find`](trait.ByteSlice.html#method.find)
2981 /// [`ByteSlice::find_iter`](trait.ByteSlice.html#method.find_iter)
2996 pub fn new<B: ?Sized + AsRef<[u8]>>(needle: &'a B) -> Finder<'a> { in new()
3003 /// If this is already an owned finder, then this is a no-op. Otherwise,
3009 pub fn into_owned(self) -> Finder<'static> { in into_owned()
3020 pub fn needle(&self) -> &[u8] { in needle()
3030 /// # Complexity
3032 /// This routine is guaranteed to have worst case linear time complexity
3037 /// complexity.
3052 pub fn find<B: AsRef<[u8]>>(&self, haystack: B) -> Option<usize> { in find()
3062 /// concern when it's necessary to re-use the same needle to search multiple
3064 /// [`ByteSlice::rfind`](trait.ByteSlice.html#method.rfind)
3066 /// [`ByteSlice::rfind_iter`](trait.ByteSlice.html#method.rfind_iter)
3081 pub fn new<B: ?Sized + AsRef<[u8]>>(needle: &'a B) -> FinderReverse<'a> { in new()
3088 /// If this is already an owned finder, then this is a no-op. Otherwise,
3094 pub fn into_owned(self) -> FinderReverse<'static> { in into_owned()
3105 pub fn needle(&self) -> &[u8] { in needle()
3115 /// # Complexity
3117 /// This routine is guaranteed to have worst case linear time complexity
3122 /// complexity.
3137 pub fn rfind<B: AsRef<[u8]>>(&self, haystack: B) -> Option<usize> { in rfind()
3142 /// An iterator over non-overlapping substring matches.
3157 fn new(haystack: &'a [u8], needle: &'a [u8]) -> Find<'a> { in new()
3168 fn next(&mut self) -> Option<usize> { in next()
3186 /// An iterator over non-overlapping substring matches in reverse.
3203 fn new(haystack: &'a [u8], needle: &'a [u8]) -> FindReverse<'a> { in new()
3210 fn haystack(&self) -> &'a [u8] { in haystack()
3214 fn needle(&self) -> &[u8] { in needle()
3223 fn next(&mut self) -> Option<usize> { in next()
3258 pub fn as_slice(&self) -> &'a [u8] { in as_slice()
3267 fn next(&mut self) -> Option<u8> { in next()
3272 fn size_hint(&self) -> (usize, Option<usize>) { in size_hint()
3279 fn next_back(&mut self) -> Option<u8> { in next_back()
3286 fn len(&self) -> usize { in len()
3301 it: FieldsWith<'a, fn(char) -> bool>,
3305 fn new(bytes: &'a [u8]) -> Fields<'a> { in new()
3314 fn next(&mut self) -> Option<&'a [u8]> { in next()
3327 /// of the predicate, i.e., `FnMut(char) -> bool`.
3335 impl<'a, F: FnMut(char) -> bool> FieldsWith<'a, F> {
3336 fn new(bytes: &'a [u8], f: F) -> FieldsWith<'a, F> { in new()
3341 impl<'a, F: FnMut(char) -> bool> Iterator for FieldsWith<'a, F> {
3345 fn next(&mut self) -> Option<&'a [u8]> { in next()
3386 fn new(haystack: &'a [u8], splitter: &'a [u8]) -> Split<'a> { in new()
3396 fn next(&mut self) -> Option<&'a [u8]> { in next()
3427 /// of the predicate, i.e., `FnMut(char) -> bool`.
3442 fn new(haystack: &'a [u8], splitter: &'a [u8]) -> SplitReverse<'a> { in new()
3452 fn next(&mut self) -> Option<&'a [u8]> { in next()
3484 /// of the predicate, i.e., `FnMut(char) -> bool`.
3497 ) -> SplitN<'a> { in new()
3507 fn next(&mut self) -> Option<&'a [u8]> { in next()
3523 /// of the predicate, i.e., `FnMut(char) -> bool`.
3536 ) -> SplitNReverse<'a> { in new()
3546 fn next(&mut self) -> Option<&'a [u8]> { in next()
3569 fn new(bytes: &'a [u8]) -> Lines<'a> { in new()
3578 fn next(&mut self) -> Option<&'a [u8]> { in next()
3581 line = &line[..line.len() - 1]; in next()
3583 line = &line[..line.len() - 1]; in next()
3608 fn new(bytes: &'a [u8]) -> LinesWithTerminator<'a> { in new()
3617 fn next(&mut self) -> Option<&'a [u8]> { in next()