Skip to content

Commit

Permalink
style(sys): function-based cfg for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
muja committed Sep 8, 2024
1 parent 4120387 commit a434949
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions unrar_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,21 @@ impl OpenArchiveData {
}

impl OpenArchiveDataEx {
pub fn new(
#[cfg(target_os = "linux")] archive: *const c_char,
#[cfg(not(target_os = "linux"))] archive: *const wchar_t,
mode: c_uint,
) -> Self {
#[cfg(target_os = "linux")]
let (archive_name, archive_name_w) = (archive, std::ptr::null());
#[cfg(target_os = "linux")]
pub fn new(archive: *const c_char, mode: c_uint) -> Self {
Self::new_internal(archive, std::ptr::null(), mode)
}

#[cfg(not(target_os = "linux"))]
let (archive_name, archive_name_w) = (std::ptr::null(), archive);
#[cfg(not(target_os = "linux"))]
pub fn new(archive: *const wchar_t, mode: c_uint) -> Self {
Self::new_internal(std::ptr::null(), archive, mode)
}

fn new_internal(
archive_name: *const c_char,
archive_name_w: *const wchar_t,
mode: c_uint,
) -> Self {
OpenArchiveDataEx {
archive_name,
archive_name_w,
Expand Down

0 comments on commit a434949

Please sign in to comment.