Lines Matching defs:string

469     // ensure our operation produces an exact-size string before we benchmark it
1292 mod string;
3554 let string = "ประเทศไทย中华Việt Nam";
3555 let mut data = String::from(string);
3556 data.push_str(string);
3574 let string = "Việt Namacbaabcaabaaba";
3575 for (i, ci) in string.char_indices() {
3577 for j in string[ip..].char_indices().map(|(i, _)| i).chain(Some(string.len() - ip)) {
3578 let pat = &string[i..ip + j];
3579 assert!(match string.find(pat) {
3583 assert!(match string.rfind(pat) {
3596 ($expected: expr, $string: expr) => {{
3597 let s: String = $string.concat();
3618 ($expected: expr, $string: expr, $delim: expr) => {{
3619 let s = $string.join($delim);
4206 // check the panic includes the prefix of the sliced string
4550 // itself appears in the debug string).
5191 let string = String::from("Some text goes here");
5192 assert_eq!(string.clone().into_boxed_str().into_string(), string);
5645 let owned: Option<std::string::String> = "string".parse().ok();
5646 assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
5651 assert_eq!(String::from(Cow::Borrowed("string")), "string");
5652 assert_eq!(String::from(Cow::Owned(String::from("string"))), "string");
6496 let string = "hello";
6497 test_from_cow!(string: &str);
6502 let string = CStr::from_bytes_with_nul(b"hello\0").unwrap();
6503 test_from_cow!(string: &CStr);
6508 let string = OsStr::new("hello");
6509 test_from_cow!(string: &OsStr);
8885 mod string;
13949 /// The first argument `format!` receives is a format string. This must be a string
13950 /// literal. The power of the formatting string is in the `{}`s contained.
13953 /// formatting string in the order given unless named or positional parameters
13958 /// depending on the intended destination of the string.
13960 /// To convert a single value to a string, use the [`to_string`] method. This
13966 /// [`to_string`]: crate::string::ToString
14970 //! Unicode string slices.
14974 //! The `&str` type is one of the two main string types, the other being `String`.
14979 //! A basic string declaration of `&str` type:
14985 //! Here we have declared a string literal, also known as a string slice.
14986 //! String literals have a static lifetime, which means the string `hello_world`
15009 use crate::string::String;
15192 /// Methods for string slices.
15203 /// let s = "this is a string";
15214 /// Replaces all matches of a pattern with another string.
15216 /// `replace` creates a new [`String`], and copies the data from this string slice into it.
15218 /// replaces them with the replacement string slice.
15236 #[must_use = "this returns the replaced string as a new allocation, \
15252 /// Replaces first N matches of a pattern with another string.
15254 /// `replacen` creates a new [`String`], and copies the data from this string slice into it.
15256 /// replaces them with the replacement string slice at most `count` times.
15275 #[must_use = "this returns the replaced string as a new allocation, \
15291 /// Returns the lowercase equivalent of this string slice, as a new [`String`].
15376 /// Returns the uppercase equivalent of this string slice, as a new [`String`].
15436 /// let string = String::from("birthday gift");
15437 /// let boxed_str = string.clone().into_boxed_str();
15439 /// assert_eq!(boxed_str.into_string(), string);
15448 /// Creates a new [`String`] by repeating a string `n` times.
15473 /// Returns a copy of this string where each character is mapped to its
15503 /// Returns a copy of this string where each character is mapped to its
15534 /// Converts a boxed slice of bytes to a boxed string slice without checking
15535 /// that the string contains valid UTF-8.
15675 use std::string::ToString;
15715 use std::string::ToString;
15999 use std::string::{String, ToString};
16029 use std::string::String;
16048 use std::string::ToString;
16172 //! A UTF-8–encoded, growable string.
16180 //! There are multiple ways to create a new [`String`] from a string literal:
16232 /// A UTF-8–encoded, growable string.
16234 /// The `String` type is the most common string type that has ownership over the
16235 /// contents of the string. It has a close relationship with its borrowed
16240 /// You can create a `String` from [a literal string][`str`] with [`String::from`]:
16279 /// which is that if you need a non-UTF-8 string, consider [`OsString`]. It is
16320 /// conversion, known as [`Deref`] coercion. In the following example a string
16340 /// to explicitly extract the string slice containing the string. The second
16414 /// string, it increases its capacity appropriately. If we instead use the
16574 /// // ...but this may make the string reallocate
16597 /// A string ([`String`]) is made of bytes ([`u8`]), and a vector of bytes
16660 /// Converts a slice of bytes to a string, including invalid characters.
16681 /// change the size of the string, and hence, require a `String`. But if
16809 /// the string (in bytes), and the allocated capacity of the data
16889 /// string contains valid UTF-8.
16942 /// Extracts a string slice containing the entire `String`.
16959 /// Converts a `String` into a mutable string slice.
16979 /// Appends a given string slice onto the end of this `String`.
16994 pub fn push_str(&mut self, string: &str) {
16995 self.vec.extend_from_slice(string.as_bytes())
17280 /// If `new_len` is greater than the string's current length, this has no
17284 /// of the string
17310 /// Removes the last character from the string buffer and returns it.
17364 None => panic!("cannot remove a char from the end of a string"),
17550 /// Inserts a string slice into this `String` at a byte position.
17573 pub fn insert_str(&mut self, idx: usize, string: &str) {
17577 self.insert_bytes(idx, string.as_bytes());
17613 /// length of the string.
17653 /// Splits the string into two at the given byte index.
17664 /// code point of the string.
17728 /// // Remove the range up until the β from the string
17733 /// // A full range clears the string
17758 Drain { start, end, iter: chars_iter, string: self_ptr }
17761 /// Removes the specified range in the string,
17762 /// and replaces it with the given string.
17763 /// The given string doesn't need to be the same length as the range.
17778 /// // Replace the range up until the β from the string
17966 // one allocation by getting the first string from the iterator
18216 /// every operation, which would lead to *O*(*n*^2) running time when building an *n*-byte string by
18219 /// The string on the right-hand side is only borrowed; its contents are copied into the returned
18589 /// Converts a string slice into a Borrowed variant.
18590 /// No heap allocation is performed, and the string
18608 /// No heap allocation is performed, and the string
18628 /// No heap allocation is performed, and the string
18681 fn from(string: String) -> Vec<u8> {
18682 string.into_bytes()
18710 string: *mut String,
18737 let self_vec = (*self.string).as_mut_vec();
18746 /// Returns the remaining (sub)string of this iterator as a slice.
18828 use crate::string::String;
19482 pub mod string;
19765 use crate::string::String;
20667 /// if let Ok(string) = value.downcast::<String>() {
20668 /// println!("String ({}): {}", string.len(), string);
21235 /// Allocate a reference-counted string slice and copy `v` into it.
21253 /// Allocate a reference-counted string slice and copy `v` into it.
23301 use crate::string::String;
24858 /// if let Ok(string) = value.downcast::<String>() {
24859 /// println!("String ({}): {}", string.len(), string);
25828 //! From these, you can see that the first argument is a format string. It is
25829 //! required by the compiler for this to be a string literal; it cannot be a
25831 //! will then parse the format string and determine if the list of arguments
25832 //! provided is suitable to pass to this format string.
25834 //! To convert a single value to a string, use the [`to_string`] method. This
25841 //! example, the format string `{} {} {}` would take three parameters, and they
25842 //! would be formatted in the same order as they're given. The format string
25860 //! A format string is required to use all of its arguments, otherwise it is a
25862 //! format string.
25885 //! valid to provide named parameters that are unused by the format string.
25891 //! parameters affect the string representation of what's being formatted.
25904 //! If the value's string does not fill up this many characters, then the
25943 //! padding is applied is to format your input, then pad this resulting string
25986 //! For non-numeric types, this can be considered a "maximum width". If the resulting string is
26009 //! in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part refers
26055 //! In some programming languages, the behavior of string formatting functions
26070 //! The literal characters `{` and `}` may be included in a string by preceding
26156 //! the function signature might suggest, string formatting is an infallible
26194 //! let string = format!("{:.*}", decimals, magnitude);
26195 //! f.pad_integral(true, "", &string)
26213 //! represented as a UTF-8 string at all times. It is **not** expected that
26237 //! print! // the format string is printed to the standard output
26239 //! eprint! // the format string is printed to the standard error
26246 //! This and [`writeln!`] are two macros which are used to emit the format string
26278 //! an opaque object describing the format string. This object
26300 //! inside this module in order to process the format string.
26314 //! [`to_string`]: crate::string::ToString
26349 use crate::string;
26352 /// formatted string.
26378 pub fn format(args: Arguments<'_>) -> string::String {
26380 let mut output = string::String::with_capacity(capacity);
26557 use std::string::ToString;
26597 use std::string::ToString;
26773 use std::string::{String, ToString};
26803 use std::string::String;
26822 use std::string::ToString;
35566 use crate::string::{String, ToString};
39633 use crate::string::String;
47168 /// [`String`]: crate::string::String
47283 /// [`String`]: crate::string::String
47421 /// [`String`]: crate::string::String
49644 /// Allocate a `Vec<u8>` and fill it with a UTF-8 string.
50138 pub use crate::string::{String, ToString};
51517 /// if let Ok(string) = value.downcast::<String>() {
51518 /// println!("String ({}): {}", string.len(), string);
51549 /// if let Ok(string) = value.downcast::<String>() {
51550 /// println!("String ({}): {}", string.len(), string);
51581 /// if let Ok(string) = value.downcast::<String>() {
51582 /// println!("String ({}): {}", string.len(), string);