Skip to content

Commit

Permalink
Merge pull request #1053 from kornelski/smallerr
Browse files Browse the repository at this point in the history
Reduce Error size with Box<str>
  • Loading branch information
ehuss authored May 20, 2024
2 parents c3454fe + 0715c33 commit 949aa49
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{raw, ErrorClass, ErrorCode};
pub struct Error {
code: c_int,
klass: c_int,
message: String,
message: Box<str>,
}

impl Error {
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Error {

unsafe fn from_raw(code: c_int, ptr: *const raw::git_error) -> Error {
let message = CStr::from_ptr((*ptr).message as *const _).to_bytes();
let message = String::from_utf8_lossy(message).into_owned();
let message = String::from_utf8_lossy(message).into_owned().into();
Error {
code,
klass: (*ptr).klass,
Expand All @@ -86,7 +86,7 @@ impl Error {
Error {
code: raw::GIT_ERROR as c_int,
klass: raw::GIT_ERROR_NONE as c_int,
message: s.to_string(),
message: s.into(),
}
}

Expand Down

0 comments on commit 949aa49

Please sign in to comment.