跳转至

std.fs

tier: std

Minimal filesystem access: exists tests path presence; read_or reads a whole file, returning a default when it is missing.

pub struct

struct FsError

Field Type
message Str

trait

trait Fs

fn read_to_string(self, path: Str) -> Result[String, FsError]
fn write(self, path: Str, data: Str) -> Result[Void, FsError]
fn exists(self, path: Str) -> Bool

pub fn

Signature Returns Description
read_or(path: Str, dft: Str) Str 读文件;不存在或不可读返回 dft
口径:read_file 终局语义为 Str(缺失 → 空串,SL-0.6 ⑯ 裁决),故先以
fs_exists 守卫再直读,不做 Option 匹配(自举解释口径 match Some/None 会落空)
exists(path: Str) Bool 文件是否存在(语义化别名,转发内建)