Skip to content

Commit cee29e7

Browse files
committed
Simplify the code, using into_encoded_bytes
It used `as_encoded_bytes` before, which required more other steps. Both functions require Rust 1.74, so the MSRVC for `gix-command`, which is 1.70, will not support them. That remains to be resolved.
1 parent bb36266 commit cee29e7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

gix-command/tests/command.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,11 @@ mod spawn {
567567
use gix_testtools::bstr::{BString, ByteSlice, ByteVec};
568568

569569
fn script_path(filename: impl AsRef<Path>) -> crate::Result<OsString> {
570-
let native_path = gix_testtools::scripted_fixture_read_only("scripts.sh")?
570+
let native_path: BString = gix_testtools::scripted_fixture_read_only("scripts.sh")?
571571
.join(filename)
572-
.as_os_str()
573-
.as_encoded_bytes()
574-
.as_bstr()
575-
.to_owned();
572+
.into_os_string()
573+
.into_encoded_bytes()
574+
.into();
576575
let unix_path = gix_path::to_unix_separators_on_windows(native_path)
577576
.to_os_str()?
578577
.to_owned();
@@ -599,8 +598,8 @@ mod spawn {
599598
Ok(out.stdout.into())
600599
}
601600

602-
fn concatenate(prefix: &OsString, suffix: &str) -> BString {
603-
let mut buffer = prefix.as_encoded_bytes().as_bstr().to_owned();
601+
fn concatenate(prefix: OsString, suffix: &str) -> BString {
602+
let mut buffer: BString = prefix.into_encoded_bytes().into();
604603
buffer.push_str(suffix);
605604
buffer
606605
}
@@ -625,7 +624,7 @@ mod spawn {
625624
fn do_name_no_args(indirect: bool) -> crate::Result {
626625
let path = script_path("name-and-args")?;
627626
let stdout = script_stdout(&path, None, indirect)?;
628-
let expected = concatenate(&path, "\n");
627+
let expected = concatenate(path, "\n");
629628
assert_eq!(stdout, expected);
630629
Ok(())
631630
}
@@ -644,7 +643,7 @@ mod spawn {
644643
let path = script_path("name-and-args")?;
645644
let args = ["foo", "bar baz", "quux"].map(OsStr::new);
646645
let stdout = script_stdout(&path, Some(&args), indirect)?;
647-
let expected = concatenate(&path, "\nfoo\nbar baz\nquux\n");
646+
let expected = concatenate(path, "\nfoo\nbar baz\nquux\n");
648647
assert_eq!(stdout, expected);
649648
Ok(())
650649
}

0 commit comments

Comments
 (0)