Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions crates/edit/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ pub struct Size {
}

impl Size {
pub const MIN: Self = Self { width: 0, height: 0 };
pub const MAX: Self = Self { width: CoordType::MAX, height: CoordType::MAX };

pub fn as_rect(&self) -> Rect {
Rect { left: 0, top: 0, right: self.width, bottom: self.height }
}
Expand Down Expand Up @@ -149,14 +146,6 @@ impl Rect {
}
}

/// [`std::cmp::minmax`] is unstable, as per usual.
pub fn minmax<T>(v1: T, v2: T) -> [T; 2]
where
T: Ord,
{
if v2 < v1 { [v2, v1] } else { [v1, v2] }
}

/// [`Read`] but with [`MaybeUninit<u8>`] buffers.
pub fn file_read_uninit<T: Read>(file: &mut T, buf: &mut [MaybeUninit<u8>]) -> io::Result<usize> {
unsafe {
Expand Down
7 changes: 4 additions & 3 deletions crates/edit/src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! Read the `windows` module for reference.
//! TODO: This reminds me that the sys API should probably be a trait.

use std::ffi::{CStr, c_char, c_int, c_void};
use std::ffi::{c_char, c_int, c_void};
use std::fs::File;
use std::mem::{self, ManuallyDrop, MaybeUninit};
use std::os::fd::{AsRawFd as _, FromRawFd as _};
Expand Down Expand Up @@ -425,6 +425,7 @@ pub fn load_icu() -> io::Result<LibIcu> {
Ok(LibIcu { libicuuc, libicui18n })
}
}

/// ICU, by default, adds the major version as a suffix to each exported symbol.
/// They also recommend to disable this for system-level installations (`runConfigureICU Linux --disable-renaming`),
/// but I found that many (most?) Linux distributions don't do this for some reason.
Expand Down Expand Up @@ -459,7 +460,7 @@ pub fn icu_detect_renaming_suffix(arena: &Arena, handle: NonNull<c_void>) -> Are
}

// The library path is in `info.dli_fname`.
let path = match CStr::from_ptr(info.dli_fname).to_str() {
let path = match std::ffi::CStr::from_ptr(info.dli_fname).to_str() {
Ok(name) => name,
Err(_) => return res,
};
Expand Down Expand Up @@ -502,7 +503,7 @@ where
} else {
// SAFETY: In this particular case we know that the string
// is valid UTF-8, because it comes from icu.rs.
let name = unsafe { CStr::from_ptr(name) };
let name = unsafe { std::ffi::CStr::from_ptr(name) };
let name = unsafe { name.to_str().unwrap_unchecked() };

let mut res = ManuallyDrop::new(ArenaString::new_in(arena));
Expand Down