Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt;
- #[derive(Debug, Copy, Clone, PartialEq)]
- pub struct Location {
- pub row: u32,
- pub column: u32,
- }
- impl Location {
- pub fn new(row: u32, column: u32) -> Location {
- Location {
- row: row,
- column: column,
- }
- }
- pub fn bump_row(&self) -> Location {
- Location { row: self.row + 1, column: 1 }
- }
- pub fn bump_column(&self) -> Location {
- Location { row: self.row, column: self.column + 1 }
- }
- }
- impl fmt::Display for Location {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "({}, {})", self.row, self.column)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement