diff options
author | Rory Dudley | 2024-05-20 13:56:13 -0600 |
---|---|---|
committer | Rory Dudley | 2024-05-20 13:56:13 -0600 |
commit | 852e13abbca280b896fd88e722cef7ada11bf3bd (patch) | |
tree | 5c630f323a821e6f3804933a0e290dd368ebf2f2 /src/compose/environment.rs | |
parent | 8a7af4aacc0d67a9887ca1fd665b1694fd62a8ca (diff) | |
download | dwarvish-852e13abbca280b896fd88e722cef7ada11bf3bd.tar.gz |
Add doc comments for the Environment struct
Added documentation comments for the Environment struct, which includes
uses cases, and defining the fields.
Diffstat (limited to 'src/compose/environment.rs')
-rw-r--r-- | src/compose/environment.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compose/environment.rs b/src/compose/environment.rs index 7107d57..ea6d070 100644 --- a/src/compose/environment.rs +++ b/src/compose/environment.rs @@ -1,5 +1,29 @@ use std::collections::HashMap; +/// Record the shell state +/// +/// The [Environment] struct keeps track of various fields, all relating to the +/// shell state. The environment is the first thing setup at the beginning of +/// the shell, and is maintained throughout the lifetime of the process. +/// +/// Both [crate::Poem]::read() and [crate::Poem]::recite() rely on this struct +/// for various functions and features. +/// +/// # Fields +/// aliases - A table of aliases, set by the user using the built-in 'alias' +/// bins - A lookup table for +x files, constructed from the $PATH +/// cs - Indication of callstack level, helpful for recursively dealing with +/// aliases +/// +/// # Examples +/// ``` +/// fn main() -> Result<(), io::Error> { +/// let mut env = compose::env(); +/// let poem = Poem::read("alias", &mut env)?; +/// poem.recite(&mut env)?; +/// () +/// } +/// ``` pub struct Environment { pub aliases: HashMap<String, String>, pub bins: Vec<String>, @@ -7,6 +31,7 @@ pub struct Environment { } impl Environment { + /// Initialize an [Environment] struct with the default values pub fn new() -> Self { Environment { aliases: HashMap::new(), |