26 lines
454 B
Rust
26 lines
454 B
Rust
use std::rc::Rc;
|
|
|
|
pub struct FqnContext {
|
|
parts: Vec<Rc<str>>,
|
|
}
|
|
|
|
impl FqnContext {
|
|
pub fn new() -> Self {
|
|
Self { parts: vec![] }
|
|
}
|
|
|
|
pub fn push(&mut self, part: Rc<str>) {
|
|
self.parts.push(part);
|
|
}
|
|
|
|
pub fn pop(&mut self) {
|
|
self.parts.pop();
|
|
}
|
|
|
|
pub fn resolve(&self, name: &str) -> Vec<Rc<str>> {
|
|
let mut result = self.parts.clone();
|
|
result.push(name.into());
|
|
result
|
|
}
|
|
}
|