mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 02:02:35 +02:00
Attempt so simplify classified
This commit is contained in:
@ -310,8 +310,7 @@ pub fn file_contents(full_path: impl AsRef<Path>) -> String {
|
||||
pub fn file_contents_binary(full_path: impl AsRef<Path>) -> Vec<u8> {
|
||||
let mut file = std::fs::File::open(full_path.as_ref()).expect("can not open file");
|
||||
let mut contents = Vec::new();
|
||||
file.read_to_end(&mut contents)
|
||||
.expect("can not read file");
|
||||
file.read_to_end(&mut contents).expect("can not read file");
|
||||
contents
|
||||
}
|
||||
|
||||
@ -327,18 +326,6 @@ pub fn line_ending() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize_string(input: &str) -> String {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
input.to_string()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
format!("\"{}\"", input)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_file_at(full_path: impl AsRef<Path>) -> Result<(), std::io::Error> {
|
||||
let full_path = full_path.as_ref();
|
||||
|
||||
@ -377,13 +364,13 @@ pub fn in_directory(str: impl AsRef<Path>) -> String {
|
||||
str.as_ref().display().to_string()
|
||||
}
|
||||
|
||||
|
||||
pub fn pipeline(commands: &str) -> String {
|
||||
commands.lines()
|
||||
.skip(1)
|
||||
.map(|line| line.trim())
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.trim_end()
|
||||
.to_string()
|
||||
commands
|
||||
.lines()
|
||||
.skip(1)
|
||||
.map(|line| line.trim())
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.trim_end()
|
||||
.to_string()
|
||||
}
|
||||
|
Reference in New Issue
Block a user