Skip to main content

2 posts tagged with "error"

View All Tags

Vim Practice

· 2 min read
forfd8960
Author

Delete words backward

  • delete 1 word: db
  • delete n words: d<number>b

Delete word forward

  • dw: delete one word.

Change the current word inpalce

  • cw: chagne the current word

How to Customize your Own Error Type in Rust

· 2 min read
forfd8960
Author

Suppose you are writing a lexical analyzer(Lexer), and you want return some customized errors while the lexer scan tokens, and there are 3 possibel error will happens:

  • Not Supported Tokens.
  • Invalid Strings.
  • Invalid Nums.

SO you can define the errors with a rust enum:

pub enum LexerError {
InvalidToken(char),
InvalidString(String),
InvalidNum(String),
}