Function in io compiler

result_unit_probe

fn result_unit_probe(int n) -> Result<unit, IoError>
Import
use io::{result_unit_probe};
Source: compiler/src/builtin_docs/io.hy

Returns Ok(()) when n >= 0 and Err(IoError::InvalidInput) otherwise.

A small host function for testing how Result<unit, IoError> values cross between the runtime and Coil code; it does no IO.

Parameters#

NameType
nint

Returns#

Result<unit, IoError>

Examples#

use io::{result_unit_probe, IoError};
use tests::assert;
let ok = match result_unit_probe(1) {
    Result::Ok(_) => true,
    Result::Err(_) => false,
};
let err = match result_unit_probe(-1) {
    Result::Err(IoError::InvalidInput) => true,
    default => false,
};
assert!(ok && err);

See also#

  • Result
  • stdin: Returns a new stream on the process’s standard input.
  • stdout: Returns a new stream on the process’s standard output.
  • stderr: Returns a new stream on the process’s standard error.
  • capture_begin: Starts keeping this thread’s stdout and stderr writes in memory instead of writing them, until the matching capture_end().
  • capture_end: Ends the innermost capture_begin() and returns what it kept, as (stdout, stderr).
  • open: Opens the file at path with mode and returns a stream on it.
  • close: Closes s.
↑ ↓ navigate ↵ open