Things we did:
- Our blog post is published!
- Headers API
- Simplified Headers constructor and
new
function, and addedfill
function. - Started looking into how I should modify WebIDL.py to allow bindings generator to support default ByteString values.
- Simplified Headers constructor and
- Request API
Things we learned:
Lifetime Error
Say you have a one line of code that is:
If you try to compile it, you may get an error that looks like:
The reason is that to_lower()
gives back a String, and as_str()
tries to give a reference to that String created by to_lower()
. However, that String would not exist anymore because it was consumed by as_str()
and therefore, the compiler throws an error saying that the borrowed value doesn’t live long enough.
To fix this issue, the compiler suggests using let
binding to increase its life time. In other words, the one line code can be expanded as following:
This way, as_str()
can return a reference to the String (method_lower
) which would exist in its scope, i.e. between curly brackets.
Similarly, this won’t compile and will throw lifetime errors:
Again, it would try to borrow integrity_metadata
from self.request
which would be transformed to Ref<'_, net_traits::request::Request>
after self.request.borrow()
. This error can be resolved by expanding the code above to this:
TODO:
- Response:
- Continue to work on Bindings generator.
- Work on Constructor.
- Request:
- Wait for more comments.
- General:
- Finish up writing blog post, intro to Rust’s ownership.