Standard library / std::process

std::process

std::process provides process-oriented primitives (hosted baseline).

Full reference: process.

Notes#

  • Supported forms is available for the hosted POSIX baseline.
  • Full reference: process

Importing#

import std::process;
import std::strings;

Examples#

Example: getcwd + chdir with recoverable errors#

import std::process;
import std::strings;

fn main () -> int {
  match (std::process::getcwd()) {
    std::process::GetCwdResult::Ok(cwd_value) => {
      let mut cwd: std::strings::String = cwd_value;

      let err1: std::process::ChdirFailed? = std::process::chdir("/");
      if err1 != None {
        cwd.drop();
        return 2;
      }

      let err2: std::process::ChdirFailed? = std::process::chdir(cwd.as_string());
      if err2 != None {
        cwd.drop();
        return 3;
      }

      cwd.drop();
      return 0;
    },
    std::process::GetCwdResult::Err(_) => {
      return 1;
    },
  }
}

See also#

  • Full reference: process
  • Environment helpers: env

Source repository · Edit this page · View Markdown