2022-09-07 15:23:37 +00:00
|
|
|
use std::os::raw::*;
|
|
|
|
|
|
|
|
#[repr(C)]
|
2022-09-07 15:41:32 +00:00
|
|
|
#[derive(Default)]
|
2022-09-07 15:23:37 +00:00
|
|
|
pub struct Position {
|
|
|
|
x: c_int,
|
|
|
|
y: c_int,
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:29:09 +00:00
|
|
|
#[repr(C)]
|
2022-09-07 15:41:32 +00:00
|
|
|
#[derive(Default)]
|
2022-09-07 15:29:09 +00:00
|
|
|
pub struct Sizes {
|
|
|
|
width: c_int,
|
|
|
|
height: c_int,
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:23:37 +00:00
|
|
|
impl Position {
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn new(x: c_int, y: c_int) -> Self {
|
2022-09-07 15:23:37 +00:00
|
|
|
Self { x, y }
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn x(&self) -> c_int {
|
2022-09-07 15:23:37 +00:00
|
|
|
self.x
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn y(&self) -> c_int {
|
2022-09-07 15:23:37 +00:00
|
|
|
self.y
|
|
|
|
}
|
|
|
|
}
|
2022-09-07 15:29:09 +00:00
|
|
|
|
|
|
|
impl Sizes {
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn new(width: c_int, height: c_int) -> Self {
|
2022-09-07 15:29:09 +00:00
|
|
|
Self { width, height }
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn width(&self) -> c_int {
|
2022-09-07 15:29:09 +00:00
|
|
|
self.width
|
|
|
|
}
|
|
|
|
|
2022-09-07 15:31:42 +00:00
|
|
|
pub fn height(&self) -> c_int {
|
2022-09-07 15:29:09 +00:00
|
|
|
self.height
|
|
|
|
}
|
|
|
|
}
|
2022-09-07 15:41:32 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn position_default() {
|
|
|
|
assert_eq!(Position::default().x(), 0);
|
|
|
|
assert_eq!(Position::default().y(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sizes_default() {
|
|
|
|
assert_eq!(Sizes::default().width(), 0);
|
|
|
|
assert_eq!(Sizes::default().height(), 0);
|
|
|
|
}
|
|
|
|
}
|