style(rect): use plus operator for offset (#2251)

## Summary
Use `+` operator to move `Rect` by an `Offset` as added
[here](https://github.com/ratatui/ratatui/pull/1596).

Includes change to use `Offset::new()` in place of `Offset { ... }`
This commit is contained in:
Paul Harrison 2025-12-02 07:47:03 -07:00 committed by GitHub
parent cb85c8eb4e
commit 345f47e044
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -72,7 +72,7 @@ fn outer() {
#[test]
fn offset() {
let base = Rect::new(2, 2, 5, 3);
let moved = base.offset(Offset { x: 4, y: 2 });
let moved = base + Offset::new(4, 2);
let mut buf = Buffer::empty(Rect::new(0, 0, 15, 10));
Filled { symbol: "" }.render(base, &mut buf);

View File

@ -1951,18 +1951,18 @@ mod tests {
let mut offset = Offset::ZERO;
for (border_type_1, border_type_2) in iproduct!(border_types, border_types) {
let title = format!("{border_type_1} + {border_type_2}");
let title_area = Rect::new(0, 0, 43, 1).offset(offset);
let title_area = Rect::new(0, 0, 43, 1) + offset;
title.render(title_area, &mut buffer);
offset.y += 1;
for (rect_1, rect_2) in rects {
Block::bordered()
.border_type(border_type_1)
.merge_borders(strategy)
.render(rect_1.offset(offset), &mut buffer);
.render(rect_1 + offset, &mut buffer);
Block::bordered()
.border_type(border_type_2)
.merge_borders(strategy)
.render(rect_2.offset(offset), &mut buffer);
.render(rect_2 + offset, &mut buffer);
}
offset.y += 9;
}