-
Notifications
You must be signed in to change notification settings - Fork 38
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
Allow integer indexing (closes #92) #116
base: master
Are you sure you want to change the base?
Conversation
567a344
to
64c5310
Compare
@thorio ran a quick test with my use case Works like a charm for both top level arrays and also arrays in sub-keys 👑 |
@SergioBenitez could you take a look at this? |
src/coalesce.rs
Outdated
@@ -27,9 +29,10 @@ impl Coalescible for Value { | |||
fn coalesce(self, other: Self, o: Order) -> Self { | |||
use {Value::Dict as D, Value::Array as A, Order::*}; | |||
match (self, other, o) { | |||
(D(t, a), D(_, b), Join | Adjoin) | (D(_, a), D(t, b), Merge | Admerge) => D(t, a.coalesce(b, o)), | |||
(D(t, a), D(_, b), Join | Adjoin | Zipjoin) | (D(_, a), D(t, b), Merge | Admerge | Zipmerge) => D(t, a.coalesce(b, o)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long. Lines should never exceed 100 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I split the join and merge cases into separate lines, I think this is more readable than any wrapping option.
src/value/value.rs
Outdated
/// "duck" => Value::from(vec![ | ||
/// map!{ | ||
/// "pasta" => 42usize, | ||
/// }, | ||
/// map!{ | ||
/// "pizza" => 229usize, | ||
/// }, | ||
/// ]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make one of the other values a vec![]
? The smaller this value is, the easier the example is to parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would involve either the array being fairly deeply nested and/or having an array of mixed types. I instead opted to remove one value from each top-level key.
pub(crate) fn is_none(&self) -> bool { | ||
matches!(self, Value::Empty(_, Empty::None)) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed to remove all of the special-casing.
64c5310
to
7a30056
Compare
7a30056
to
83678de
Compare
Round 1. Once reviewed, these changes should be merged into the appropriate commits to produce a clean history.
@SergioBenitez I fixed all the issues with obvious solutions, I think the rest warrant further discussion. The big benefit with the zip- strategies is the handling of "there is no value here" values, without it the Env provider would not work correctly for This also touches on #112, where the user wanted a way to specify "there is no value here", such that So we need to differentiate between these three cases when
Thus I think we do need something like
|
This PR contains a few related changes for various issues:
Value::find()
(Allow Value::find to traverse arrays #92)