fn check_round_trip(instructions: Vec<Draw>) {
        // Encode the instruction
        let mut encoded = String::new();
        for instruction in instructions.iter() {
            instruction.encode_canvas(&mut encoded);
        }

        println!("{:?} {:?}", instructions, encoded);

        // Try decoding it
        let decoded = decode_drawing(encoded.chars()).collect::<Vec<_>>();

        println!("  -> {:?}", decoded);

        // Should decode OK
        assert!(decoded.len() == instructions.len());

        // Should be the same as the original instruction
        assert!(decoded == instructions.into_iter().map(|draw| Ok(draw)).collect::<Vec<_>>());
    }
///
/// Checks if a particular string of drawing operations can be both encoded and decoded
///
Checks if a particular string of drawing operations can be both encoded and decoded
Checks if a particular string of drawing operations can be both encoded and decoded
fn check_round_trip(instructions: Vec<Draw>) {
        // Encode the instruction
        let mut encoded = String::new();
        for instruction in instructions.iter() {
            instruction.encode_canvas(&mut encoded);
        }
        println!("{:?} {:?}", instructions, encoded);
        // Try decoding it
        let decoded = decode_drawing(encoded.chars()).collect::<Vec<_>>();
        println!("  -> {:?}", decoded);
        // Should decode OK
        assert!(decoded.len() == instructions.len());
        // Should be the same as the original instruction
        assert!(decoded == instructions.into_iter().map(|draw| Ok(draw)).collect::<Vec<_>>());
    }
fn check_round_trip ( instructions : Vec < Draw > ) { // Encode the instruction let mut encoded = String :: new ( ) ; for instruction in instructions . iter ( ) { instruction . encode_canvas ( & mut encoded ) ; } println ! ( " " instructions encoded ) ; // Try decoding it let decoded = decode_drawing ( encoded . chars ( ) ) . collect :: < Vec < _ > > ( ) ; println ! ( " " decoded ) ; // Should decode OK assert ! ( decoded len ( ) instructions len ( ) ) ; // Should be the same as the original instruction assert ! ( decoded instructions into_iter ( ) map ( draw Ok ( draw ) ) collect Vec ( ) ) ; }
Checks if a particular string of drawing operations can be both encoded and decoded
Checks if a particular string of drawing operations can be both encoded and decoded
instructions
Vec<Draw>