We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelativePathBuf
Hello, thank you for your work! Figment is really an awesome work with ergonomic designs.
But I encounter some problems when I would like to deserialize a struct with RelativePathBuf as its field, which is inside an enum:
#[derive(Serialize, Deserialize, Debug)] pub struct Test { trace: RelativePathBuf, } #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "tp")] pub enum Mode { Test(Test), }
I'm using the following code to extract the enum:
fn main() { let m = figment::Figment::new().merge(Toml::file("./mode.toml")).extract::<Mode>().unwrap(); }
Inside the mode.toml file is:
mode.toml
tp = "Test" trace = "./123.json"
This will result in an error:
called `Result::unwrap()` on an `Err` value: Error { tag: Tag::Default, profile: None, metadata: None, path: [], kind: InvalidType(Str("./123.json"), "struct RelativePathBuf"), prev: None }
If I change the RelativePathBuf to String, then it works.
String
It also works if I directly deserialize the struct Test with its field type still as RelativePathBuf, e.g. with:
Test
fn main(){ let t = figment::Figment::new().merge(Toml::file("./test.toml")).extract::<Test>().unwrap(); }
and in the test.toml:
test.toml
trace = "./123.json"
I'm wondering if there is a way to fix my problem, or is this behavior intended?
The deps I'm using:
[dependencies] figment = { version = "0.10.19", features = ["toml", "json"] } serde = { version = "1.0.203", features = ["derive"] } toml = "0.8.14"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, thank you for your work! Figment is really an awesome work with ergonomic designs.
But I encounter some problems when I would like to deserialize a struct with
RelativePathBuf
as its field, which is inside an enum:I'm using the following code to extract the enum:
Inside the
mode.toml
file is:This will result in an error:
If I change the
RelativePathBuf
toString
, then it works.It also works if I directly deserialize the struct
Test
with its field type still asRelativePathBuf
, e.g. with:and in the
test.toml
:I'm wondering if there is a way to fix my problem, or is this behavior intended?
The deps I'm using:
The text was updated successfully, but these errors were encountered: