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 Source::with_line_offset function #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olson-dan
Copy link

Hi,

Here's the PR discussed here: #6

I've cleaned it up a little to remove the auto-formatting and ensure that Source::with_line_offset uses AsRef<str>.

}
}
}

impl Source {
/// Add an offset to the line number displayed in the message.
pub fn with_line_offset<S: AsRef<str>>(source: S, line_offset: usize) -> Source {
Source { line_offset, ..Source::from(source) }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_x might make more sense as a builder pattern (i.e: takes self, returns Self). This would be strictly more powerful.

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

Successfully merging this pull request may close these issues.

None yet

4 participants