Serde: Support NonZeroI* types

Created on 14 Jul 2019  路  4Comments  路  Source: serde-rs/serde

A comment here says that the NonZeroI* types might be removed from Rust. It appears that information is out of date since they were promoted to the stable release channel as of version 1.34.0. It'd be great if the macro were updated so we can #[derive(Serialize, Deserialize)] structs that contain these types.

Most helpful comment

Not sure this is related, but since 1.0.98 was released I am seeing:
`` error[E0412]: cannot find typeNonZeroI8in modulenum --> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2416:5 | 2416 | NonZeroI8, | ^^^^^^^^^ help: a struct with a similar name exists:NonZeroU8`

error[E0412]: cannot find type NonZeroI16 in module num
--> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2417:5
|
2417 | NonZeroI16,
| ^^^^^^^^^^ help: a struct with a similar name exists: NonZeroU16

error[E0412]: cannot find type NonZeroI32 in module num
--> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2418:5
|
2418 | NonZeroI32,
| ^^^^^^^^^^ help: a struct with a similar name exists: NonZeroU32

````
etc etc

This is using rustc 1.35.0-nightly (e4c66afba 2019-04-13)

All 4 comments

Thanks, I would accept a PR to implement this.

Not sure this is related, but since 1.0.98 was released I am seeing:
`` error[E0412]: cannot find typeNonZeroI8in modulenum --> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2416:5 | 2416 | NonZeroI8, | ^^^^^^^^^ help: a struct with a similar name exists:NonZeroU8`

error[E0412]: cannot find type NonZeroI16 in module num
--> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2417:5
|
2417 | NonZeroI16,
| ^^^^^^^^^^ help: a struct with a similar name exists: NonZeroU16

error[E0412]: cannot find type NonZeroI32 in module num
--> /home/eran/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.98/src/de/impls.rs:2418:5
|
2418 | NonZeroI32,
| ^^^^^^^^^^ help: a struct with a similar name exists: NonZeroU32

````
etc etc

This is using rustc 1.35.0-nightly (e4c66afba 2019-04-13)

@eranrund -- we don't support old nightly compilers. If you are using nightly, the expectation is that you update the compiler every night or else pin your dependencies so that none of them are newer than the nightly.

Thanks @dtolnay

Was this page helpful?
0 / 5 - 0 ratings