Struct rhai::plugin::ImmutableString[][src]

pub struct ImmutableString(_);
Expand description

The system immutable string type.

An ImmutableString wraps an Rc<String> (or Arc<String> under the sync feature) so that it can be simply shared and not cloned.

Example

use rhai::ImmutableString;

let s1: ImmutableString = "hello".into();

// No actual cloning of the string is involved below.
let s2 = s1.clone();
let s3 = s2.clone();

assert_eq!(s1, s2);

// Clones the underlying string (because it is already shared) and extracts it.
let mut s: String = s1.into_owned();

// Changing the clone has no impact on the previously shared version.
s.push_str(", world!");

// The old version still exists.
assert_eq!(s2, s3);
assert_eq!(s2.as_str(), "hello");

// Not equals!
assert_ne!(s2.as_str(), s.as_str());
assert_eq!(s, "hello, world!");

Implementations

impl ImmutableString[src]

pub fn into_owned(self) -> String[src]

Consume the ImmutableString and convert it into a String. If there are other references to the same string, a cloned copy is returned.

Trait Implementations

impl Add<&'_ ImmutableString> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the + operator.

fn add(self, rhs: Self) -> Self::Output[src]

Performs the + operation. Read more

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

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: &str) -> Self::Output[src]

Performs the + operation. Read more

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

type Output = ImmutableString

The resulting type after applying the + operator.

fn add(self, rhs: &str) -> Self::Output[src]

Performs the + operation. Read more

impl Add<ImmutableString> for ImmutableString[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: Self) -> Self::Output[src]

Performs the + operation. Read more

impl Add<String> for ImmutableString[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: String) -> Self::Output[src]

Performs the + operation. Read more

impl Add<String> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the + operator.

fn add(self, rhs: String) -> Self::Output[src]

Performs the + operation. Read more

impl Add<char> for ImmutableString[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, rhs: char) -> Self::Output[src]

Performs the + operation. Read more

impl Add<char> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the + operator.

fn add(self, rhs: char) -> Self::Output[src]

Performs the + operation. Read more

impl AddAssign<&'_ ImmutableString> for ImmutableString[src]

fn add_assign(&mut self, rhs: &ImmutableString)[src]

Performs the += operation. Read more

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

fn add_assign(&mut self, rhs: &str)[src]

Performs the += operation. Read more

impl AddAssign<ImmutableString> for ImmutableString[src]

fn add_assign(&mut self, rhs: ImmutableString)[src]

Performs the += operation. Read more

impl AddAssign<String> for ImmutableString[src]

fn add_assign(&mut self, rhs: String)[src]

Performs the += operation. Read more

impl AddAssign<char> for ImmutableString[src]

fn add_assign(&mut self, rhs: char)[src]

Performs the += operation. Read more

impl AsRef<SmartString<Compact>> for ImmutableString[src]

fn as_ref(&self) -> &SmartString[src]

Performs the conversion.

impl AsRef<str> for ImmutableString[src]

fn as_ref(&self) -> &str[src]

Performs the conversion.

impl Borrow<SmartString<Compact>> for ImmutableString[src]

fn borrow(&self) -> &SmartString[src]

Immutably borrows from an owned value. Read more

impl Borrow<str> for ImmutableString[src]

fn borrow(&self) -> &str[src]

Immutably borrows from an owned value. Read more

impl Clone for ImmutableString[src]

fn clone(&self) -> ImmutableString[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 Debug for ImmutableString[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for ImmutableString[src]

fn default() -> ImmutableString[src]

Returns the “default value” for a type. Read more

impl Deref for ImmutableString[src]

type Target = SmartString

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl<'d> Deserialize<'d> for ImmutableString[src]

fn deserialize<D: Deserializer<'d>>(de: D) -> Result<Self, D::Error>[src]

Deserialize this value from the given Serde deserializer. Read more

impl Display for ImmutableString[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<&'_ ImmutableString> for Dynamic[src]

fn from(value: &ImmutableString) -> Self[src]

Performs the conversion.

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

fn from(value: &String) -> Self[src]

Performs the conversion.

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

fn from(value: &str) -> Self[src]

Performs the conversion.

impl From<ImmutableString> for SmartString[src]

fn from(value: ImmutableString) -> Self[src]

Performs the conversion.

impl From<SmartString<Compact>> for ImmutableString[src]

fn from(value: SmartString) -> Self[src]

Performs the conversion.

impl From<String> for ImmutableString[src]

fn from(value: String) -> Self[src]

Performs the conversion.

impl<'a> FromIterator<&'a char> for ImmutableString[src]

fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self[src]

Creates a value from an iterator. Read more

impl<'a> FromIterator<&'a str> for ImmutableString[src]

fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self[src]

Creates a value from an iterator. Read more

impl<'a> FromIterator<SmartString<Compact>> for ImmutableString[src]

fn from_iter<T: IntoIterator<Item = SmartString>>(iter: T) -> Self[src]

Creates a value from an iterator. Read more

impl<'a> FromIterator<String> for ImmutableString[src]

fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self[src]

Creates a value from an iterator. Read more

impl FromIterator<char> for ImmutableString[src]

fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self[src]

Creates a value from an iterator. Read more

impl FromStr for ImmutableString[src]

type Err = ()

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Parses a string s to return a value of this type. Read more

impl Hash for ImmutableString[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for ImmutableString[src]

fn cmp(&self, other: &ImmutableString) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<S: AsRef<str>> PartialEq<S> for ImmutableString[src]

fn eq(&self, other: &S) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<S: AsRef<str>> PartialOrd<S> for ImmutableString[src]

fn partial_cmp(&self, other: &S) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Serialize for ImmutableString[src]

fn serialize<S: Serializer>(&self, ser: S) -> Result<S::Ok, S::Error>[src]

Serialize this value into the given Serde serializer. Read more

impl Sub<&'_ ImmutableString> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the - operator.

fn sub(self, rhs: Self) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<ImmutableString> for ImmutableString[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, rhs: Self) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<String> for ImmutableString[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, rhs: String) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<String> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the - operator.

fn sub(self, rhs: String) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<char> for ImmutableString[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, rhs: char) -> Self::Output[src]

Performs the - operation. Read more

impl Sub<char> for &ImmutableString[src]

type Output = ImmutableString

The resulting type after applying the - operator.

fn sub(self, rhs: char) -> Self::Output[src]

Performs the - operation. Read more

impl SubAssign<&'_ ImmutableString> for ImmutableString[src]

fn sub_assign(&mut self, rhs: &ImmutableString)[src]

Performs the -= operation. Read more

impl SubAssign<ImmutableString> for ImmutableString[src]

fn sub_assign(&mut self, rhs: ImmutableString)[src]

Performs the -= operation. Read more

impl SubAssign<String> for ImmutableString[src]

fn sub_assign(&mut self, rhs: String)[src]

Performs the -= operation. Read more

impl SubAssign<char> for ImmutableString[src]

fn sub_assign(&mut self, rhs: char)[src]

Performs the -= operation. Read more

impl TryFrom<ImmutableString> for FnPtr[src]

type Error = Box<EvalAltResult>

The type returned in the event of a conversion error.

fn try_from(value: ImmutableString) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl Eq for ImmutableString[src]

impl StructuralEq for ImmutableString[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CallHasher for T where
    T: Hash + ?Sized
[src]

pub default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64 where
    H: Hash + ?Sized,
    B: BuildHasher
[src]

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]