-
Notifications
You must be signed in to change notification settings - Fork 5
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
refactoring errors & assignment #41
Conversation
This isn't ready yet - i still have a bunch of problems in the tests to fix. @asmello sorry this just now coming in and still not ready. I know you aren't blocked or in a hurry but I told you I was shooting for a Monday release. I'm hoping to get it wrapped up either tonight or tomorrow. I still need to:
|
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.
Just did a quick, non-exhaustive look to check the approach and added comments at random places. Will try to do a proper review ASAP, hopefully this Friday, if you have it ready by then.
src/assign.rs
Outdated
use serde_json::Value; | ||
use core::mem::replace; | ||
|
||
use crate::{Error, Pointer, PointerBuf}; | ||
use serde_json::{map::Entry, Map, Value}; | ||
use snafu::ResultExt; | ||
|
||
use crate::{assign_error, AssignError, Pointer, Token}; |
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.
We can have a separate discussion about this, but worth converging on a style for imports. I generally prefer to just merge everything into a single block, have never found it useful to separate them, but if you feel strongly against it, I can accept this convention too.
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.
Oh, I have no preference here. I'm lazy and let RA just do its thing. I'm definitely game for cleaning them up. I think there's even a lint that'll do it but its in nightly and was hit-or-miss for me when I tried it last.
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 think you're right. It's a bit unfortunate RA doesn't do exactly what I want by default, and there's no setting for it, but if you just merge the blocks once it'll keep them merged (even if you add more imports later). No need to consolidate this everywhere in this PR, but might as well start with it for new code.
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 think the untidiness of imports is amplified by all the unnecessary mods in the crate. Flattening it should make this a lot easier to keep in check.
I may try that lint again too. I was rather excited when I found it and super disappointed when it had some issues. While I find the utility of auto-imports super convenient, I do get annoyed and distracted by cluttered use blocks.
I went ahead and backed out |
I'm going to return a I dont know if its worth it. On one hand, more logic. On the other, i doubt i'm running out of fumes tonight but I'll circle back to this in the morning. |
@asmello hey, one of the quickcheck tests ( I'm not sure how I'm tripping it. #[quickcheck]
fn qc_intersection(base: PointerBuf, suffix_0: PointerBuf, suffix_1: PointerBuf) -> TestResult {
if suffix_0.first() == suffix_1.first() {
// base must be the true intersection
return TestResult::discard();
}
let mut a = base.clone();
a.append(&suffix_0);
let mut b = base.clone();
b.append(&suffix_1);
let isect = a.intersection(&b);
TestResult::from_bool(isect == base)
}
|
@asmello this method on fn partial_path(&self, suffix: &Self) -> &Self {
self.strip_suffix(suffix).expect("suffix came from self")
} |
it now simply calls A::assign
I think I know what it is. edit: fixed it, sorry about the mention. I wasn't sure why it randomly tripped and stayed consistent. I haven't used quickcheck before so it tripped me up. |
Added more tests for edit: done with that. |
I'm not super excited about the name of I also need to revisit what is passed in. This was just the min to get it working. Current pointer (path up to and including the current token) should probably be provided as well. If so, a |
Sounds reasonable! General comment: I think things are still a bit in flux (especially given the |
Done with a proper review! Generally LGTM, solid code! Mostly minor stuff. The amount of tests gives me confidence there's nothing too bad I may have missed. 😂 BTW - seems like I can't resolve my own comments! :\ |
Yea, I didn't have time to flush it out but wanted to get it pushed incase you had a chance to look. |
@asmello The more I worked on I walked it back and deleted The possibility of ambiguity is too high for this to be used in anything that demands precision. I think there's a better solution for more controlled assignment, perhaps something like an iterator of entries. I'm not quite sure yet. Either way, I don't think we need to solve it now. Neither of us are using this API and we haven't received feedback from anyone who is. I think it's best just to keep it simple with a helpful API that is only suitable for certain situations. Let me know what you think. I'll work on adding tests and documentation in the meantime. I'll merge this in if you're cool with abandoning the effort. |
That works for me. I'm always in favour of keeping things simple if there's no clear impetus for added complexity. |
Oh.. so I don't know how to handle including Should I enable |
Walking back the feature flags for this PR. |
was about to hit Squash and merge but hit this:
|
error
,Error
AssignError
ResolveError
DeleteError
Assign
,Resolve
,ResolveMut
,Delete
traits to now use associated types forValue
andError
MaybePointer
Assignment
Pointer::split_at
Assign::assign
to return the replaced value asOption<Assign::Value>