Skip to content

Commit

Permalink
[agx - Rust] Implement Add for RectInsets
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 12, 2024
1 parent 008653f commit c9c9027
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/todo.md
Expand Up @@ -320,4 +320,6 @@ Auto install LLD link? Or llvm with brew? Need lld-link for the UEFI build
// different on each OS), we could have an enum to model the possible font options, with an escape hatch
// 'get from this path' variant, which could perhaps hold different values depending on the OS.

Better errors when you try to use (ex.) printf before the VMM has initialized
Better errors when you try to use (ex.) printf before the VMM has initialized

Perhaps the VM allocator could inspect the call stack to ensure no one is trying to call it from the PMM? Could only be enabled on debug builds?
14 changes: 14 additions & 0 deletions rust_programs/agx_definitions/src/lib.rs
Expand Up @@ -464,6 +464,20 @@ impl RectInsets {
}
}

impl Add for RectInsets {
type Output = RectInsets;

fn add(self, rhs: RectInsets) -> Self::Output {
// TODO(PT): The side order here should match the constructor passed to inset_by()...
RectInsets::new(
self.left + rhs.left,
self.top + rhs.top,
self.right + rhs.right,
self.bottom + rhs.bottom,
)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Ord, PartialOrd, Eq)]
pub struct Rect {
pub origin: Point,
Expand Down

0 comments on commit c9c9027

Please sign in to comment.