fn neighbour_of(&self, target: KeypadButton, direction: Direction) -> Option<KeypadButton> {
            self.buttons_to_positions.get(&target).and_then(|&position| {
                let next_position = match direction {
                    Direction::Up => Point { y: position.y - 1, ..position },
                    Direction::Right => Point { x: position.x + 1, ..position },
                    Direction::Down => Point { y: position.y + 1, ..position },
                    Direction::Left => Point { x: position.x - 1, ..position },
                };
                self.positions_to_buttons.get(&next_position).and_then(|&button| Some(button))
            })
        }
/// Find the button near the given target KeypadButton.
///
/// Returns None if target is not in self or there is no button in the given `Direction`
/// from target, `Some` button otherwise.
Find the button near the given target KeypadButton.
Returns None if target is not in self or there is no button in the given `Direction`
from target, `Some` button otherwise.
Find the button near the given target KeypadButton . Returns None if target is not in self or there is no button in the given ` Direction ` from target ` Some ` button otherwise .
fn neighbour_of(&self, target: KeypadButton, direction: Direction) -> Option<KeypadButton> {
            self.buttons_to_positions.get(&target).and_then(|&position| {
                let next_position = match direction {
                    Direction::Up => Point { y: position.y - 1, ..position },
                    Direction::Right => Point { x: position.x + 1, ..position },
                    Direction::Down => Point { y: position.y + 1, ..position },
                    Direction::Left => Point { x: position.x - 1, ..position },
                };
                self.positions_to_buttons.get(&next_position).and_then(|&button| Some(button))
            })
        }
fn neighbour_of ( & self , target : KeypadButton , direction : Direction ) -> Option < KeypadButton > { self . buttons_to_positions . get ( & target ) . and_then ( | & position | { let next_position = match direction { Direction :: Up => Point { y : position . y - 1 , .. position } , Direction :: Right => Point { x : position . x + 1 , .. position } , Direction :: Down => Point { y : position . y + 1 , .. position } , Direction :: Left => Point { x : position . x - 1 , .. position } , } ; self . positions_to_buttons . get ( & next_position ) . and_then ( | & button | Some ( button ) ) } ) }
Find the button near the given target KeypadButton.
Find the button near the given target KeypadButton .
&self
target
KeypadButton
direction
Direction
&self
target
KeypadButton
direction
Direction