Skip to content

Commit

Permalink
Use a Cow<'static, str> for ParseError
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Feb 29, 2024
1 parent 039c276 commit 9a9ad42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
//! ```
use std::{
char,
error,
borrow::Cow,
char, error,
fmt::{self, Display},
fs::{File, OpenOptions},
io::{self, Read, Seek, SeekFrom, Write},
Expand Down Expand Up @@ -1169,7 +1169,7 @@ struct Parser<'a> {
pub struct ParseError {
pub line: usize,
pub col: usize,
pub msg: String,
pub msg: Cow<'static, str>,
}

impl Display for ParseError {
Expand Down Expand Up @@ -1243,7 +1243,7 @@ impl<'a> Parser<'a> {
}
}

fn error<U, M: Into<String>>(&self, msg: M) -> Result<U, ParseError> {
fn error<U, M: Into<Cow<'static, str>>>(&self, msg: M) -> Result<U, ParseError> {
Err(ParseError {
line: self.line + 1,
col: self.col + 1,
Expand Down

0 comments on commit 9a9ad42

Please sign in to comment.