From 0a84afff254e3b1b192a23ba89e5bf5d0cc339d1 Mon Sep 17 00:00:00 2001 From: Petros Angelatos Date: Thu, 24 Mar 2022 23:31:34 +0100 Subject: [PATCH] trie: adapt unstable box_pattern code to stable rust fixes #7 Signed-off-by: Petros Angelatos --- src/catalog/trie.rs | 48 +++++++++++++++++++++++---------------------- src/lib.rs | 2 -- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/catalog/trie.rs b/src/catalog/trie.rs index c0ff28c..f731d84 100644 --- a/src/catalog/trie.rs +++ b/src/catalog/trie.rs @@ -140,9 +140,6 @@ pub trait TrieElim: Debug + Hash + PartialEq + Eq + Clone + 'static { NameC: FnOnce(&Name, &Self) -> Res; } -/* -20121221-- requires box_syntax feature - impl Trie { fn mfn(nm: Name, meta: Meta, trie: Self, bs: BS, elt: X, hash: u64) -> Self { match trie { @@ -185,39 +182,44 @@ impl Trie { Self::bin(bs, *left, r) } } - Trie::Name(_, box Trie::Art(a)) => Self::mfn(nm, meta, force(&a), bs, elt, hash), + Trie::Name(name, name_trie) => match *name_trie { + Trie::Art(a) => Self::mfn(nm, meta, force(&a), bs, elt, hash), + t => panic!("Bad value found in nadd:\n{:?}\n", Trie::Name(name, Box::new(t))), + }, t => panic!("Bad value found in nadd:\n{:?}\n", t), } } fn root_mfn(_: Name, nm: Name, trie: Self, elt: X) -> Self { match trie { - Trie::Name(_, box Trie::Art(a)) => { - match force(&a) { - Trie::Root(meta, t) => { - let (nm, nm_) = name_fork(nm); - let mut hasher = DefaultHasher::new(); - elt.hash(&mut hasher); - let a = Self::mfn(nm_, - meta.clone(), - *t, - BS { - length: 0, - value: 0, - }, - elt, - hasher.finish()); - Self::root(meta, Self::name(nm, Self::art(put(a)))) + Trie::Name(_, name_trie) => match *name_trie { + Trie::Art(a) => { + match force(&a) { + Trie::Root(meta, t) => { + let (nm, nm_) = name_fork(nm); + let mut hasher = DefaultHasher::new(); + elt.hash(&mut hasher); + let a = Self::mfn(nm_, + meta.clone(), + *t, + BS { + length: 0, + value: 0, + }, + elt, + hasher.finish()); + Self::root(meta, Self::name(nm, Self::art(put(a)))) + } + Trie::Name(name, name_trie) if matches!(&*name_trie, Trie::Art(_)) => Self::root_mfn(nm.clone(), nm, Trie::Name(name, name_trie), elt), + t => panic!("Non-root node entry to `Trie.extend': {:?}", t), } - t @ Trie::Name(_, box Trie::Art(_)) => Self::root_mfn(nm.clone(), nm, t, elt), - t => panic!("Non-root node entry to `Trie.extend': {:?}", t), } + _ => panic!("None-name node at entry to `Trie.extend'"), } _ => panic!("None-name node at entry to `Trie.extend'"), } } } -*/ impl TrieIntro for Trie { fn nil(bs: BS) -> Self { diff --git a/src/lib.rs b/src/lib.rs index 2086a98..f18d82f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1396,8 +1396,6 @@ list. */ //#![feature(associated_consts)] -//#![feature(box_patterns)] -//#![feature(box_syntax)] #![crate_name = "adapton"] #![crate_type = "lib"]