LukasKalbertodt / litrs

Parsing and inspecting Rust literals (particularly useful for proc macros)

Home Page:https://docs.rs/litrs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Community Feedback

LukasKalbertodt opened this issue · comments

Do you have any opinions, complaints, suggestions, ideas, ... about litrs? Let me know! This issue is less formal and more relaxed than "normal issues", so feel free to just dump your thoughts here.

I haven't had a chance to test this out yet, but I think having TryFrom impls could be quite convenient. It would avoid the match with a single type expected with the rest panicking (.expect could be used or some other error handling).

I assume you are talking about TryFrom<X> for Y where Y is litrs::StringLit, litrs::IntegerLit and so on? That's a great idea! What could X be then? proc_macro[2]::Literal for sure. But also String and &str? Probably all four options, right?

EDIT: no, I wasn't thinking straight. The &str and String cases are already covered by parse, of course. But yeah, for the proc_macro[2]::Literal types it makes perfect sense!

I was imagining proc_macro::Literal and proc_macro::TokenTree (along with proc_macro2 equivalents).

Yeah TokenTree also makes sense. Sweet, thanks.

@jhpratt I just published 0.2.0 which contains a large number of From and TryFrom impls. It was actually more work than expected, but I think they really improve the library and make lots of real world uses cases easier. Thanks for the suggestion again!

@LukasKalbertodt I stumbled across this crate and really love it. Thank you so much for doing this!

I'm working on my own programming language https://github.com/xiyuzhai-husky-lang/husky/. I shall work out the literal part of my language based on this project. Amazing work!!!