Skip to content
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

safe get methods for Yaml #5

Closed
blaenk opened this issue Jul 2, 2015 · 2 comments
Closed

safe get methods for Yaml #5

blaenk opened this issue Jul 2, 2015 · 2 comments

Comments

@blaenk
Copy link

blaenk commented Jul 2, 2015

It's nice that we have convenience Index impls for Yaml, but it'd be nice if we could have access to safe methods that don't panic if the key is missing.

@chyh1990
Copy link
Owner

chyh1990 commented Jul 2, 2015

It won't panic, it is one of the feature of yaml-rust. It just return a special Yaml::BadValue.

Example for readme:

// Chained key/array access is checked and won't panic,
// return BadValue if they are not exist.
assert!(doc["INVALID_KEY"][100].is_badvalue());

@blaenk
Copy link
Author

blaenk commented Jul 2, 2015

Ah yeah, I forgot about that :)

@blaenk blaenk closed this as completed Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants