pub(crate) struct RenderContext<'a, 'db> {
completion: &'a CompletionContext<'a, 'db>,
is_private_editable: bool,
import_to_add: Option<LocatedImport>,
doc_aliases: Vec<SmolStr>,
}Expand description
Interface for data and methods required for items rendering.
Fields§
§completion: &'a CompletionContext<'a, 'db>§is_private_editable: bool§import_to_add: Option<LocatedImport>§doc_aliases: Vec<SmolStr>Implementations§
Source§impl<'a, 'db> RenderContext<'a, 'db>
impl<'a, 'db> RenderContext<'a, 'db>
pub(crate) fn new( completion: &'a CompletionContext<'a, 'db>, ) -> RenderContext<'a, 'db>
pub(crate) fn private_editable(self, private_editable: bool) -> Self
pub(crate) fn import_to_add(self, import_to_add: Option<LocatedImport>) -> Self
pub(crate) fn doc_aliases(self, doc_aliases: Vec<SmolStr>) -> Self
fn snippet_cap(&self) -> Option<SnippetCap>
fn db(&self) -> &'a RootDatabase
fn source_range(&self) -> TextRange
fn completion_relevance(&self) -> CompletionRelevance
fn is_immediately_after_macro_bang(&self) -> bool
Sourcefn is_deprecated(
&self,
def: impl HasAttrs,
def_as_assoc_item: Option<AssocItem>,
) -> bool
fn is_deprecated( &self, def: impl HasAttrs, def_as_assoc_item: Option<AssocItem>, ) -> bool
Whether def is deprecated.
This can happen for two reasons:
- the def is marked with
#[deprecated] - the def is an assoc item whose trait is deprecated
In order to be able to check for the latter, we’d ideally want to try_as_dyn<_, dyn AsAssocItem>(def)
(see try_as_dyn), but that function is currently unstable. Therefore, we employ a hack instead:
if def can be an assoc item, it should be passed to this method as follows:
ⓘ
self.is_deprecated(def, Some(def))otherwise, it should be passed as:
ⓘ
self.is_deprecated(def, None)Sourcefn is_variant_deprecated(&self, variant: EnumVariant) -> bool
fn is_variant_deprecated(&self, variant: EnumVariant) -> bool
Whether an enum variant should be rendered as deprecated.
A variant inherits deprecation from its parent enum, matching rustc’s
behavior where #[deprecated] on an enum applies to its variants.
fn docs(&self, def: impl HasDocs) -> Option<Documentation<'a>>
Trait Implementations§
Source§impl<'a, 'db> Clone for RenderContext<'a, 'db>
impl<'a, 'db> Clone for RenderContext<'a, 'db>
Source§fn clone(&self) -> RenderContext<'a, 'db>
fn clone(&self) -> RenderContext<'a, 'db>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<'a, 'db> Freeze for RenderContext<'a, 'db>
impl<'a, 'db> !RefUnwindSafe for RenderContext<'a, 'db>
impl<'a, 'db> !Send for RenderContext<'a, 'db>
impl<'a, 'db> !Sync for RenderContext<'a, 'db>
impl<'a, 'db> Unpin for RenderContext<'a, 'db>
impl<'a, 'db> UnsafeUnpin for RenderContext<'a, 'db>
impl<'a, 'db> !UnwindSafe for RenderContext<'a, 'db>
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,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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