mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #6950 - servo:struct-pattern, r=glennw
Add a comment to explain the struct pattern trick. https://github.com/servo/servo/issues/6912#issuecomment-127429643 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6950) <!-- Reviewable:end -->
This commit is contained in:
commit
0565df8596
1 changed files with 4 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue