-
Notifications
You must be signed in to change notification settings - Fork 172
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
Pass OwnedRpcParams to async methods #410
Conversation
Might have to mess a bit more with lifetimes, or do an extra quasi iterator for parsing using let a: &str = params.next();
let b: &str = params.next(); // a is using a lifetime that's bound to a mutable borrow, hence borrowck forbids this thinking it's aliasing |
let params = RpcParams::new(Some(r#"["foo", "bar"]"#)); | ||
let mut seq = params.sequence(); | ||
|
||
assert_eq!(seq.next::<&str>().unwrap(), "foo"); | ||
assert_eq!(seq.next::<&str>().unwrap(), "bar"); | ||
assert!(seq.next::<&str>().is_err()); |
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 is the important test and the reason for adding a separate struct for handling sequence parsing: seq
borrows the json from params
, which allows it to produce slices with that lifetime, while &mut self
borrows are transient.
Test that parse() works after calling sequence()
Pass
OwnedRpcParams
to async methods to allow deserializing to happen asynchronously as well.Closes #408