0

Fix some typos in StructTraits examples

- Stray semicolon at the end of a function definition
- Missing closing brace in struct definition
- Unnecessarily decomposing a string into ptr/length when strings become
  string_views for free
- Add braces to single-line if now that that's the preferred style

Change-Id: I55a81402e639c13f23dabe57f714adebae302c03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6431486
Commit-Queue: Fred Shih <ffred@chromium.org>
Reviewed-by: Fred Shih <ffred@chromium.org>
Auto-Submit: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1442468}
This commit is contained in:
David Benjamin
2025-04-03 15:45:15 -07:00
committed by Chromium LUCI CQ
parent f5ab41f56c
commit 892bf74972

@ -1480,12 +1480,13 @@ namespace mojo {
bool StructTraits<gfx::mojom::RectDataView, gfx::Rect>::Read(
gfx::mojom::RectDataView data,
gfx::Rect* out_rect) {
if (data.width() < 0 || data.height() < 0)
if (data.width() < 0 || data.height() < 0) {
return false;
}
out_rect->SetRect(data.x(), data.y(), data.width(), data.height());
return true;
};
}
} // namespace mojo
```
@ -1520,9 +1521,10 @@ struct StructTraits<url::mojom::UrlDataView, GURL> {
!r.is_valid()) {
return std::string_view();
}
return std::string_view(r.possibly_invalid_spec().c_str(),
r.possibly_invalid_spec().length());
return r.possibly_invalid_spec();
}
};
} // namespace mojo
```