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§

source

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"));
source

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"));
source

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")));
source

fn find<P>(&self, pat: P) -> Option<usize>where P: Pattern,

Equivalent to str::find.

Examples
use std::ffi::OsStr;

use os_str_bytes::OsStrBytesExt;

let os_string = OsStr::new("foobar");
assert_eq!(Some(1), os_string.find("o"));
assert_eq!(None, os_string.find("of"));
source

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"));
source

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"));
source

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),
);
source

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"));
source

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"));
source

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")));
source

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"));
source

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"));
source

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"));
source

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"));
source

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

source§

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,

Available on crate features nightly and raw_os_str only.
source§

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,

Available on crate features nightly and raw_os_str only.
source§

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,

Available on crate features nightly and raw_os_str only.
source§

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,

Available on crate features nightly and raw_os_str only.
source§

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

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,

Available on crate features nightly and raw_os_str only.
source§

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,

Available on crate features nightly and raw_os_str only.
source§

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,

Available on crate features nightly and raw_os_str only.

Implementors§