remove TryFrom<&Origin<Pixels>> for Origin<Tiles>
This commit is contained in:
parent
eba1a6a6be
commit
373d0efe55
1 changed files with 0 additions and 43 deletions
|
|
@ -66,27 +66,6 @@ impl From<&Origin<Tiles>> for Origin<Pixels> {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&Origin<Pixels>> for Origin<Tiles> {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: &Origin<Pixels>) -> Result<Self, Self::Error> {
|
||||
let (x, x_rem) = (value.x / TILE_SIZE, value.x % TILE_SIZE);
|
||||
if x_rem != 0 {
|
||||
return Err(());
|
||||
}
|
||||
let (y, y_rem) = (value.y / TILE_SIZE, value.y % TILE_SIZE);
|
||||
if y_rem != 0 {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
x,
|
||||
y,
|
||||
phantom_data: PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<Unit: DisplayUnit> Default for Origin<Unit> {
|
||||
fn default() -> Self {
|
||||
Self::ZERO
|
||||
|
|
@ -105,28 +84,6 @@ mod tests {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn origin_pixel_to_tile() {
|
||||
let pixel: Origin<Pixels> = Origin::new(8, 16);
|
||||
let actual: Origin<Tiles> = Origin::try_from(&pixel).unwrap();
|
||||
let expected: Origin<Tiles> = Origin::new(1, 2);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn origin_pixel_to_tile_fail_y() {
|
||||
let pixel: Origin<Pixels> = Origin::new(8, 15);
|
||||
let _: Origin<Tiles> = Origin::try_from(&pixel).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn origin_pixel_to_tile_fail_x() {
|
||||
let pixel: Origin<Pixels> = Origin::new(7, 16);
|
||||
let _: Origin<Tiles> = Origin::try_from(&pixel).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn origin_add() {
|
||||
assert_eq!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue