[][src]Struct sixtyfps_corelib::string::SharedString

#[repr(C)]pub struct SharedString { /* fields omitted */ }

A string type used by the SixtyFPS run-time.

SharedString uses implicit data sharing to make it efficient to pass around copies. When cloning, a reference to the data is cloned, not the data itself. The data itself is only copied when modifying it, for example using push_str. This is also called copy-on-write.

Under the hood the string data is UTF-8 encoded and it is always terminated with a null character.

Implementations

impl SharedString[src]

pub fn len(&self) -> usize[src]

Size of the string, in bytes. This excludes the terminating null character.

pub fn as_str(&self) -> &str[src]

Return a slice to the string

pub fn push_str(&mut self, x: &str)[src]

Append a string to this string

let mut hello = SharedString::from("Hello");
hello.push_str(", ");
hello.push_str("World");
hello.push_str("!");
assert_eq!(hello, "Hello, World!");

Trait Implementations

impl<'_> Add<&'_ str> for SharedString[src]

type Output = SharedString

The resulting type after applying the + operator.

impl<'_> AddAssign<&'_ str> for SharedString[src]

impl AsRef<[u8]> for SharedString[src]

impl AsRef<CStr> for SharedString[src]

impl AsRef<str> for SharedString[src]

impl Clone for SharedString[src]

impl Debug for SharedString[src]

impl Default for SharedString[src]

impl Deref for SharedString[src]

type Target = str

The resulting type after dereferencing.

impl Display for SharedString[src]

impl Eq for SharedString[src]

impl<'_> From<&'_ String> for SharedString[src]

impl<'_> From<&'_ str> for SharedString[src]

impl From<String> for SharedString[src]

impl Hash for SharedString[src]

impl Into<String> for SharedString[src]

impl Ord for SharedString[src]

impl<T: ?Sized> PartialEq<T> for SharedString where
    T: AsRef<str>, 
[src]

impl<T: ?Sized> PartialOrd<T> for SharedString where
    T: AsRef<str>, 
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.