Lookups — miri view
Agents often guess method names from other languages: .len(), .to_string(),
.keys(). miri view answers from the real standard library instead, so one lookup replaces
a string of wrong guesses.
What can I call on a type? Members a type gets from its traits are listed too:
$ miri view --type String --public
class String implements Equatable, Hashable, Comparable, Addable, Multiplicable, Iterable, Cloneable
fn clone() String
fn code_at(index int) int?
fn compare(other String) int
fn concat(other String) String
fn contains(needle String) bool
fn element_at(index int) String
fn ends_with(suffix String) bool
fn equals(other String) bool
static fn from_code_point(code int) String?
fn hash() int
fn init() String
fn is_empty() bool
fn join(parts [String]) String
fn length() int
fn repeat(count int) String
fn replace(old String, to String) String
fn size() int
fn split(separator String) [String]
fn starts_with(prefix String) bool
fn substring(start int, end int) String
fn to_float() float?
fn to_int() int?
fn to_lower() String
fn to_upper() String
fn trim() String
fn trim_end() String
fn trim_start() String
exit status 0
What does a module offer?
$ miri view system.fs --outline --public
use system.result
use system.string
// Represents a filesystem operation error.
@non_exhaustive
public enum FsError
NotFound(String)
PermissionDenied(String)
AlreadyExists(String)
NotADirectory(String)
InvalidData(String)
Other(String)
// Filesystem capability class. Acquire a handle with `let fs = Fs()` to access filesystem operations.
public class Fs
// Checks whether a file or directory exists at the given path.
public fn exists(path String) bool
// Reads the entire contents of a file into a string.
public fn read_file(path String) Result<String, FsError>
// Writes the given contents to a file, truncating if it exists.
public fn write_file(path String, contents String) Result<int, FsError>
// Appends the given contents to a file, creating it if it doesn't exist.
public fn append_file(path String, contents String) Result<int, FsError>
// Lists the entries (file and directory names) in a directory.
public fn list_dir(path String) Result<[String], FsError>
// Creates a directory at the given path, creating missing parents as needed.
public fn create_dir(path String) Result<bool, FsError>
// Deletes a regular file at the given path.
public fn delete(path String) Result<bool, FsError>
// Returns the current working directory as an absolute path.
public fn cwd() Result<String, FsError>
exit status 0
Show me one function, from a module or from a file of your own:
$ miri view scores.mi --fn total_of_passing
fn total_of_passing(scores [int]) int
var total = 0
for s in scores
if s >= 5: total = total + s
total
exit status 0
miri view --stdlib-root prints where the standard library is searched for. Set
MIRI_STDLIB_PATH if the compiler cannot find it.