From 9803c0ca81caa92460a07b07dfe3153f75df2aa7 Mon Sep 17 00:00:00 2001 From: caitlin Date: Fri, 16 Aug 2019 07:03:31 +0800 Subject: [PATCH] feat(geektime_algo): add 35 trie fix get_or_insert_with error --- rust/35_trie/trie.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/35_trie/trie.rs b/rust/35_trie/trie.rs index 6ad3ca8..abfb2a5 100644 --- a/rust/35_trie/trie.rs +++ b/rust/35_trie/trie.rs @@ -14,7 +14,7 @@ impl Trie { fn insert(&mut self, word: &str) { let mut curr = self; for i in word.chars().map(|c| (c as usize - 'a' as usize) as usize) { - curr = curr.nodes[i].get_or_insert_with(Box::new(Trie::new())); + curr = curr.nodes[i].get_or_insert_with(|| Box::new(Trie::new())); } curr.is_ending = true; }