#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct MeasureResult {
pub width: f32,
pub height: f32,
pub baseline: Option<f32>,
}
impl MeasureResult {
pub const fn new(width: f32, height: f32) -> Self {
Self {
width,
height,
baseline: None,
}
}
pub const fn with_baseline(width: f32, height: f32, baseline: f32) -> Self {
Self {
width,
height,
baseline: Some(baseline),
}
}
#[inline]
pub const fn baseline(mut self, baseline: f32) -> Self {
self.baseline = Some(baseline);
self
}
#[inline]
pub const fn into_tuple(self) -> (f32, f32) {
(self.width, self.height)
}
}
impl From<(f32, f32)> for MeasureResult {
fn from((width, height): (f32, f32)) -> Self {
Self::new(width, height)
}
}
impl From<MeasureResult> for (f32, f32) {
fn from(result: MeasureResult) -> Self {
(result.width, result.height)
}
}