Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper for strings #23

Open
piegamesde opened this issue Sep 28, 2021 · 2 comments
Open

Add helper for strings #23

piegamesde opened this issue Sep 28, 2021 · 2 comments

Comments

@piegamesde
Copy link

Usually, one does not want to check individual characters, but strings as a whole. Since this results in repeating the same boilerplate over and over, how about providing a direct mechanism on &str for this purpose? I'm thinking of three methods: starts_with_xid_start, is_xid_continue, is_xid_ident. I'm fine with them being either standalone methods or trait extensions to str.

@lunabunn
Copy link

What benefit does s.is_xid_continue() provide over the only slightly longer s.chars().all(UnicodeXID::is_xid_continue)?

@piegamesde
Copy link
Author

s.chars().all(UnicodeXID::is_xid_continue) is not only twice as long, which I would not call insignificant, it is also less concise to read (one mental operation vs three).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants