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

Allow taking ownership of underlying line string #22

Open
jmagnuson opened this issue Nov 8, 2020 · 0 comments
Open

Allow taking ownership of underlying line string #22

jmagnuson opened this issue Nov 8, 2020 · 0 comments

Comments

@jmagnuson
Copy link
Owner

Fields are currently hidden behind ref-getter functions Line::source and Line::line. This was done to allow for flexibility in the underlying data types (especially source which should really sit behind an Arc) without breaking the exposed API. But it would be nice to at least provide a way for reusing the existing String allocated for the line. A few options:

  • Straight destructuring would require making the fields pub, which I would personally be okay with, except for the constraint mentioned above. Just line being public could work.

  • Line::into_parts -> (PathBuf, String) could work (and just clone the Path if/when it becomes Arc'ed).

  • Line::take_line -> String and panic, or return "".to_string on future calls to that or Line::line.

  • impl Into<String> for Line and just consume self to pass along line.

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

1 participant