Skip to main content

Field

Struct Field 

Source
pub struct Field(/* private fields */);

Implementations§

Source§

impl Field

Source

pub fn name(&self) -> SmolStr

The field’s name, excluding any whitespace before the colon. Empty when the source had no name at all (: value), which the parser also diagnoses.

Source

pub fn name_token(&self) -> Option<SyntaxToken>

The FIELD_NAME token, absent for a nameless : value.

Source

pub fn name_range(&self) -> TextRange

The name’s source range, collapsed to the colon’s start when there is no name token — so a diagnostic always has somewhere to point.

Source

pub fn value_range(&self) -> TextRange

The range spanning every value line, or an empty range at the field’s end when the field has no value at all (Package: at EOF).

Source

pub fn value_lines(&self) -> impl Iterator<Item = ValueLine> + use<>

The field’s value lines, starting with the field’s own line (everything after the colon) and continuing through its continuation lines.

Source

pub fn comment_lines(&self) -> impl Iterator<Item = CommentLine> + use<>

Comment lines interleaved into this field’s continuation block. R’s read.dcf skips them and resumes the field.

Source

pub fn folded_value(&self) -> String

The field’s logical value: each nonempty value line trimmed, joined with \n. This is what a caller wanting Depends or Roxygen reads. Empty value lines contribute no segment, matching R’s read.dcf.

Source

pub fn raw_value_text(&self) -> String

The exact source bytes of everything after the colon, newlines and interleaved comments included. For the formatter, which rewrites rather than reads.

Trait Implementations§

Source§

impl AstNode for Field

Source§

type Language = DcfLanguage

Source§

fn can_cast(kind: SyntaxKind) -> bool

Source§

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

Source§

fn syntax(&self) -> &SyntaxNode

Source§

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

Source§

impl Clone for Field

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Field

Source§

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

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

impl Eq for Field

Source§

impl Hash for Field

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 Field

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Field

Auto Trait Implementations§

§

impl !RefUnwindSafe for Field

§

impl !Send for Field

§

impl !Sync for Field

§

impl !UnwindSafe for Field

§

impl Freeze for Field

§

impl Unpin for Field

§

impl UnsafeUnpin for Field

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.