pub struct KdlString<'a> { /* private fields */ }Expand description
A KDL string, parsed from an identifier, escaped string, or raw string. Exists in either Owned or Borrowed form, depending on whether there were escapes in the string. Doesn’t track the origin of the string (identifier, escaped, or raw), because KDL semantics treat them all identically.
Implementations§
Source§impl<'a> KdlString<'a>
impl<'a> KdlString<'a>
Sourcepub fn from_borrowed(s: &'a str) -> Self
pub fn from_borrowed(s: &'a str) -> Self
Create a borrowed KDL string
Sourcepub fn from_string(s: String) -> Self
pub fn from_string(s: String) -> Self
Create an owned KDL string
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Convert this unconditionally into an owned string.
Methods from Deref<Target = Cow<'a, str>>§
1.0.0 · Sourcepub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned
Acquires a mutable reference to the owned form of the data.
Clones the data if it is not already owned.
§Examples
use std::borrow::Cow;
let mut cow = Cow::Borrowed("foo");
cow.to_mut().make_ascii_uppercase();
assert_eq!(
cow,
Cow::Owned(String::from("FOO")) as Cow<'_, str>
);Trait Implementations§
Source§impl<'de> Deserialize<'de> for KdlString<'de>
impl<'de> Deserialize<'de> for KdlString<'de>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a, 'b> Extend<&'b char> for KdlString<'a>
impl<'a, 'b> Extend<&'b char> for KdlString<'a>
Source§fn extend<T: IntoIterator<Item = &'b char>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'b char>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<'a> Extend<&'a str> for KdlString<'a>
impl<'a> Extend<&'a str> for KdlString<'a>
Source§fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a str>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl Extend<char> for KdlString<'_>
impl Extend<char> for KdlString<'_>
Source§fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = char>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T> FromIterator<T> for KdlString<'_>where
Self: Extend<T>,
impl<T> FromIterator<T> for KdlString<'_>where
Self: Extend<T>,
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a> StringBuilder<'a> for KdlString<'a>
impl<'a> StringBuilder<'a> for KdlString<'a>
impl<'a> Eq for KdlString<'a>
Auto Trait Implementations§
impl<'a> Freeze for KdlString<'a>
impl<'a> RefUnwindSafe for KdlString<'a>
impl<'a> Send for KdlString<'a>
impl<'a> Sync for KdlString<'a>
impl<'a> Unpin for KdlString<'a>
impl<'a> UnsafeUnpin for KdlString<'a>
impl<'a> UnwindSafe for KdlString<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
Source§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more