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