Implement Default for Location

This commit is contained in:
harupy 2023-01-05 22:48:47 +09:00
parent 7f552e4594
commit 2dfd053bed
3 changed files with 10 additions and 4 deletions

View file

@ -1,12 +1,18 @@
use serde::{Deserialize, Serialize};
/// Sourcecode location.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Location {
pub(super) row: u32,
pub(super) column: u32,
}
impl Default for Location {
fn default() -> Self {
Self { row: 1, column: 0 }
}
}
impl Location {
pub fn fmt_with(
&self,