Skip to content
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
42 changes: 0 additions & 42 deletions clap_lex/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,39 +162,6 @@ pub trait OsStrExt: private::Sealed {
///
/// [`split_whitespace`]: str::split_whitespace
fn split<'s, 'n>(&'s self, needle: &'n str) -> Split<'s, 'n>;
/// Divide one string slice into two at an index.
///
/// The argument, `mid`, should be a byte offset from the start of the
/// string. It must also be on the boundary of a UTF-8 code point.
///
/// The two slices returned go from the start of the string slice to `mid`,
/// and from `mid` to the end of the string slice.
///
/// To get mutable string slices instead, see the [`split_at_mut`]
/// method.
///
/// [`split_at_mut`]: str::split_at_mut
///
/// # Panics
///
/// Panics if `mid` is not on a UTF-8 code point boundary, or if it is
/// past the end of the last code point of the string slice.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use clap_lex::OsStrExt as _;
/// let s = std::ffi::OsStr::new("Per Martin-Löf");
///
/// let (first, last) = s.split_at(3);
///
/// assert_eq!("Per", first);
/// assert_eq!(" Martin-Löf", last);
/// ```
#[deprecated(since = "4.1.0", note = "This is not sound for all `index`")]
fn split_at(&self, index: usize) -> (&OsStr, &OsStr);
/// Splits the string on the first occurrence of the specified delimiter and
/// returns prefix before delimiter and suffix after delimiter.
///
Expand Down Expand Up @@ -249,15 +216,6 @@ impl OsStrExt for OsStr {
}
}

fn split_at(&self, index: usize) -> (&OsStr, &OsStr) {
let bytes = to_bytes(self);
unsafe {
// BUG: This is unsafe and has been deprecated
let (first, second) = bytes.split_at(index);
(to_os_str_unchecked(first), to_os_str_unchecked(second))
}
}

fn split_once(&self, needle: &'_ str) -> Option<(&OsStr, &OsStr)> {
let start = self.find(needle)?;
let end = start + needle.len();
Expand Down