Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dylni committed Dec 15, 2023
1 parent d40806b commit 93febc3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ rustc-args = ["--cfg", "os_str_bytes_docs_rs"]
rustdoc-args = ["--cfg", "os_str_bytes_docs_rs"]

[dependencies]
memchr = { version = "2.4", optional = true }
memchr = { version = "2.3.5", optional = true }

[dev-dependencies]
fastrand = "2.0"
lazy_static = "1.4"
tempfile = "3.2"
lazy_static = "1.0.3"
tempfile = "3.8"

[features]
default = ["memchr", "raw_os_str"]
Expand Down
22 changes: 11 additions & 11 deletions src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ pub(super) fn check_bound(string: &OsStr, index: usize) {

macro_rules! r#impl {
( $($name:ident),+ ) => {
$(
#[cfg(feature = "memchr")]
use memchr::memmem::$name;

#[cfg(not(feature = "memchr"))]
fn $name(string: &[u8], pat: &[u8]) -> Option<usize> {
(pat.len()..=string.len())
.$name(|&x| string[..x].ends_with(pat))
.map(|x| x - pat.len())
}
)+
$(
#[cfg(feature = "memchr")]
use memchr::memmem::$name;

#[cfg(not(feature = "memchr"))]
fn $name(string: &[u8], pat: &[u8]) -> Option<usize> {
(pat.len()..=string.len())
.$name(|&x| string[..x].ends_with(pat))
.map(|x| x - pat.len())
}
)+
};
}
r#impl!(find, rfind);
Expand Down
4 changes: 2 additions & 2 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use super::RawOsStr;

macro_rules! r#impl {
(
$(#[$attr:meta])* $name:ident ,
$(#[$raw_attr:meta])* $raw_name:ident ,
$(#[ $attr:meta ])* $name:ident ,
$(#[ $raw_attr:meta ])* $raw_name:ident ,
$split_method:ident ,
$reverse:expr ,
) => {
Expand Down
28 changes: 14 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
//! - [`RawOsString::from_raw_vec`]
//!
//! Because this feature should not be used in libraries, the
//! "OS_STR_BYTES_CHECKED_CONVERSIONS" environment variable must be defined
//! during compilation.
//! "OS\_STR\_BYTES\_CHECKED\_CONVERSIONS" environment variable must be
//! defined during compilation.
//!
//! - **conversions** -
//! Provides methods that require encoding conversion and may be expensive:
Expand Down Expand Up @@ -213,10 +213,10 @@ use std::path::PathBuf;

macro_rules! if_checked_conversions {
( $($item:item)+ ) => {
$(
#[cfg(feature = "checked_conversions")]
$item
)+
$(
#[cfg(feature = "checked_conversions")]
$item
)+
};
}

Expand Down Expand Up @@ -248,10 +248,10 @@ const _: &str = env!(

macro_rules! if_conversions {
( $($item:item)+ ) => {
$(
#[cfg(feature = "conversions")]
$item
)+
$(
#[cfg(feature = "conversions")]
$item
)+
};
}

Expand All @@ -265,10 +265,10 @@ if_conversions! {

macro_rules! if_raw_str {
( $($item:item)+ ) => {
$(
#[cfg(feature = "raw_os_str")]
$item
)+
$(
#[cfg(feature = "raw_os_str")]
$item
)+
};
}

Expand Down
8 changes: 4 additions & 4 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

macro_rules! if_checked_conversions {
( $($item:item)+ ) => {
$(
#[cfg(feature = "checked_conversions")]
$item
)+
$(
#[cfg(feature = "checked_conversions")]
$item
)+
};
}

Expand Down

0 comments on commit 93febc3

Please sign in to comment.