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

The "Efficient method" and "Beginner friendly method" seem essentially the same here. #1677

Closed
woofyzhao opened this issue Feb 8, 2023 · 3 comments

Comments

@woofyzhao
Copy link
Contributor

https://doc.rust-lang.org/rust-by-example/std_misc/file/read_lines.html

They are actually the same except that the "Efficient method" wraps the Lines object in a Result...

@woofyzhao
Copy link
Contributor Author

@frittex14 Please take a look at this. It does not seem to have anything to do with efficiency.

@frittex14
Copy link
Contributor

Hey,
The reason for this change was to give Rust beginners code that's simple to understand. I use 'efficient' here to mean things like good code organization, readability, and being in line with how Rust is usually written, not how fast it runs. If it's bugging you, you can change it to "This method is NOT idiomatic." or something similar, but I still reckon using 'efficient' makes it easiest to explain to someone new to Rust, or programming in general. Hope this helps ;)

@woofyzhao
Copy link
Contributor Author

woofyzhao commented Feb 9, 2023

Hey, The reason for this change was to give Rust beginners code that's simple to understand. I use 'efficient' here to mean things like good code organization, readability, and being in line with how Rust is usually written, not how fast it runs. If it's bugging you, you can change it to "This method is NOT idiomatic." or something similar, but I still reckon using 'efficient' makes it easiest to explain to someone new to Rust, or programming in general. Hope this helps ;)

Oh, then it's the bottom line "This process is more efficient than creating a String in memory especially working with larger files." that made me confused.

Thank you for your explanation.

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