Trait os_str_bytes::OsStrBytesExt
source · pub trait OsStrBytesExt: OsStrBytes {
Show 15 methods
// Required methods
fn contains<P>(&self, pat: P) -> bool
where P: Pattern;
fn ends_with<P>(&self, pat: P) -> bool
where P: Pattern;
fn ends_with_os(&self, pat: &Self) -> bool;
fn find<P>(&self, pat: P) -> Option<usize>
where P: Pattern;
fn rfind<P>(&self, pat: P) -> Option<usize>
where P: Pattern;
fn rsplit_once<P>(&self, pat: P) -> Option<(&Self, &Self)>
where P: Pattern;
fn split_at(&self, mid: usize) -> (&Self, &Self);
fn split_once<P>(&self, pat: P) -> Option<(&Self, &Self)>
where P: Pattern;
fn starts_with<P>(&self, pat: P) -> bool
where P: Pattern;
fn starts_with_os(&self, pat: &Self) -> bool;
fn strip_prefix<P>(&self, pat: P) -> Option<&Self>
where P: Pattern;
fn strip_suffix<P>(&self, pat: P) -> Option<&Self>
where P: Pattern;
fn trim_end_matches<P>(&self, pat: P) -> &Self
where P: Pattern;
fn trim_matches<P>(&self, pat: P) -> &Self
where P: Pattern;
fn trim_start_matches<P>(&self, pat: P) -> &Self
where P: Pattern;
}Available on crate features
nightly and raw_os_str only.Expand description
An extension trait providing methods from RawOsStr.
Required Methods§
sourcefn contains<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn contains<P>(&self, pat: P) -> boolwhere P: Pattern,
Equivalent to str::contains.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert!(os_string.contains("oo"));
assert!(!os_string.contains("of"));sourcefn ends_with<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn ends_with<P>(&self, pat: P) -> boolwhere P: Pattern,
Equivalent to str::ends_with.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert!(os_string.ends_with("bar"));
assert!(!os_string.ends_with("foo"));sourcefn ends_with_os(&self, pat: &Self) -> bool
fn ends_with_os(&self, pat: &Self) -> bool
Available on crate feature
conversions only.Equivalent to str::ends_with but accepts this type for
the pattern.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert!(os_string.ends_with_os(OsStr::new("bar")));
assert!(!os_string.ends_with_os(OsStr::new("foo")));sourcefn rfind<P>(&self, pat: P) -> Option<usize>where
P: Pattern,
fn rfind<P>(&self, pat: P) -> Option<usize>where P: Pattern,
Equivalent to str::rfind.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert_eq!(Some(2), os_string.rfind("o"));
assert_eq!(None, os_string.rfind("of"));sourcefn rsplit_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where
P: Pattern,
fn rsplit_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where P: Pattern,
Equivalent to str::rsplit_once.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert_eq!(
Some((OsStr::new("fo"), OsStr::new("bar"))),
os_string.rsplit_once("o"),
);
assert_eq!(None, os_string.rsplit_once("of"));sourcefn split_at(&self, mid: usize) -> (&Self, &Self)
fn split_at(&self, mid: usize) -> (&Self, &Self)
Equivalent to str::split_at.
Panics
Panics if the index is not a valid boundary.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert_eq!(
((OsStr::new("fo"), OsStr::new("obar"))),
os_string.split_at(2),
);sourcefn split_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where
P: Pattern,
fn split_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where P: Pattern,
Equivalent to str::split_once.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert_eq!(
Some((OsStr::new("f"), OsStr::new("obar"))),
os_string.split_once("o"),
);
assert_eq!(None, os_string.split_once("of"));sourcefn starts_with<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn starts_with<P>(&self, pat: P) -> boolwhere P: Pattern,
Equivalent to str::starts_with.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert!(os_string.starts_with("foo"));
assert!(!os_string.starts_with("bar"));sourcefn starts_with_os(&self, pat: &Self) -> bool
fn starts_with_os(&self, pat: &Self) -> bool
Available on crate feature
conversions only.Equivalent to str::starts_with but accepts this type
for the pattern.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("foobar");
assert!(os_string.starts_with_os(OsStr::new("foo")));
assert!(!os_string.starts_with_os(OsStr::new("bar")));sourcefn strip_prefix<P>(&self, pat: P) -> Option<&Self>where
P: Pattern,
fn strip_prefix<P>(&self, pat: P) -> Option<&Self>where P: Pattern,
Equivalent to str::strip_prefix.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("111foo1bar111");
assert_eq!(
Some(OsStr::new("11foo1bar111")),
os_string.strip_prefix("1"),
);
assert_eq!(None, os_string.strip_prefix("o"));sourcefn strip_suffix<P>(&self, pat: P) -> Option<&Self>where
P: Pattern,
fn strip_suffix<P>(&self, pat: P) -> Option<&Self>where P: Pattern,
Equivalent to str::strip_suffix.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("111foo1bar111");
assert_eq!(
Some(OsStr::new("111foo1bar11")),
os_string.strip_suffix("1"),
);
assert_eq!(None, os_string.strip_suffix("o"));sourcefn trim_end_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_end_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Equivalent to str::trim_end_matches.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("111foo1bar111");
assert_eq!("111foo1bar", os_string.trim_end_matches("1"));
assert_eq!("111foo1bar111", os_string.trim_end_matches("o"));sourcefn trim_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Equivalent to str::trim_matches.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("111foo1bar111");
assert_eq!("foo1bar", os_string.trim_matches("1"));
assert_eq!("111foo1bar111", os_string.trim_matches("o"));sourcefn trim_start_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_start_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Equivalent to str::trim_start_matches.
Examples
use std::ffi::OsStr;
use os_str_bytes::OsStrBytesExt;
let os_string = OsStr::new("111foo1bar111");
assert_eq!("foo1bar111", os_string.trim_start_matches("1"));
assert_eq!("111foo1bar111", os_string.trim_start_matches("o"));Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl OsStrBytesExt for OsStr
impl OsStrBytesExt for OsStr
source§fn contains<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn contains<P>(&self, pat: P) -> boolwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn ends_with<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn ends_with<P>(&self, pat: P) -> boolwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn ends_with_os(&self, pat: &Self) -> bool
fn ends_with_os(&self, pat: &Self) -> bool
Available on crate features
nightly and raw_os_str and conversions only.source§fn find<P>(&self, pat: P) -> Option<usize>where
P: Pattern,
fn find<P>(&self, pat: P) -> Option<usize>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn rfind<P>(&self, pat: P) -> Option<usize>where
P: Pattern,
fn rfind<P>(&self, pat: P) -> Option<usize>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn rsplit_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where
P: Pattern,
fn rsplit_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn split_at(&self, mid: usize) -> (&Self, &Self)
fn split_at(&self, mid: usize) -> (&Self, &Self)
Available on crate features
nightly and raw_os_str only.source§fn split_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where
P: Pattern,
fn split_once<P>(&self, pat: P) -> Option<(&Self, &Self)>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn starts_with<P>(&self, pat: P) -> boolwhere
P: Pattern,
fn starts_with<P>(&self, pat: P) -> boolwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn starts_with_os(&self, pat: &Self) -> bool
fn starts_with_os(&self, pat: &Self) -> bool
Available on crate features
nightly and raw_os_str and conversions only.source§fn strip_prefix<P>(&self, pat: P) -> Option<&Self>where
P: Pattern,
fn strip_prefix<P>(&self, pat: P) -> Option<&Self>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn strip_suffix<P>(&self, pat: P) -> Option<&Self>where
P: Pattern,
fn strip_suffix<P>(&self, pat: P) -> Option<&Self>where P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn trim_end_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_end_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn trim_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.source§fn trim_start_matches<P>(&self, pat: P) -> &Selfwhere
P: Pattern,
fn trim_start_matches<P>(&self, pat: P) -> &Selfwhere P: Pattern,
Available on crate features
nightly and raw_os_str only.