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

fix inconsistent naming and functions provided #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,14 @@ pub struct ReportBuilder<'a, S: Span> {
}

impl<'a, S: Span> ReportBuilder<'a, S> {
/// Give this report a numerical code that may be used to more precisely look up the error in documentation.
pub fn with_code<C: fmt::Display>(mut self, code: C) -> Self {
/// Set the numerical code for this report that may be used to more precisely look up the error in documentation.
pub fn set_code<C: fmt::Display>(&mut self, code: C) {
self.code = Some(format!("{:02}", code));
}

/// Set the numerical code for this report that may be used to more precisely look up the error in documentation.
pub fn with_code<C: fmt::Display>(mut self, code: C) -> Self {
self.set_code(code);
self
}

Expand All @@ -275,7 +280,7 @@ impl<'a, S: Span> ReportBuilder<'a, S> {
self.msg = Some(msg.to_string());
}

/// Add a message to this report.
/// Set the message of this report.
pub fn with_message<M: ToString>(mut self, msg: M) -> Self {
self.msg = Some(msg.to_string());
self
Expand Down Expand Up @@ -330,8 +335,13 @@ impl<'a, S: Span> ReportBuilder<'a, S> {
}

/// Use the given [`Config`] to determine diagnostic attributes.
pub fn with_config(mut self, config: Config) -> Self {
pub fn set_config(&mut self, config: Config) {
self.config = config;
}

/// Use the given [`Config`] to determine diagnostic attributes.
pub fn with_config(mut self, config: Config) -> Self {
self.set_config(config);
self
}

Expand Down
Loading