#[non_exhaustive]pub struct BeancountFile<D> {
pub options: Vec<BeanOption>,
pub includes: Vec<PathBuf>,
pub directives: Vec<Directive<D>>,
}Expand description
Main struct representing a parsed beancount file.
To get an instance of this, use parse.
For an example, look at the root crate documentation.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.options: Vec<BeanOption>List of beancount options
See: https://beancount.github.io/docs/beancount_language_syntax.html#options
includes: Vec<PathBuf>Paths of include directives
See: https://beancount.github.io/docs/beancount_language_syntax.html#includes
directives: Vec<Directive<D>>List of Directive found in the file
Implementations§
Source§impl<D> BeancountFile<D>
impl<D> BeancountFile<D>
Sourcepub fn option(&self, key: &str) -> Option<&str>
pub fn option(&self, key: &str) -> Option<&str>
Returns the first value found for the option
If the option is declared multiple times, this function returns the first one found.
See Self::options to get all declared options.
Syntax: https://beancount.github.io/docs/beancount_language_syntax.html#options
§Example
let input = r#"
option "favorite_color" "blue"
option "operating_currency" "CHF"
option "operating_currency" "PLN"
"#;
let beancount = beancount_parser_2::parse::<f64>(input).unwrap();
assert_eq!(beancount.option("favorite_color"), Some("blue"));
assert_eq!(beancount.option("operating_currency"), Some("CHF"));
assert_eq!(beancount.option("foo"), None);Trait Implementations§
Source§impl<D: Clone> Clone for BeancountFile<D>
impl<D: Clone> Clone for BeancountFile<D>
Source§fn clone(&self) -> BeancountFile<D>
fn clone(&self) -> BeancountFile<D>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<D> Freeze for BeancountFile<D>
impl<D> RefUnwindSafe for BeancountFile<D>where
D: RefUnwindSafe,
impl<D> Send for BeancountFile<D>where
D: Send,
impl<D> Sync for BeancountFile<D>where
D: Sync,
impl<D> Unpin for BeancountFile<D>where
D: Unpin,
impl<D> UnwindSafe for BeancountFile<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more