pub trait WithDimensions: Sized {
// Required method
fn set_dimensions(&mut self, width: u32, height: u32);
// Provided method
fn dimensions(self, width: u32, height: u32) -> Self { ... }
}Expand description
Trait for types that have configurable width/height dimensions.
Eliminates the 14+ identical dimensions() builder methods duplicated across
pmat visualization and trueno-viz chart types.
§Examples
use batuta_common::display::WithDimensions;
struct Chart { width: u32, height: u32 }
impl WithDimensions for Chart {
fn set_dimensions(&mut self, width: u32, height: u32) {
self.width = width;
self.height = height;
}
}
let chart = Chart { width: 80, height: 24 }.dimensions(120, 40);
assert_eq!(chart.width, 120);
assert_eq!(chart.height, 40);Required Methods§
Sourcefn set_dimensions(&mut self, width: u32, height: u32)
fn set_dimensions(&mut self, width: u32, height: u32)
Set the width and height on this type.
Provided Methods§
Sourcefn dimensions(self, width: u32, height: u32) -> Self
fn dimensions(self, width: u32, height: u32) -> Self
Builder method: set dimensions and return self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.