pub struct Move {
pub origin: Vector,
pub target: Vector,
}Fields§
§origin: Vector§target: VectorImplementations§
Source§impl Move
impl Move
Sourcepub fn new(origin: Vector, target: Vector) -> Self
pub fn new(origin: Vector, target: Vector) -> Self
Examples found in repository?
examples/example.rs (line 7)
3fn main() {
4 let mut game = GameState::new();
5
6 // Move the central pawn forward one space
7 game.try_move(Move::new(Vector::new(-1, -1), Vector::new(0, 0)))
8 .unwrap();
9
10 // An invalid move fails and tells you why
11 let err = game.try_move(Move::new(Vector::new(-1, -1), Vector::new(0, 0)))
12 .unwrap_err();
13
14 println!("{}", err);
15 // Prints `attempt to move from (-1, -1), but there isn't a piece there``
16}Trait Implementations§
Source§impl FromWasmAbi for Move
impl FromWasmAbi for Move
Source§impl IntoWasmAbi for Move
impl IntoWasmAbi for Move
Source§impl LongRefFromWasmAbi for Move
impl LongRefFromWasmAbi for Move
Source§impl OptionFromWasmAbi for Move
impl OptionFromWasmAbi for Move
Source§impl OptionIntoWasmAbi for Move
impl OptionIntoWasmAbi for Move
Source§impl RefFromWasmAbi for Move
impl RefFromWasmAbi for Move
Source§impl RefMutFromWasmAbi for Move
impl RefMutFromWasmAbi for Move
Source§impl TryFromJsValue for Move
impl TryFromJsValue for Move
Source§impl VectorFromWasmAbi for Move
impl VectorFromWasmAbi for Move
Source§impl VectorIntoWasmAbi for Move
impl VectorIntoWasmAbi for Move
impl Copy for Move
impl SupportsConstructor for Move
impl SupportsInstanceProperty for Move
impl SupportsStaticProperty for Move
Auto Trait Implementations§
impl Freeze for Move
impl RefUnwindSafe for Move
impl Send for Move
impl Sync for Move
impl Unpin for Move
impl UnwindSafe for Move
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.