Struct str_stack::StrStack
[−]
[src]
pub struct StrStack { /* fields omitted */ }
Methods
impl StrStack
[src]
fn new() -> StrStack
Create a new StrStack.
fn with_capacity(bytes: usize, strings: usize) -> StrStack
Create a new StrStack with the given capacity.
You will be able to push bytes
bytes and create strings
strings before reallocating.
fn push(&mut self, s: &str) -> usize
Push a string onto the string stack.
This returns the index of the string on the stack.
fn iter(&self) -> Iter
Iterate over the strings on the stack.
fn pop(&mut self) -> bool
Remove the top string from the stack.
Returns true iff a string was removed.
fn clear(&mut self)
Clear the stack.
fn len(&self) -> usize
Returns the number of strings on the stack.
fn is_empty(&self) -> bool
Returns true if there are no strings on the stack.
fn truncate(&mut self, len: usize)
Truncate the stack to len
strings.
fn consume<R: Read>(&mut self, source: R) -> Result<usize>
Read from source
into the string stack.
Returns the index of the new string or an IO Error.
fn writer(&mut self) -> Writer
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!");Run
fn write_fmt(&mut self, args: Arguments) -> usize
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!");Run
unsafe fn get_unchecked(&self, index: usize) -> &str
Trait Implementations
impl Clone for StrStack
[src]
fn clone(&self) -> StrStack
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
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
The method for the indexing (Foo[Bar]
) operation
impl Debug for StrStack
[src]
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.
fn into_iter(self) -> Iter<'a>
Creates an iterator from a value. Read more
impl<S> Extend<S> for StrStack where S: AsRef<str>
[src]
fn extend<T>(&mut self, iterator: T) where 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]
fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=S>
Creates a value from an iterator. Read more