summaryrefslogtreecommitdiff
path: root/crates/nu-test-support
diff options
context:
space:
mode:
authorStefan Holderbach <sholderbach@users.noreply.github.com>2023-09-12 08:06:56 +0200
committerGitHub <noreply@github.com>2023-09-12 14:06:56 +0800
commit6e9b6f22c92e028069792a93bcce3bd8dd0da925 (patch)
tree3959d9958f5d84bf6bfd9f87b2e1da0a10bee469 /crates/nu-test-support
parente90b099622907fe34a1081ba547ef85e11692f64 (diff)
Deref `&String` arguments to `&str` where appropriate (#10321)
# Description This generally makes for nicer APIs, as you are not forced to use an existing allocation covering the full `String`. Some exceptions remain where the underlying type requirements favor it. # User-Facing Changes None
Diffstat (limited to 'crates/nu-test-support')
-rw-r--r--crates/nu-test-support/src/macros.rs4
-rw-r--r--crates/nu-test-support/src/playground/matchers.rs8
-rw-r--r--crates/nu-test-support/src/playground/play.rs8
3 files changed, 10 insertions, 10 deletions
diff --git a/crates/nu-test-support/src/macros.rs b/crates/nu-test-support/src/macros.rs
index fff0fa051..3dc2d1095 100644
--- a/crates/nu-test-support/src/macros.rs
+++ b/crates/nu-test-support/src/macros.rs
@@ -469,9 +469,9 @@ pub fn read_std(std: &[u8]) -> String {
out.replace('\n', "")
}
-use std::{path::PathBuf, process::Command};
+use std::{path::Path, process::Command};
-pub fn run_command(executable_path: &PathBuf, target_cwd: &str) -> Command {
+pub fn run_command(executable_path: &Path, target_cwd: &str) -> Command {
let mut command = Command::new(executable_path);
command
diff --git a/crates/nu-test-support/src/playground/matchers.rs b/crates/nu-test-support/src/playground/matchers.rs
index 3071a9a20..1f8dad1be 100644
--- a/crates/nu-test-support/src/playground/matchers.rs
+++ b/crates/nu-test-support/src/playground/matchers.rs
@@ -30,7 +30,7 @@ pub fn says() -> Play {
trait CheckerMatchers {
fn output(&self, actual: &Outcome) -> MatchResult;
- fn std(&self, actual: &[u8], expected: Option<&String>, description: &str) -> MatchResult;
+ fn std(&self, actual: &[u8], expected: Option<&str>, description: &str) -> MatchResult;
fn stdout(&self, actual: &Outcome) -> MatchResult;
}
@@ -40,10 +40,10 @@ impl CheckerMatchers for Play {
}
fn stdout(&self, actual: &Outcome) -> MatchResult {
- self.std(&actual.out, self.stdout_expectation.as_ref(), "stdout")
+ self.std(&actual.out, self.stdout_expectation.as_deref(), "stdout")
}
- fn std(&self, actual: &[u8], expected: Option<&String>, description: &str) -> MatchResult {
+ fn std(&self, actual: &[u8], expected: Option<&str>, description: &str) -> MatchResult {
let out = match expected {
Some(out) => out,
None => return Ok(()),
@@ -51,7 +51,7 @@ impl CheckerMatchers for Play {
let actual =
str::from_utf8(actual).map_err(|_| format!("{description} was not utf8 encoded"))?;
- if actual != *out {
+ if actual != out {
return Err(format!(
"not equal:\n actual: {actual}\n expected: {out}\n\n"
));
diff --git a/crates/nu-test-support/src/playground/play.rs b/crates/nu-test-support/src/playground/play.rs
index 8ca71a9ef..d81899c5f 100644
--- a/crates/nu-test-support/src/playground/play.rs
+++ b/crates/nu-test-support/src/playground/play.rs
@@ -46,12 +46,12 @@ impl Dirs {
self.fixtures.join("playground/config")
}
- pub fn root(&self) -> &PathBuf {
- &self.root
+ pub fn root(&self) -> &Path {
+ self.root.as_path()
}
- pub fn test(&self) -> &PathBuf {
- &self.test
+ pub fn test(&self) -> &Path {
+ self.test.as_path()
}
}