diff src/environ.rs @ 141:a508a69c068a

Remove a lot of Results from functions. Many functions are documented to only return failing Results when given improper inputs or when there is a memory allocation failure (which can be verified by looking at the source). In cases where we know our input is correct, we don't need to check for memory allocation errors for the same reason that Rust doesn't do so when you, e.g., create a new Vec.
author Paul Fisher <paul@pfish.zone>
date Sat, 05 Jul 2025 17:16:56 -0400
parents 3f11b8d30f63
children
line wrap: on
line diff
--- a/src/environ.rs	Sat Jul 05 17:11:33 2025 -0400
+++ b/src/environ.rs	Sat Jul 05 17:16:56 2025 -0400
@@ -3,7 +3,6 @@
 //! PAM modules can set environment variables to apply to a user session.
 //! This module manages the interface for doing all of that.
 
-use crate::constants::Result;
 use std::ffi::{OsStr, OsString};
 
 /// A key/value map for environment variables, as [`OsString`]s.
@@ -15,19 +14,15 @@
     fn get(&self, key: impl AsRef<OsStr>) -> Option<OsString>;
 
     /// Iterates over the key/value pairs of the environment.
-    fn iter(&self) -> Result<impl Iterator<Item = (OsString, OsString)>>;
+    fn iter(&self) -> impl Iterator<Item = (OsString, OsString)>;
 }
 
 pub trait EnvironMapMut<'a>: EnvironMap<'a> {
     /// Sets the environment variable with the given key,
     /// returning the old one if present.
-    fn insert(
-        &mut self,
-        key: impl AsRef<OsStr>,
-        val: impl AsRef<OsStr>,
-    ) -> Result<Option<OsString>>;
+    fn insert(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> Option<OsString>;
 
     /// Removes the environment variable from the map, returning its old value
     /// if present.
-    fn remove(&mut self, key: impl AsRef<OsStr>) -> Result<Option<OsString>>;
+    fn remove(&mut self, key: impl AsRef<OsStr>) -> Option<OsString>;
 }