Skip to content

Commit

Permalink
Change some parameters from &Path to AsRef<OsStr>
Browse files Browse the repository at this point in the history
There were a few methods in the API that took `&Path` parameters which makes
it awkward to pass in `&'static str` and other such things. There were other
existing methods that used `AsRef<OsStr>` so I changed the rest to match.
  • Loading branch information
luser committed Jan 20, 2020
1 parent 27fa40c commit 98c3dc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Device {
}

/// Returns the parent of the device with the matching subsystem and devtype if any.
pub fn parent_with_subsystem(&self, subsystem: &Path) -> Result<Option<Self>> {
pub fn parent_with_subsystem<T: AsRef<OsStr>>(&self, subsystem: T) -> Result<Option<Self>> {
let subsystem = util::os_str_to_cstring(subsystem)?;
let ptr = unsafe {
ffi::udev_device_get_parent_with_subsystem_devtype(
Expand All @@ -125,10 +125,10 @@ impl Device {
}

/// Returns the parent of the device with the matching subsystem and devtype if any.
pub fn parent_with_subsystem_devtype(
pub fn parent_with_subsystem_devtype<T: AsRef<OsStr>, U: AsRef<OsStr>>(
&self,
subsystem: &Path,
devtype: &Path,
subsystem: T,
devtype: U
) -> Result<Option<Self>> {
let subsystem = util::os_str_to_cstring(subsystem)?;
let devtype = util::os_str_to_cstring(devtype)?;
Expand Down
2 changes: 1 addition & 1 deletion src/enumerator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Enumerator {
}

/// Includes the device with the given syspath.
pub fn add_syspath(&mut self, syspath: &Path) -> Result<()> {
pub fn add_syspath<T: AsRef<OsStr>>(&mut self, syspath: T) -> Result<()> {
let syspath = util::os_str_to_cstring(syspath)?;

util::errno_to_result(unsafe {
Expand Down

0 comments on commit 98c3dc6

Please sign in to comment.