mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Canonicalize to longer version of prefix
This commit is contained in:
parent
4049a8c922
commit
eb185656dd
2 changed files with 8 additions and 2 deletions
|
@ -212,9 +212,15 @@ impl Context {
|
|||
return Some(v)
|
||||
}
|
||||
}
|
||||
for &(ref pre, _) in &self.prefixes {
|
||||
for &(ref pre, ref val) in &self.prefixes {
|
||||
if name.starts_with(pre) {
|
||||
if let Some(v) = self.canonicalize(&name[pre.len()..]) {
|
||||
let mut pre = pre;
|
||||
for &(ref other, ref otherval) in &self.prefixes {
|
||||
if other.len() > pre.len() && val == otherval {
|
||||
pre = other;
|
||||
}
|
||||
}
|
||||
return Some(format!("{}{}", pre, v))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ pub type Dim = Rc<String>;
|
|||
pub type Unit = BTreeMap<Dim, i64>;
|
||||
|
||||
/// The basic representation of a number with a unit.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Number(pub Num, pub Unit);
|
||||
|
||||
fn one() -> Mpq {
|
||||
|
|
Loading…
Reference in a new issue