aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/env.rs
diff options
context:
space:
mode:
authorValentin <[email protected]>2018-06-15 18:57:24 +0200
committerFenrirWolf <[email protected]>2018-06-15 10:57:24 -0600
commitf2a90174bb36b9ad528e863ab34c02ebce002b02 (patch)
tree959e8d67883d3a89e179b3549b1f30d28e51a87c /ctr-std/src/env.rs
parentMerge pull request #68 from linouxis9/master (diff)
downloadctru-rs-f2a90174bb36b9ad528e863ab34c02ebce002b02.tar.xz
ctru-rs-f2a90174bb36b9ad528e863ab34c02ebce002b02.zip
Update for latest nightly 2018-06-09 (#70)
* Update for latest nightly 2018-06-09 * We now have a proper horizon os and sys modules in libstd
Diffstat (limited to 'ctr-std/src/env.rs')
-rw-r--r--ctr-std/src/env.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/ctr-std/src/env.rs b/ctr-std/src/env.rs
index a103c0b..91e417c 100644
--- a/ctr-std/src/env.rs
+++ b/ctr-std/src/env.rs
@@ -49,9 +49,11 @@ use sys::os as os_imp;
/// ```
/// use std::env;
///
-/// // We assume that we are in a valid directory.
-/// let path = env::current_dir().unwrap();
-/// println!("The current directory is {}", path.display());
+/// fn main() -> std::io::Result<()> {
+/// let path = env::current_dir()?;
+/// println!("The current directory is {}", path.display());
+/// Ok(())
+/// }
/// ```
#[stable(feature = "env", since = "1.0.0")]
pub fn current_dir() -> io::Result<PathBuf> {
@@ -441,15 +443,18 @@ pub struct JoinPathsError {
/// Joining paths on a Unix-like platform:
///
/// ```
-/// # if cfg!(unix) {
/// use std::env;
/// use std::ffi::OsString;
/// use std::path::Path;
///
-/// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
-/// let path_os_string = env::join_paths(paths.iter()).unwrap();
-/// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
+/// fn main() -> Result<(), env::JoinPathsError> {
+/// # if cfg!(unix) {
+/// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
+/// let path_os_string = env::join_paths(paths.iter())?;
+/// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
/// # }
+/// Ok(())
+/// }
/// ```
///
/// Joining a path containing a colon on a Unix-like platform results in an error:
@@ -471,11 +476,15 @@ pub struct JoinPathsError {
/// use std::env;
/// use std::path::PathBuf;
///
-/// if let Some(path) = env::var_os("PATH") {
-/// let mut paths = env::split_paths(&path).collect::<Vec<_>>();
-/// paths.push(PathBuf::from("/home/xyz/bin"));
-/// let new_path = env::join_paths(paths).unwrap();
-/// env::set_var("PATH", &new_path);
+/// fn main() -> Result<(), env::JoinPathsError> {
+/// if let Some(path) = env::var_os("PATH") {
+/// let mut paths = env::split_paths(&path).collect::<Vec<_>>();
+/// paths.push(PathBuf::from("/home/xyz/bin"));
+/// let new_path = env::join_paths(paths)?;
+/// env::set_var("PATH", &new_path);
+/// }
+///
+/// Ok(())
/// }
/// ```
#[stable(feature = "env", since = "1.0.0")]