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

Reduce Error size with Box<str> #1053

Merged
merged 1 commit into from
May 20, 2024
Merged
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
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