Struct str_stack::StrStack [−][src]
Implementations
impl StrStack
[src]
pub fn new() -> StrStack
[src]
Create a new StrStack.
pub fn with_capacity(bytes: usize, strings: usize) -> StrStack
[src]
Create a new StrStack with the given capacity.
You will be able to push bytes
bytes and create strings
strings before reallocating.
pub fn push(&mut self, s: &str) -> usize
[src]
Push a string onto the string stack.
This returns the index of the string on the stack.
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
Iterate over the strings on the stack.
pub fn pop(&mut self) -> bool
[src]
Remove the top string from the stack.
Returns true iff a string was removed.
pub fn clear(&mut self)
[src]
Clear the stack.
pub fn len(&self) -> usize
[src]
Returns the number of strings on the stack.
pub fn truncate(&mut self, len: usize)
[src]
Truncate the stack to len
strings.
pub fn consume<R: Read>(&mut self, source: R) -> Result<usize>
[src]
Read from source
into the string stack.
Returns the index of the new string or an IO Error.
pub fn writer(&mut self) -> Writer<'_>
[src]
Returns a writer helper for this string stack.
This is useful for building a string in-place on the string-stack.
Example:
use std::fmt::Write; use str_stack::StrStack; let mut s = StrStack::new(); let index = { let mut writer = s.writer(); writer.write_str("Hello"); writer.write_char(' '); writer.write_str("World"); writer.write_char('!'); writer.finish() }; assert_eq!(&s[index], "Hello World!");
pub fn write_fmt(&mut self, args: Arguments<'_>) -> usize
[src]
Allows calling the write! macro directly on the string stack:
Example:
use std::fmt::Write; use str_stack::StrStack; let mut s = StrStack::new(); let index = write!(&mut s, "Hello {}!", "World"); assert_eq!(&s[index], "Hello World!");
pub unsafe fn get_unchecked(&self, index: usize) -> &str
[src]
Trait Implementations
impl Clone for StrStack
[src]
impl Debug for StrStack
[src]
impl Default for StrStack
[src]
impl<S> Extend<S> for StrStack where
S: AsRef<str>,
[src]
S: AsRef<str>,
fn extend<T>(&mut self, iterator: T) where
T: IntoIterator<Item = S>,
[src]
T: IntoIterator<Item = S>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<S> FromIterator<S> for StrStack where
S: AsRef<str>,
[src]
S: AsRef<str>,
fn from_iter<T>(iterator: T) -> Self where
T: IntoIterator<Item = S>,
[src]
T: IntoIterator<Item = S>,
impl Index<usize> for StrStack
[src]
impl<'a> IntoIterator for &'a StrStack
[src]
Auto Trait Implementations
impl RefUnwindSafe for StrStack
impl Send for StrStack
impl Sync for StrStack
impl Unpin for StrStack
impl UnwindSafe for StrStack
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,