Paragraph

Struct Paragraph 

Source
pub struct Paragraph(/* private fields */);
Expand description

An AST node representing a Paragraph.

Implementations§

Source§

impl Paragraph

Source

pub fn new() -> Paragraph

Create a new empty paragraph.

Source

pub fn wrap_and_sort( &self, indentation: Indentation, immediate_empty_line: bool, max_line_length_one_liner: Option<usize>, sort_entries: Option<&dyn Fn(&Entry, &Entry) -> Ordering>, format_value: Option<&dyn Fn(&str, &str) -> String>, ) -> Paragraph

Reformat this paragraph

§Arguments
  • indentation - The indentation to use
  • immediate_empty_line - Whether multi-line values should always start with an empty line
  • max_line_length_one_liner - If set, then this is the max length of the value if it is crammed into a “one-liner” value
  • sort_entries - If set, then this function will sort the entries according to the given function
  • format_value - If set, then this function will format the value according to the given function
Source

pub fn get(&self, key: &str) -> Option<String>

Returns the value of the given key in the paragraph.

Source

pub fn contains_key(&self, key: &str) -> bool

Returns whether the paragraph contains the given key.

Source

pub fn entries(&self) -> impl Iterator<Item = Entry> + '_

Returns an iterator over all entries in the paragraph.

Source

pub fn items(&self) -> impl Iterator<Item = (String, String)> + '_

Returns an iterator over all items in the paragraph.

Source

pub fn get_all<'a>(&'a self, key: &'a str) -> impl Iterator<Item = String> + 'a

Returns an iterator over all values for the given key in the paragraph.

Source

pub fn keys(&self) -> impl Iterator<Item = String> + '_

Returns an iterator over all keys in the paragraph.

Source

pub fn remove(&mut self, key: &str)

Remove the given field from the paragraph.

Source

pub fn insert(&mut self, key: &str, value: &str)

Insert a new field

Source

pub fn set(&mut self, key: &str, value: &str)

Set a field in the paragraph

Source

pub fn rename(&mut self, old_key: &str, new_key: &str) -> bool

Rename the given field in the paragraph.

Trait Implementations§

Source§

impl AstNode for Paragraph

Source§

type Language = Lang

Source§

fn can_cast(kind: SyntaxKind) -> bool

Source§

fn cast(syntax: SyntaxNode<Lang>) -> Option<Self>

Source§

fn syntax(&self) -> &SyntaxNode<Lang>

Source§

fn clone_for_update(&self) -> Self
where Self: Sized,

Source§

fn clone_subtree(&self) -> Self
where Self: Sized,

Source§

impl Clone for Paragraph

Source§

fn clone(&self) -> Paragraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Paragraph

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Paragraph

Source§

fn default() -> Self

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

impl Display for Paragraph

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Vec<(&str, &str)>> for Paragraph

Source§

fn from(v: Vec<(&str, &str)>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<(String, String)>> for Paragraph

Source§

fn from(v: Vec<(String, String)>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<(&'a str, &'a str)> for Paragraph

Source§

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

Creates a value from an iterator. Read more
Source§

impl FromIterator<(String, String)> for Paragraph

Source§

fn from_iter<T: IntoIterator<Item = (String, String)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<Paragraph> for Deb822

Source§

fn from_iter<T: IntoIterator<Item = Paragraph>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for Paragraph

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Self, Self::Err>

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

impl Hash for Paragraph

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

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

impl PartialEq for Paragraph

Source§

fn eq(&self, other: &Paragraph) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Paragraph

Source§

impl StructuralPartialEq for Paragraph

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.