Things we did:
- Response API
- Wrapped
net_traits::response::Response
’s headers (hyper::headers
) withRc
andRefCell
. - Fought with the borrow checker the whole day. Implemented
clone
fornet_traits::response::Response
and dealt with side-effects of using internalRc
types… x_X
- Wrapped
- Request API
- Decided not to file a spec issue, but clarified the reasoning for the additional step in
request.rs
in the comments. - Made the code more readable, and removed unnecessary parts.
- jdm gave me the permission to squash! Woohoo! Merge is near.
- Decided not to file a spec issue, but clarified the reasoning for the additional step in
Things we learned:
-
Parentheses are useful! Long story short, wrapping parentheses around
(*gadget1.owner)
applies the deref*
to justgadget1.owner
, which is just what I needed. :) -
Reflog is what git uses to keep track of updates to the tip of branches, including those that are invisible on git log! This acts as a great safety net. For example, if you want to undo git rebase, you can find the
HEAD
of pre-rebase, andgit reset --hard
to thatHEAD
. -
You cannot modify a field that is in a borrowed context. This is a sample code.
- A few things to notice in the code:
- The reason there are
r
andreferrer
is that if it’s written into one line (let r_referrer = self.request.borrow().referer.borrow()
), it will throw a life time error. See here. - In
match
ifreferrer
does not have&*
, it will throw a type mismatch error. This is becausereferrer
is aRef<>
type, and it is trying to match againstReferer
enum. - So, you may want to dereference (
*referrer
) so that you can usereferrer
as aReferer
enum type through deref coercions. However, that will be trying to movereferrer
out of borrowed context. - And therefore, you make it explicit that
referrer
is borrowed object, while dereferencing it:&*referrer
- Similarly, in the last match arm,
u_c
is created becauseu
is aref
. If you were to writeu.into_string()
, you will be trying to moveu
out of borrowed context.
- The reason there are
TODO:
- Response API:
- Deal with current build errors (now the side-effects of wrapping headers with
Rc
andRefCell
are appearing in places like fetch/methods.rs, uh oh) - And then modify
net_traits::request::Request
anddom::headers
as well…… - Implement JSTraceable for
RefCell
indom::Headers
- And then finally work on dom::Response!
- Deal with current build errors (now the side-effects of wrapping headers with
- Request API:
- If merge happens, start working on making Headers iterable based on jdm’s PR.
- General:
- Finish up writing blog post, intro to Rust’s ownership.