add line address, change u32 for usize in Address

remove one useless print too
This commit is contained in:
rick 2023-04-10 23:16:38 +02:00
parent 1de2f2c5e0
commit e18f954cb0
Signed by: Rick
GPG key ID: 5CBE8779CD27BCBA

View file

@ -1,17 +1,18 @@
use std::str::FromStr;
#[derive(Debug)] #[derive(Debug)]
pub enum Address { pub enum Address {
Actual, Actual,
Last, Last,
Line(u32), Line(usize),
FromStartTo(u32), FromStartTo(usize),
FromToEnd(u32), FromToEnd(usize),
FromTo(u32, u32), FromTo(usize, usize),
Null, Null,
} }
impl Address { impl Address {
pub fn is_null(&self) -> bool { pub fn is_null(&self) -> bool {
println!("{:?}", self);
match self { match self {
Self::Null => true, Self::Null => true,
_ => false, _ => false,
@ -26,6 +27,8 @@ pub fn parse_address(addr: &str) -> Address {
if addr.is_empty() { if addr.is_empty() {
Address::Actual Address::Actual
} else if let Ok(l) = usize::from_str(addr) {
Address::Line(l)
} else { } else {
match addr { match addr {
"." => Address::Actual, "." => Address::Actual,
@ -37,8 +40,6 @@ pub fn parse_address(addr: &str) -> Address {
#[derive(Debug)] #[derive(Debug)]
pub enum Command { pub enum Command {
ChangeAddr(Address),
Append(Address), Append(Address),
Insert(Address), Insert(Address),
Change(Address), Change(Address),