pub fn encode_char(&self, c: char) -> Option<Vec<char>> {

        match self {
            HuffNode::Tree(l,r) => {
                if let Some(mut v) = l.encode_char(c) {
                    v.insert(0, '0');
                    return Some(v);
                }
                if let Some(mut v) = r.encode_char(c) {
                    v.insert(0, '1');
                    return Some(v);
                }
                None
    
            },
            HuffNode::Leaf(nc) => {
                if c == *nc {
                    Some(Vec::new())
    
                } else { None }
            },
        }
    }
// this method is used to generate the representation of char
// as current Huffman coder, if not find, just return None
this method is used to generate the representation of char
as current Huffman coder, if not find, just return None
this method is used to generate the representation of char as current Huffman coder if not find just return None
pub fn encode_char(&self, c: char) -> Option<Vec<char>> {
        match self {
            HuffNode::Tree(l,r) => {
                if let Some(mut v) = l.encode_char(c) {
                    v.insert(0, '0');
                    return Some(v);
                }
                if let Some(mut v) = r.encode_char(c) {
                    v.insert(0, '1');
                    return Some(v);
                }
                None
            },
            HuffNode::Leaf(nc) => {
                if c == *nc {
                    Some(Vec::new())
                } else { None }
            },
        }
    }
pub fn encode_char ( & self , c : char ) -> Option < Vec < char > > { match self { HuffNode :: Tree ( l , r ) => { if let Some ( mut v ) = l . encode_char ( c ) { v . insert ( 0 , '0' ) ; return Some ( v ) ; } if let Some ( mut v ) = r . encode_char ( c ) { v . insert ( 0 , '1' ) ; return Some ( v ) ; } None } , HuffNode :: Leaf ( nc ) => { if c == * nc { Some ( Vec :: new ( ) ) } else { None } } , } }
this method is used to generate the representation of char
as current Huffman coder, if not find, just return None
this method is used to generate the representation of char as current Huffman coder if not find just return None
&self
c
char
&self
c
char