My code:
fn request_add(request: &mut Request, collection_name: &\'static str) -> Fallible>
where
T: ser
Because it's an API guideline:
Generic reader/writer functions take
R: Read
andW: Write
by value (C-RW-VALUE)The standard library contains these two impls:
impl<'a, R: Read + ?Sized> Read for &'a mut R { /* ... */ } impl<'a, W: Write + ?Sized> Write for &'a mut W { /* ... */ }
That means any function that accepts
R: Read
orW: Write
generic parameters by value can be called with amut
reference if necessary.
You either call Read::by_ref or just take a reference yourself:
serde_json::from_reader(&mut request.body)
serde_json::from_reader(request.body.by_ref())
See also: