pub struct Annotation<T = ()> { /* private fields */ }Expand description
A caller-provided semantic range with arbitrary typed data.
This annotation marks only price in a one-line source:
use lumis_core::annotations::Annotation;
let source = "let total = price;";
let annotation = Annotation::new(12..17, "search-match")?;
assert_eq!(&source[12..17], "price");When passed in highlighting options, a custom formatter receives
AnnotationStart before
price and AnnotationEnd
after it.
Implementations§
Source§impl<T> Annotation<T>
impl<T> Annotation<T>
Sourcepub fn new(
range: impl Into<AnnotationRange>,
data: T,
) -> Result<Annotation<T>, AnnotationError>
pub fn new( range: impl Into<AnnotationRange>, data: T, ) -> Result<Annotation<T>, AnnotationError>
Creates an annotation for an offset or position range.
An empty range is a point: it marks a position rather than covering
text, and a formatter receives
AnnotationStart
immediately followed by
AnnotationEnd there.
Line-keyed overlays need this for a blank line, which has nothing to
cover but is still somewhere a review comment can land.
Only a reversed range is rejected. Source bounds, position bounds, and UTF-8 character boundaries are checked when the annotation is used to format a specific source.
Sourcepub fn range(&self) -> &AnnotationRange
pub fn range(&self) -> &AnnotationRange
Returns the caller-provided source range.
Trait Implementations§
Source§impl<T> Clone for Annotation<T>where
T: Clone,
impl<T> Clone for Annotation<T>where
T: Clone,
Source§fn clone(&self) -> Annotation<T>
fn clone(&self) -> Annotation<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for Annotation<T>where
T: Debug,
impl<T> Debug for Annotation<T>where
T: Debug,
impl<T> Eq for Annotation<T>where
T: Eq,
Source§impl<T> Hash for Annotation<T>where
T: Hash,
impl<T> Hash for Annotation<T>where
T: Hash,
Source§impl<T> PartialEq for Annotation<T>where
T: PartialEq,
impl<T> PartialEq for Annotation<T>where
T: PartialEq,
impl<T> StructuralPartialEq for Annotation<T>where
T: PartialEq,
Auto Trait Implementations§
impl<T> Freeze for Annotation<T>where
T: Freeze,
impl<T> RefUnwindSafe for Annotation<T>where
T: RefUnwindSafe,
impl<T> Send for Annotation<T>where
T: Send,
impl<T> Sync for Annotation<T>where
T: Sync,
impl<T> Unpin for Annotation<T>where
T: Unpin,
impl<T> UnsafeUnpin for Annotation<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Annotation<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.