Created
May 19, 2020 18:10
-
-
Save DarkFenX/82c9752fe1e51f105d0fb91aa4cc9229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0277]: the trait bound `std::option::Option<main::Extras>: std::convert::From<std::option::Option<main::JsonExtras>>` is not satisfied | |
--> src/main.rs:19:62 | |
| | |
19 | Data { some_id: self.someID, extras: self.extras.into() } | |
| ^^^^ the trait `std::convert::From<std::option::Option<main::JsonExtras>>` is not implemented for `std::option::Option<main::Extras>` | |
| | |
= help: the following implementations were found: | |
<std::option::Option<&'a T> as std::convert::From<&'a std::option::Option<T>>> | |
<std::option::Option<&'a mut T> as std::convert::From<&'a mut std::option::Option<T>>> | |
<std::option::Option<T> as std::convert::From<T>> | |
= note: required because of the requirements on the impl of `std::convert::Into<std::option::Option<main::Extras>>` for `std::option::Option<main::JsonExtras>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
use std::fs; | |
fn main() -> std::io::Result<()> { | |
pub struct Data { | |
pub some_id: u32, | |
pub extras: Option<Extras>, | |
} | |
pub struct Extras { | |
pub another_id: u32, | |
} | |
pub struct JsonData { | |
pub someID: u32, | |
pub extras: Option<JsonExtras>, | |
} | |
impl Into<Data> for JsonData { | |
fn into(self) -> Data { | |
Data { some_id: self.someID, extras: self.extras.into() } | |
} | |
} | |
pub struct JsonExtras { | |
pub anotherID: u32, | |
} | |
impl Into<Extras> for JsonExtras { | |
fn into(self) -> Extras { | |
Extras { another_id: self.anotherID } | |
} | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment