Unexpected end of macro invocation in Rust

2.1k views Asked by At

I have the following code in Rust

use std::fmt;

pub struct MyRange<Idx> {
    pub start: Idx,
    pub end: Idx,
}

impl fmt::Debug for MyRange<f32>  {
    fn fmt( &self, f: &mut fmt::Formatter ) -> fmt::Result {
        write!( "Nothing seriously" )
    }
}

fn main() {
    let start:f32= 1.2;
    let end:f32 = 5.;
    let rng2 = MyRange { start: start, end: end};
    println!( "{:?}", rng2 ); 
}

At Compile, I'm getting the following error

error: unexpected end of macro invocation
  --> src/main.rs:10:17
   |
10 |         write!( "Nothing seriously" )
   |                 ^^^^^^^^^^^^^^^^^^^

I'm not exactly certain what the problem is.

Edit: I'm using the latest Rust version (Stable 1.20)

1

There are 1 answers

0
Pavel Strakhov On BEST ANSWER

write! expects the output buffer as its first argument:

write!(f, "Nothing seriously")