add line address, change u32 for usize in Address
remove one useless print too
This commit is contained in:
parent
1de2f2c5e0
commit
e18f954cb0
1 changed files with 8 additions and 7 deletions
15
src/enums.rs
15
src/enums.rs
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue