/// Write a `ConstVal` in a way closer to the original source code than the `Debug` output.
Write a `ConstVal` in a way closer to the original source code than the `Debug` output.
Write a ` ConstVal ` in a way closer to the original source code than the ` Debug ` output .
fn fmt_const_val<W: Write>(fmt: &mut W, const_val: &ConstVal) -> fmt::Result {
    use middle::const_val::ConstVal::*;
    match *const_val {
        Float(f) => write!(fmt, "{:?}", f),
        Integral(n) => write!(fmt, "{}", n),
        Str(ref s) => write!(fmt, "{:?}", s),
        ByteStr(ref bytes) => {
            let escaped: String = bytes
                .iter()
                .flat_map(|&ch| ascii::escape_default(ch).map(|c| c as char))
                .collect();
            write!(fmt, "b\"{}\"", escaped)
        }
        Bool(b) => write!(fmt, "{:?}", b),
        Function(def_id) => write!(fmt, "{}", item_path_str(def_id)),
        Struct(node_id) | Tuple(node_id) | Array(node_id, _) | Repeat(node_id, _) =>
            write!(fmt, "{}", node_to_string(node_id)),
        Char(c) => write!(fmt, "{:?}", c),
        Dummy => bug!(),
    }
}
fn fmt_const_val < W : Write > ( fmt : & mut W , const_val : & ConstVal ) -> fmt :: Result { use middle :: const_val :: ConstVal :: * ; match * const_val { Float ( f ) => write ! ( fmt " " f ) , Integral ( n ) => write ! ( fmt " " n ) , Str ( ref s ) => write ! ( fmt " " s ) , ByteStr ( ref bytes ) => { let escaped : String = bytes . iter ( ) . flat_map ( | & ch | ascii :: escape_default ( ch ) . map ( | c | c as char ) ) . collect ( ) ; write ! ( fmt " \" \" " escaped ) } Bool ( b ) => write ! ( fmt " " b ) , Function ( def_id ) => write ! ( fmt " " item_path_str ( def_id ) ) , Struct ( node_id ) | Tuple ( node_id ) | Array ( node_id , _ ) | Repeat ( node_id , _ ) => write ! ( fmt " " node_to_string ( node_id ) ) , Char ( c ) => write ! ( fmt " " c ) , Dummy => bug ! ( ) , } }
Write a `ConstVal` in a way closer to the original source code than the `Debug` output.
Write a ` ConstVal ` in a way closer to the original source code than the ` Debug ` output .
fmt
&mut W
const_val
&ConstVal