Struct str_stack::StrStack
[−]
[src]
pub struct StrStack { /* fields omitted */ }
Methods
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.
ⓘImportant traits for Iter<'a>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]
fn clone(&self) -> StrStack
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for StrStack
[src]
impl Index<usize> for StrStack
[src]
type Output = str
The returned type after indexing.
fn index(&self, index: usize) -> &str
[src]
Performs the indexing (container[index]
) operation.
impl Debug for StrStack
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a> IntoIterator for &'a StrStack
[src]
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
type Item = &'a str
The type of the elements being iterated over.
ⓘImportant traits for Iter<'a>fn into_iter(self) -> Iter<'a>
[src]
Creates an iterator from a value. Read more
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>,
Extends a collection with the contents of an iterator. Read more
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>,
Creates a value from an iterator. Read more