mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
servo: Merge #6950 - Add a comment to explain the struct pattern trick (from servo:struct-pattern); r=glennw
https://github.com/servo/servo/issues/6912#issuecomment-127429643 Source-Repo: https://github.com/servo/servo Source-Revision: 0565df859684560b525b0361476d334f79db8474
This commit is contained in:
parent
9c986f84a3
commit
4f271271e1
@ -103,6 +103,8 @@ impl<T: HeapSizeOf> HeapSizeOf for Option<T> {
|
||||
|
||||
impl HeapSizeOf for url::Url {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
// Using a struct pattern without `..` rather than `foo.bar` field access
|
||||
// makes sure this will be updated if a field is added.
|
||||
let &url::Url { ref scheme, ref scheme_data, ref query, ref fragment } = self;
|
||||
scheme.heap_size_of_children() +
|
||||
scheme_data.heap_size_of_children() +
|
||||
@ -122,6 +124,8 @@ impl HeapSizeOf for url::SchemeData {
|
||||
|
||||
impl HeapSizeOf for url::RelativeSchemeData {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
// Using a struct pattern without `..` rather than `foo.bar` field access
|
||||
// makes sure this will be updated if a field is added.
|
||||
let &url::RelativeSchemeData { ref username, ref password, ref host,
|
||||
ref port, ref default_port, ref path } = self;
|
||||
username.heap_size_of_children() +
|
||||
|
Loading…
Reference in New Issue
Block a user