Things we did:
- Response API
- Wrapped
net_traits::response::Response’s headers (hyper::headers) withRcandRefCell. - Fought with the borrow checker the whole day. Implemented
clonefornet_traits::response::Responseand dealt with side-effects of using internalRctypes… x_X
- Wrapped
- Request API
- Decided not to file a spec issue, but clarified the reasoning for the additional step in
request.rsin 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
HEADof pre-rebase, andgit reset --hardto thatHEAD. -
You cannot modify a field that is in a borrowed context. This is a sample code.
fn Referrer(&self) -> USVString {
let r = self.request.borrow();
let referrer = r.referer.borrow();
USVString(match &*referrer {
&Referer::NoReferer => String::from("no-referrer"),
&Referer::Client => String::from("client"),
&Referer::RefererUrl(ref u) => {
let u_c = u.clone();
u_c.into_string()
}
})
}- A few things to notice in the code:
- The reason there are
randreferreris 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
matchifreferrerdoes not have&*, it will throw a type mismatch error. This is becausereferreris aRef<>type, and it is trying to match againstRefererenum. - So, you may want to dereference (
*referrer) so that you can usereferreras aRefererenum type through deref coercions. However, that will be trying to movereferrerout of borrowed context. - And therefore, you make it explicit that
referreris borrowed object, while dereferencing it:&*referrer - Similarly, in the last match arm,
u_cis created becauseuis aref. If you were to writeu.into_string(), you will be trying to moveuout of borrowed context.
- The reason there are
TODO:
- Response API:
- Deal with current build errors (now the side-effects of wrapping headers with
RcandRefCellare appearing in places like fetch/methods.rs, uh oh) - And then modify
net_traits::request::Requestanddom::headersas well…… - Implement JSTraceable for
RefCellindom::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.