pub type ConfigKey = Txt;
Expand description
Unique key to a config entry.
Aliased Type§
struct ConfigKey(/* private fields */);
Implementations
Source§impl Txt
impl Txt
Sourcepub const fn from_static(s: &'static str) -> Txt
pub const fn from_static(s: &'static str) -> Txt
New text that is a &'static str
.
Sourcepub const fn from_string(s: String) -> Txt
pub const fn from_string(s: String) -> Txt
Sourcepub fn from_str(s: &str) -> Txt
pub fn from_str(s: &str) -> Txt
New cloned from s
.
The text will be internally optimized for sharing, if you plan to edit the text after this call
consider using from_string
instead.
Sourcepub fn from_arc(s: Arc<str>) -> Txt
pub fn from_arc(s: Arc<str>) -> Txt
New from a shared arc str.
Note that the text can outlive the Arc
, by cloning the string data when modified or
to use a more optimal representation, you cannot use the reference count of s
to track
the lifetime of the text.
Sourcepub fn from_fmt(args: Arguments<'_>) -> Txt
pub fn from_fmt(args: Arguments<'_>) -> Txt
New text from format_args!
, avoids allocation if the text is static (no args) or can fit the inlined representation.
Sourcepub fn end_mut(&mut self)
pub fn end_mut(&mut self)
Convert the inner representation of the string to not be String
. After
this call the text can be cheaply cloned.
Sourcepub fn into_owned(self) -> String
pub fn into_owned(self) -> String
Extracts the owned string.
Turns the text to owned if it was borrowed.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Calls String::clear
if the text is owned, otherwise
replaces self
with an empty str (""
).
Sourcepub fn pop(&mut self) -> Option<char>
pub fn pop(&mut self) -> Option<char>
Removes the last character from the text and returns it.
Returns None if this Txt
is empty.
This method only converts to TxtRepr::String
if the
internal representation is TxtRepr::Arc
, other representations are reborrowed.
Sourcepub fn truncate(&mut self, new_len: usize)
pub fn truncate(&mut self, new_len: usize)
Shortens this Txt
to the specified length.
If new_len
is greater than the text’s current length, this has no
effect.
This method only converts to TxtRepr::String
if the
internal representation is TxtRepr::Arc
, other representations are reborrowed.
Sourcepub fn split_off(&mut self, at: usize) -> Txt
pub fn split_off(&mut self, at: usize) -> Txt
Splits the text into two at the given index.
Returns a new Txt
. self
contains bytes [0, at)
, and
the returned Txt
contains bytes [at, len)
. at
must be on the
boundary of a UTF-8 code point.
This method only converts to TxtRepr::String
if the
internal representation is TxtRepr::Arc
, other representations are reborrowed.
Sourcepub fn push(&mut self, c: char)
pub fn push(&mut self, c: char)
Push the character to the end of the text.
This method avoids converting to TxtRepr::String
when the current text
plus char can fit inlined.
Sourcepub fn push_str(&mut self, s: &str)
pub fn push_str(&mut self, s: &str)
Push the string to the end of the text.
This method avoids converting to TxtRepr::String
when the current text
plus char can fit inlined.
Sourcepub fn as_static_str(&self) -> Option<&'static str>
pub fn as_static_str(&self) -> Option<&'static str>
Copy the inner static str
if this text represents one.
Trait Implementations
Source§impl AddAssign<&str> for Txt
impl AddAssign<&str> for Txt
Source§fn add_assign(&mut self, rhs: &str)
fn add_assign(&mut self, rhs: &str)
+=
operation. Read moreSource§impl Clone for Txt
Clones the text.
impl Clone for Txt
Clones the text.
If the inner representation is TxtRepr::String
the returned value is in a representation optimized
for sharing, either a static empty, an inlined short or an Arc<str>
long string.
Source§impl<'de> Deserialize<'de> for Txt
impl<'de> Deserialize<'de> for Txt
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Txt, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Txt, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl IntoVar<CategoryId> for Txt
impl IntoVar<CategoryId> for Txt
Source§impl IntoVar<CommandScope> for Txt
impl IntoVar<CommandScope> for Txt
Source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moreSource§impl IntoVar<Cow<'static, str>> for Txt
impl IntoVar<Cow<'static, str>> for Txt
Source§impl IntoVar<DragDropData> for Txt
impl IntoVar<DragDropData> for Txt
Source§fn into_var(self) -> <Txt as IntoVar<DragDropData>>::Var
fn into_var(self) -> <Txt as IntoVar<DragDropData>>::Var
Source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moreSource§impl IntoVar<FileDialogFilters> for Txt
impl IntoVar<FileDialogFilters> for Txt
Source§fn into_var(self) -> <Txt as IntoVar<FileDialogFilters>>::Var
fn into_var(self) -> <Txt as IntoVar<FileDialogFilters>>::Var
Source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read more