Skip to main content

Docs

Struct Docs 

Source
pub struct Docs {
    docs: String,
    docs_source_map: Vec<DocsSourceMapLine>,
    outline_mod: Option<(HirFileId, usize)>,
    inline_file: HirFileId,
    prefix_len: TextSize,
    inline_inner_docs_start: Option<TextSize>,
    outline_inner_docs_start: Option<TextSize>,
    macro_calls: ThinVec<(AstId<MacroCall>, MacroCallId)>,
}

Fields§

§docs: String

The concatenated string of all #[doc = "..."] attributes and documentation comments.

§docs_source_map: Vec<DocsSourceMapLine>

A sorted map from an offset in docs to an offset in the source code.

§outline_mod: Option<(HirFileId, usize)>

If the item is an outlined module (mod foo;), docs_source_map stores the concatenated list of the outline and inline docs (outline first). Then, this field contains the [HirFileId] of the outline declaration, and the index in docs from which the inline docs begin.

§inline_file: HirFileId§prefix_len: TextSize

The size of the prepended prefix, which does not map to real doc comments.

§inline_inner_docs_start: Option<TextSize>

The offset in docs from which the docs are inner attributes/comments.

§outline_inner_docs_start: Option<TextSize>

Like inline_inner_docs_start, but for outline_mod. This can happen only when merging Docs (as outline modules don’t have inner attributes).

§macro_calls: ThinVec<(AstId<MacroCall>, MacroCallId)>

All macro calls in #[doc = ...] attributes, recursively.

Implementations§

Source§

impl Docs

Source

pub fn docs(&self) -> &str

Source

pub fn into_docs(self) -> String

Source

pub fn macro_calls( &self, ) -> impl Iterator<Item = (AstId<MacroCall>, MacroCallId)>

Source

fn is_empty(&self) -> bool

Source

pub fn find_ast_range( &self, string_range: TextRange, ) -> Option<(InFile<TextRange>, IsInnerDoc)>

Source

pub fn shift_by(&mut self, offset: TextSize)

Source

pub fn prepend_str(&mut self, s: &str)

Source

pub fn append_str(&mut self, s: &str)

Source

pub fn append(&mut self, other: &Docs)

Source

fn extend_with_doc_comment(&mut self, comment: DocComment, indent: &mut Indent)

Source

fn extend_with_doc_attr(&mut self, value: String, indent: &mut Indent)

Source

fn extend_with_doc_str( &mut self, doc: &str, offset_in_ast: TextSize, comment_kind: DocCommentKind, indent: &mut Indent, )

Source

fn extend_with_unmapped_doc_str(&mut self, doc: &str, indent: &mut Indent)

Source

fn push_doc_lines( &mut self, doc: &str, ast_offset: Option<TextSize>, comment_kind: DocCommentKind, indent: &mut Indent, )

Beautifies doc and appends the result to self.docs, one line at a time via Docs::push_doc_line. Mirrors rustc’s beautify_doc_string, delegating to get_vertical_trim and get_horizontal_trim for the multi-line case.

Individual /// line comments always reach us as a single-line doc, so the !doc.contains('\n') fast path fires and the multi-line logic never runs on them. Desugared #[doc = "..."] strings and macro-expanded docs also route through here with shape = CommentShape::Line, matching rustc.

Unlike rustc’s version, which joins the beautified lines into a new interned Symbol, this port pushes each line individually via Docs::push_doc_line and pairs it with its byte offset relative to doc’s start so the source-map records accurate per-line offsets.

Source

fn push_doc_line( &mut self, line: &str, ast_offset: Option<TextSize>, comment_kind: DocCommentKind, indent: &mut Indent, )

Appends a single beautified line to self.docs and records its source-map row.

Source

fn remove_indent(&mut self, indent: &Indent)

Source

fn remove_last_newline(&mut self)

Source

fn shrink_to_fit(&mut self)

Trait Implementations§

Source§

impl Clone for Docs

Source§

fn clone(&self) -> Docs

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 Docs

Source§

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

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

impl Eq for Docs

Source§

impl Hash for Docs

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 Docs

Source§

fn eq(&self, other: &Docs) -> 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 Docs

Auto Trait Implementations§

§

impl Freeze for Docs

§

impl RefUnwindSafe for Docs

§

impl Send for Docs

§

impl Sync for Docs

§

impl Unpin for Docs

§

impl UnsafeUnpin for Docs

§

impl UnwindSafe for Docs

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
§

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

§

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

Compare self to key and return true if they are equal.
§

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

§

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.

§

impl<T> HashEqLike<&T> for T
where T: Hash + Eq,

§

fn eq(&self, data: &&T) -> bool

§

impl<T> HashEqLike<Cow<'_, T>> for T
where T: Hash + Eq + Clone,

§

fn eq(&self, data: &Cow<'_, T>) -> bool

§

impl<T> HashEqLike<T> for T
where T: Hash + Eq,

§

fn eq(&self, data: &T) -> bool

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoBox<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Send + Sync>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more