-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
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
Modified with trait #35
Conversation
Thanks! Not related to your change, but is there really no stdlib version of this yet? Very disappointing IMO. Regardless, I don't see how this can hurt so I'll probably merge soon. |
Yeah, there seems to be a couple of external libraries providing this trait. However, I believe given this project has zero dependencies, I implemented one within the library Also, going through your Github issues, people seemed to be interested in compatibility with |
What are you thinking for version information. Does this require a semver change? I'm leaning no since no tests were changed yet they still pass. |
Also, I switched to |
let me know if that sounds good and I can release the version |
I believe crates.io will require some version change for a modified push |
Yes, please do! I don't do rust anymore so this library is only maintained by contributors. |
Persistent to issue #17 I have modified the implementation of the strfmt function by using a crate-level exported Map trait instead of using a reference to a HashMap
The Map trait is automatically impleemeneted for
std::collection::HashMap
,serde_json::Map<String, Value>
and forstd::env::Vars
. For any other custom structs it can be implemented at the user-levelThis is the implementation of the trait
In general, the
.get()
method is used. However for cases where a local object is created and to be returned for the string-formatting, an object reference cannot be returned since it will be destroyed pursuant Rust's lifetime rules. Hence, in such cases.get_owned
can be used which will return an owned object and not a reference.By default,
.get()
is first tried. If it returnsNone
, it tries.get_owned()
. If both returnNone
, then new_key_error is raisedAdditionally, all the tests for this have also passed pursuant to
cargo test