LukasKalbertodt / litrs

Parsing and inspecting Rust literals (particularly useful for proc macros)
https://docs.rs/litrs
Apache License 2.0
42 stars 5 forks source link

Community Feedback #1

Open LukasKalbertodt opened 3 years ago

LukasKalbertodt commented 3 years ago

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.

jhpratt commented 3 years ago

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).

LukasKalbertodt commented 3 years ago

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!

jhpratt commented 3 years ago

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

LukasKalbertodt commented 3 years ago

Yeah TokenTree also makes sense. Sweet, thanks.

LukasKalbertodt commented 3 years ago

@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!

wycats commented 3 years ago

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

xiyuzhai commented 1 year ago

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!!!