File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 11//! # Trie
22
33const ALPHABET_SIZE : usize = 26 ;
4- const FIRST_CHAR : char = 'A' ;
4+ const FIRST_CHAR : usize = 'A' as usize ;
55
66#[ derive( Default ) ]
77struct Node {
@@ -45,7 +45,7 @@ impl Trie {
4545 pub fn insert ( & mut self , s : & [ char ] ) {
4646 let mut v = 0 ;
4747 for & ch in s {
48- let idx = ch as usize - FIRST_CHAR as usize ;
48+ let idx = ch as usize - FIRST_CHAR ;
4949 if self . t [ v] . next [ idx] . is_none ( ) {
5050 self . t [ v] . next [ idx] = Some ( self . t . len ( ) ) ;
5151 self . t . push ( Node :: default ( ) ) ;
@@ -63,7 +63,7 @@ impl Trie {
6363 pub fn find ( & self , s : & [ char ] ) -> usize {
6464 let mut v = 0 ;
6565 for & ch in s {
66- let idx = ch as usize - FIRST_CHAR as usize ;
66+ let idx = ch as usize - FIRST_CHAR ;
6767 if let Some ( u) = self . t [ v] . next [ idx] {
6868 v = u;
6969 } else {
You can’t perform that action at this time.
0 commit comments