Attempts to write one complete borrowed UTF-8 view to standard output.
Module std.io
import std.io;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
TryPrint
pub fn TryPrint(Value: str) -> Result<void, IoError>Attempts to write one complete borrowed UTF-8 view to standard output.
On the Linux/POSIX target, a closed pipe is reported as OutputFailed; the operation contains the SIGPIPE generated by its own write attempt.
Value: Valid UTF-8 view borrowed only for the complete call. Return: .Ok after every byte is accepted or .Err { Error = .OutputFailed }. Warning: May block and may emit a strict prefix before reporting failure.
Example
module example.print;
from std.io import Print, TryPrint;
fn Main() -> i32 {
let ResultValue = TryPrint("recoverable\n");
switch ResultValue {
case .Ok => Print("complete\n");
case .Err { Error = _ } => return 1;
}
return 0;
}pub fn Print(Value: str) -> voidWrites one complete borrowed UTF-8 view or terminates fatally. Value: Valid UTF-8 view borrowed only for the complete call. Return: No value after successful complete output. Warning: May block, may emit a strict prefix, and fatal-traps without unwinding on failure.