Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String
Converts a vector of bytes to a String without checking that the string contains valid UTF-8.
associated_function alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn insert(&mut self, idx: usize, ch: char)
Inserts a character into this String at byte position idx.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn insert_str(&mut self, idx: usize, string: &str)
Inserts a string slice into this String at byte position idx.
method alloc Stable since 1.16.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_boxed_str(self) -> Box<str>
Converts this String into a Box<strstr>.
method alloc Stable since 1.4.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn into_bytes(self) -> Vec<u8>
Converts a String into a byte vector.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_raw_parts(self) -> (*mut u8, usize, usize)
Decomposes a String into its raw components: (pointer, length, capacity).
method alloc Stable since 1.93.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_empty(&self) -> bool
Returns true if this String has a length of zero, and false otherwise.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn leak<'a>(self) -> &'a mut str
Consumes and leaks the String, returning a mutable reference to the contents, &'a mut str.
method alloc Stable since 1.72.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn len(&self) -> usize
Returns the length of this String, in bytes, not chars or graphemes. In other words, it might not be what a human considers the length of the string.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> String
Creates a new empty String.
associated_function alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn pop(&mut self) -> Option<char>
Removes the last character from the string buffer and returns it.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn push(&mut self, ch: char)
Appends the given char to the end of this String.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn push_str(&mut self, string: &str)
Appends a given string slice onto the end of this String.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn remove(&mut self, idx: usize) -> char
Removes a char from this String at byte position idx and returns it.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
Removes the specified range in the string, and replaces it with the given string. The given string doesn't need to be the same length as the range.
method alloc Stable since 1.27.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional bytes more than the current length. The allocator may reserve more space to speculatively avoid frequent allocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional bytes more than the current length. Unlike reserve, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn retain<F>(&mut self, f: F)
Retains only the characters specified by the predicate.
method alloc Stable since 1.26.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of this String with a lower bound.
method alloc Stable since 1.56.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of this String to match its length.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
"I'm trying to round up to next power of two (for fun). I know that's perhaps not a lot of fun, but there's [next_power_of_two() ](https://doc.rust-lan..."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.