Fix positions.

This commit is contained in:
Stephen Chung
2022-02-10 17:55:32 +08:00
parent 3050e38c5e
commit d23d1159ab
10 changed files with 95 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
use crate::ast::Ident;
use crate::tokenizer::Token;
use crate::StaticVec;
use crate::{Position, StaticVec};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
@@ -114,4 +114,12 @@ impl Namespace {
pub(crate) fn set_index(&mut self, index: Option<NonZeroUsize>) {
self.index = index
}
/// Get the [position][Position] of this [`NameSpace`].
///
/// # Panics
///
/// Panics if the path is empty.
pub fn position(&self) -> Position {
self.path[0].pos
}
}