Skip to content

Commit

Permalink
Revert command name in error type to &'static str
Browse files Browse the repository at this point in the history
  • Loading branch information
Seeker14491 committed Jun 12, 2021
1 parent 9a36c6e commit 5d24271
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- On Linux (non-WSL), the system `xdg-open` is now used if present. Otherwise, the bundled version is used, as before.
- Avoid blocking the thread on Linux and WSL.
- The command name in the `OpenError::ExitStatus` variant is now returned as a `Cow<'static, str>` instead of a
`&'static str`.
### Removed
- `impl From<io::Error> for OpenError`.

Expand Down
8 changes: 2 additions & 6 deletions opener/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use crate::macos as sys;
#[cfg(target_os = "windows")]
use crate::windows as sys;

use std::borrow::Cow;
use std::error::Error;
use std::ffi::{OsStr, OsString};
use std::fmt::{self, Display, Formatter};
Expand Down Expand Up @@ -120,7 +119,7 @@ pub enum OpenError {
/// A command exited with a non-zero exit status.
ExitStatus {
/// A string that identifies the command.
cmd: Cow<'static, str>,
cmd: &'static str,

/// The failed process's exit status.
status: ExitStatus,
Expand Down Expand Up @@ -204,10 +203,7 @@ fn wsl_to_windows_path(_path: &OsStr) -> Option<OsString> {
}

#[cfg(not(target_os = "windows"))]
fn wait_child(
child: &mut std::process::Child,
cmd_name: Cow<'static, str>,
) -> Result<(), OpenError> {
fn wait_child(child: &mut std::process::Child, cmd_name: &'static str) -> Result<(), OpenError> {
use std::io::Read;

let exit_status = child.wait().map_err(OpenError::Io)?;
Expand Down
2 changes: 1 addition & 1 deletion opener/src/linux_and_more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn open(path: &OsStr) -> Result<(), OpenError> {
fn wsl_open(path: &OsStr) -> Result<(), OpenError> {
let result = open_with_wslview(path);
if let Ok(mut child) = result {
return crate::wait_child(&mut child, "wslview".into());
return crate::wait_child(&mut child, "wslview");
}

open_with_system_xdg_open(path).map_err(OpenError::Io)?;
Expand Down
2 changes: 1 addition & 1 deletion opener/src/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ pub(crate) fn open(path: &OsStr) -> Result<(), OpenError> {
.spawn()
.map_err(OpenError::Io)?;

crate::wait_child(&mut open, "open".into())
crate::wait_child(&mut open, "open")
}

0 comments on commit 5d24271

Please sign in to comment.