~goorzhel/rstdm

3491a0d5fa8857efe4c6676ccaf331330899dc2e — Antonio Gurgel 28 days ago 176cd25
Condense unwrap comments

I use them because every unwrap should be justified (and used sparingly
anyway). "Because" is redundant.
3 files changed, 3 insertions(+), 3 deletions(-)

M src/cli.rs
M src/system.rs
M src/user.rs
M src/cli.rs => src/cli.rs +1 -1
@@ 40,7 40,7 @@ impl Options {
        /// no such directory" error line on every startup would be rude.
        fn gather_default_dirs(leaf_dir: &str) -> impl Iterator<Item = PathBuf> + '_ {
            let xdg = BaseDirectories::new().unwrap();
            // Unwrap because there's an error if and only if:
            // unwrap: there's an error if and only if:
            // 1. $HOME is unset, AND
            // 2. rstdm's user -- usually `root` -- has no homedir.
            xdg.get_data_dirs().into_iter().filter_map(move |mut p| {

M src/system.rs => src/system.rs +1 -1
@@ 42,7 42,7 @@ pub fn prepare_xdg_runtime(user: &User) -> Result<()> {
    let gid = user.gid;

    let path: std::path::PathBuf = var("XDG_RUNTIME_DIR").unwrap().into();
    // Unwrap because $XDG_RUNTIME_DIR should already be set by User::load_environment.
    // unwrap: $XDG_RUNTIME_DIR should already be set by User::load_environment.
    create_dir_all(&path).context("Failed to create XDG_RUNTIME_DIR")?;
    chown(&path, Some(uid), Some(gid)).context("Failed to chown XDG_RUNTIME_DIR")?;
    set_permissions(&path, Permissions::from_mode(0o700))

M src/user.rs => src/user.rs +1 -1
@@ 65,7 65,7 @@ impl User {
        for pair in output.split_terminator('\n') {
            let mut pair = pair.split('=');
            let (key, value) = (pair.next().unwrap(), pair.next().unwrap());
            // Unwraps because output has already been ensured to be KV pairs in valid UTF-8.
            // unwrap: output has already been ensured to be KV pairs in valid UTF-8.
            trace!("Loading environment: {}={}", key, value);
            std::env::set_var(key, value);
        }