DynString

Trait DynString 

Source
pub trait DynString:
    AsRef<str>
    + Capacity
    + Clear
    + Default
    + Deref<Target = str>
    + DerefMut
    + Extend<char, Error = Error>
    + Push<char, Error = Error>
    + for<'str> Push<&'str str, Error = Error>
    + Truncate<Input = usize>
    + WithCapacity<Input = usize>
    + Write { }
Expand description

Dynamic String

Any owned growing string-like structure that cl-aux knows should implement this trait.

fn stuff<S>(s: &mut S)
where
    S: cl_aux::DynString
{
    s.clear();
    s.push("World").unwrap();
    s.truncate(1);
}

let mut s = String::from("Hello");
stuff(&mut s);
assert_eq!(s, "W");

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> DynString for T
where T: AsRef<str> + Capacity + Clear + Default + Deref<Target = str> + DerefMut + Extend<char, Error = Error> + Push<char, Error = Error> + for<'str> Push<&'str str, Error = Error> + Truncate<Input = usize> + WithCapacity<Input = usize> + Write,