Skip to content

Commit

Permalink
Rollup merge of #85136 - shirshak55:master, r=dtolnay
Browse files Browse the repository at this point in the history
Change param name (k to key and v to value) in std::env module

1. When I was reading code the ide displayed `k` and `v`, so I
thought it would be better to show key and value?

2. I noticed var method already uses `key` instead of `k` so it
is more consistent to use `key` instead of `k`?

Thanks
  • Loading branch information
JohnTitor authored May 11, 2021

Verified

This commit was signed with the committer’s verified signature.
simeonschaub Simeon David Schaub
2 parents 4ab3050 + 0778e8d commit 6ec4f91
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
@@ -324,13 +324,13 @@ impl Error for VarError {
/// assert_eq!(env::var(key), Ok("VALUE".to_string()));
/// ```
#[stable(feature = "env", since = "1.0.0")]
pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(k: K, v: V) {
_set_var(k.as_ref(), v.as_ref())
pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
_set_var(key.as_ref(), value.as_ref())
}

fn _set_var(k: &OsStr, v: &OsStr) {
os_imp::setenv(k, v).unwrap_or_else(|e| {
panic!("failed to set environment variable `{:?}` to `{:?}`: {}", k, v, e)
fn _set_var(key: &OsStr, value: &OsStr) {
os_imp::setenv(key, value).unwrap_or_else(|e| {
panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e)
})
}

@@ -366,13 +366,13 @@ fn _set_var(k: &OsStr, v: &OsStr) {
/// assert!(env::var(key).is_err());
/// ```
#[stable(feature = "env", since = "1.0.0")]
pub fn remove_var<K: AsRef<OsStr>>(k: K) {
_remove_var(k.as_ref())
pub fn remove_var<K: AsRef<OsStr>>(key: K) {
_remove_var(key.as_ref())
}

fn _remove_var(k: &OsStr) {
os_imp::unsetenv(k)
.unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", k, e))
fn _remove_var(key: &OsStr) {
os_imp::unsetenv(key)
.unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e))
}

/// An iterator that splits an environment variable into paths according to

0 comments on commit 6ec4f91

Please sign in to comment.