Struct rhai::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
Create a new ImmutableString
.
Consume the ImmutableString
and convert it into a String
.
If there are other references to the same string, a cloned copy is returned.
Methods from Deref<Target = SmartString<Compact>>
Return the length in bytes of the string.
Note that this may differ from the length in char
s.
Return the currently allocated capacity of the string.
Note that if this is a boxed string, it returns String::capacity()
,
but an inline string always returns SmartStringMode::MAX_INLINE
.
Note also that if a boxed string is converted into an inline string, its capacity is deallocated, and if the inline string is promoted to a boxed string in the future, it will be reallocated with a default capacity.
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the +=
operation. Read more
Performs the conversion.
Immutably borrows from an owned value. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
type Error = Box<EvalAltResult>
type Error = Box<EvalAltResult>
The type returned in the event of a conversion error.
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for ImmutableString
impl !Send for ImmutableString
impl !Sync for ImmutableString
impl Unpin for ImmutableString
impl UnwindSafe for ImmutableString
Blanket Implementations
Mutably borrows from an owned value. Read more