1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 20:17:45 +00:00

uucore: remove panic encoding handling

We never want utilities to panic on invalid input and it is not currently in use, so it can be removed safely.
This commit is contained in:
Terts Diepraam 2022-08-17 14:29:53 +02:00
parent 9fad6fde35
commit 0ed8b97a3f

View file

@ -153,7 +153,6 @@ pub fn execution_phrase() -> &'static str {
pub enum InvalidEncodingHandling {
Ignore,
ConvertLossy,
Panic,
}
#[must_use]
@ -192,11 +191,9 @@ pub trait Args: Iterator<Item = OsString> + Sized {
/// Converts each iterator item to a String and collects these into a vector
/// On invalid encoding, the result will depend on the argument. This method allows to either drop entries with illegal encoding
/// completely (```InvalidEncodingHandling::Ignore```), convert them using lossy-conversion (```InvalidEncodingHandling::ConvertLossy```)
/// which will result in strange strings or can chosen to panic (```InvalidEncodingHandling::Panic```).
/// which will result in strange strings or can chosen to panic.
/// # Arguments
/// * `handling` - This switch allows to switch the behavior, when invalid encoding is encountered
/// # Panics
/// * Occurs, when invalid encoding is encountered and handling is set to ```InvalidEncodingHandling::Panic```
fn collect_str(self, handling: InvalidEncodingHandling) -> ConversionResult {
let mut full_conversion = true;
let result_vector: Vec<String> = self
@ -213,9 +210,6 @@ pub trait Args: Iterator<Item = OsString> + Sized {
InvalidEncodingHandling::ConvertLossy => {
Err(s_ret.to_string_lossy().into_owned())
}
InvalidEncodingHandling::Panic => {
panic!("Broken encoding found but caller cannot handle it")
}
}
}
})