13

Rust: Finite State Machine

 3 years ago
source link: https://www.youtube.com/watch?v=whN36JVUd6A
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
0:04 / 20:35

Rust: Finite State Machine

450 views
Premiered Aug 20, 2021

11 Comments

Sort by
default-user=s48-c-k-c0x00ffffff-no-rj
Add a public comment...
Well, I'm looking at re-implementing my parser from Go to Rust so I'm bit new to Rust. But video confused me. Why use bytes? I've seen you can convert string to char vectors. Isn't that better approach for handling different languages?

1 day ago (edited)

Took me a while to understand what right and left quote meant 😅 Left quote: sentence(s) ending quote Right quote: sentence(s) starting quote And in 'process' fn: you're pushing all the characters inside the quotes to buffer.

(Did I get it right?)

Read more 2 days ago

It's been a while since I used state machines! I enjoyed the refresher =) Your implementation was great! It was also cool to see you handle Chinese characters. I do think you could have simplified the state machine to two states (e.g. InQuote and NotInQuote) rather than three. Something like this: case InQuote: if is_right_quote then flush buffer and state -> NotInQuote else add to buffer NotInQuote: if is_left_quote then state -> InQuote else continue

Read more 2 days ago


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK