Skip to content

Commit

Permalink
Reduce Error size with Box<str>
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed May 19, 2024
1 parent c3454fe commit 0715c33
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 0715c33

Please sign in to comment.