Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Checking stream capabilities

Use readable() and writable() to inspect an open file through a shared reference. Closed files return an error; closed itself remains an infallible property.

def demo() -> Result[(), IoError]:
    with open("capabilities.txt", "w")? as file:
        print(file.readable()?)?
        print(file.writable()?)?
    Ok(())
def main() -> Result[(), IoError]:
    demo()?
    Ok(())
False
True