Skip to main content

PracticeWorld

Trait PracticeWorld 

Source
pub trait PracticeWorld {
    // Required methods
    fn locate(&self, lesson_path: &str) -> Option<PathBuf>;
    fn cwd_relative(&self) -> String;

    // Provided methods
    fn kind_at(&self, lesson_path: &str) -> Option<EntryKind> { ... }
    fn read_text(&self, lesson_path: &str) -> Option<String> { ... }
}
Expand description

The practice environment a lesson runs in, as seen by outcome checks

Required Methods§

Source

fn locate(&self, lesson_path: &str) -> Option<PathBuf>

Real path for a path relative to the lesson home, if it stays inside

Source

fn cwd_relative(&self) -> String

Current directory relative to the lesson home (“” at the home)

Provided Methods§

Source

fn kind_at(&self, lesson_path: &str) -> Option<EntryKind>

What is at a path relative to the lesson home; None when the path would leave it. By default, the real file PracticeWorld::locate gives.

Source

fn read_text(&self, lesson_path: &str) -> Option<String>

A text file’s contents, by a path relative to the lesson home. By default, read from the real file PracticeWorld::locate gives.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§