pub struct Entry { /* private fields */ }Expand description
A committed entry: its number and where its text lives in the session’s source map.
Returned in Feed::Complete. The text itself is stored once, in the
session; an Entry is a small Copy handle to it.
§Examples
use repl_lang::{Feed, Session, Span, Status};
let mut session = Session::new();
session.feed("first", |_| Status::Complete(()))?;
let Feed::Complete { entry, .. } = session.feed("second", |_| Status::Complete(()))? else {
return Err("the pipeline always completes".into());
};
assert_eq!(entry.number(), 2);
assert_eq!(entry.span(), Span::new(6, 13));
let source = session.sources().source(entry.id()).ok_or("missing")?;
assert_eq!(source.name(), "<repl:2>");
assert_eq!(source.text(), "second\n");Implementations§
Source§impl Entry
impl Entry
Sourcepub const fn number(&self) -> u32
pub const fn number(&self) -> u32
The entry’s number, counting from 1 in the order entries were
committed. It matches Input::number for the
input that produced it and is the key for
Session::entry.
Sourcepub const fn id(&self) -> SourceId
pub const fn id(&self) -> SourceId
The entry’s id in Session::sources.
Sourcepub const fn span(&self) -> Span
pub const fn span(&self) -> Span
The global span of the entry’s text, equal to the
Input::span the pipeline saw.
Trait Implementations§
impl Copy for Entry
impl Eq for Entry
impl StructuralPartialEq for Entry
Auto Trait Implementations§
impl Forget for Entry
impl Freeze for Entry
impl Move for Entry
impl RefUnwindSafe for Entry
impl Send for Entry
impl Sync for Entry
impl Unpin for Entry
impl UnsafeUnpin for Entry
impl UnwindSafe for Entry
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