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

Getting a line slice requires two error checks #152

Open
jyn514 opened this issue Jan 15, 2020 · 0 comments
Open

Getting a line slice requires two error checks #152

jyn514 opened this issue Jan 15, 2020 · 0 comments

Comments

@jyn514
Copy link
Collaborator

jyn514 commented Jan 15, 2020

Presumably line_span always returns a valid span. However, the API requires you to check the error anyway:

    let line = file_db
        .line_span(file, start.line)
        .expect("line should be in bounds");
    println!("{}", file_db.source_slice(file, line).expect("line is still in bounds"));

I would like Files to get a new line_slice API which returns a Result<&str, LineIndexOutOfBoundsError> directly.

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