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

Use unindent as extension function #30

Closed
la10736 opened this issue Aug 13, 2019 · 3 comments
Closed

Use unindent as extension function #30

la10736 opened this issue Aug 13, 2019 · 3 comments

Comments

@la10736
Copy link
Contributor

la10736 commented Aug 13, 2019

It would be great to have an extension function for unindent(). I'm using it in tests and use unindent() as postfix instead of function call improve test readability:

assert_eq!(tests, r#"
                    case_1_1_1
                    case_1_1_2
                    case_1_2_1
                    case_1_2_2
                    case_2_1_1
                    case_2_1_2
                    case_2_2_1
                    case_2_2_2"#.unindent())

It is better than surround string by unindent() function.

Just I'm not sure if is better to have two different traits for unindent and unindent_bytes or use just one for both. In the last case I need to write every single implementation (&str, String, &[u8]...) but in the first case I can do just two impl for AsRef<str> and AsRef<[u8]>.

If it is ok for you I can implement it...

@dtolnay
Copy link
Owner

dtolnay commented Aug 13, 2019

Thanks, I would accept a PR for this.

@la10736
Copy link
Contributor Author

la10736 commented Aug 13, 2019

Do you prefer just one trait or two?

@dtolnay
Copy link
Owner

dtolnay commented Aug 13, 2019

I would prefer one extension trait called unindent::Unindent.

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