Skip to content

cargo fmt makes example not compile? #2

@EriKWDev

Description

@EriKWDev

This was a very strange experience, but the example compiles if I go into the folder and do cargo run, but if I do cargo fmt and then cargo run I suddenly get compilation errors.

> cargo run
   Compiling microserde_example v0.1.0 (/home/erik/Documents/GitHub/microserde/example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/microserde_example`
Bin len: 130
Bin roundtrip equality true
JSON Output {"a":1,"b":2,"c":[3],"e":{"One":[]},"f":{"Two":[4,5]},"g":{"Three":{"x":6,"y":7,}},"h":{"Four":{"w":8,}},"i":{"Four":{"z":9,"w":8,}},"j":"Hello","k":[10,11],"l":[1,2,3,4],"m":[2,3],}
JSON roundtrip equality true
(... and more )

> cargo fmt
> cargo run
   Compiling microserde_example v0.1.0 (/home/erik/Documents/GitHub/microserde/example)
error[E0277]: the trait bound `T: Clone` is not satisfied
 --> src/main.rs:5:10
  |
5 | #[derive(SerBin, DeBin, SerJson, DeJson, SerRon, DeRon, PartialEq)]
  |          ^^^^^^ the trait `Clone` is not implemented for `T`
  |
note: required by a bound in `MyStruct`
 --> src/main.rs:8:8
  |
6 | struct MyStruct<T>
  |        -------- required by a bound in this struct
7 | where
8 |     T: Clone,
  |        ^^^^^ required by this bound in `MyStruct`
  = note: this error originates in the derive macro `SerBin` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T`
  |
6 | struct MyStruct<T: std::clone::Clone>
  |                  +++++++++++++++++++

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions