summaryrefslogtreecommitdiff
path: root/src/size.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-10-16 21:31:14 +0200
committerLaurenz <laurmaedje@gmail.com>2019-10-16 21:31:14 +0200
commitf2f05e07b0ff2d98e3c822b2618d02281ed1078c (patch)
tree6f4f8fa046af49c319d68c012a078f3489ab92aa /src/size.rs
parenta3c667895e4e5d5673931415397523b9615008d3 (diff)
Implement space extension (multipage) ➕
Diffstat (limited to 'src/size.rs')
-rw-r--r--src/size.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/size.rs b/src/size.rs
index c7439439..414fd855 100644
--- a/src/size.rs
+++ b/src/size.rs
@@ -131,6 +131,15 @@ impl Size2D {
}
}
+ /// Return a [`Size2D`] reduced by the paddings of the given box.
+ #[inline]
+ pub fn unpadded(&self, padding: SizeBox) -> Size2D {
+ Size2D {
+ x: self.x - padding.left - padding.right,
+ y: self.y - padding.top - padding.bottom,
+ }
+ }
+
/// Whether the given [`Size2D`] fits into this one, that is,
/// both coordinate values are smaller.
#[inline]
@@ -189,6 +198,11 @@ debug_display!(Size);
/// An error which can be returned when parsing a size.
pub struct ParseSizeError;
+error_type! {
+ err: ParseSizeError,
+ show: f => write!(f, "failed to parse size"),
+}
+
impl FromStr for Size {
type Err = ParseSizeError;