#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Viewport {
width: u32,
height: u32,
}
impl Viewport {
pub fn new(width: u32, height: u32) -> Self {
Self { width, height }
}
pub fn width(&self) -> u32 {
self.width
}
pub fn height(&self) -> u32 {
self.height
}
}
#[cfg(test)]
mod tests {
use crate::test_utils::*;
use super::*;
#[test]
fn new_stores_dimensions() {
let vp = Viewport::new(1280, 720);
assert_eq!(vp.width(), 1280);
assert_eq!(vp.height(), 720);
}
#[test]
fn trait_send() {
assert_send::<Viewport>();
}
#[test]
fn trait_sync() {
assert_sync::<Viewport>();
}
#[test]
fn trait_unpin() {
assert_unpin::<Viewport>();
}
}