Struct beancount_parser::BeancountFile 
source · #[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
use beancount_parser::BeancountFile;
let input = r#"
option "favorite_color" "blue"
option "operating_currency" "CHF"
option "operating_currency" "PLN"
"#;
let beancount: BeancountFile<f64> = input.parse().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 copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moresource§impl<D: Debug> Debug for BeancountFile<D>
 
impl<D: Debug> Debug for BeancountFile<D>
source§impl<D> Default for BeancountFile<D>
 
impl<D> Default for BeancountFile<D>
source§impl<D> Extend<Entry<D>> for BeancountFile<D>
 
impl<D> Extend<Entry<D>> for BeancountFile<D>
source§fn extend<T: IntoIterator<Item = Entry<D>>>(&mut self, iter: T)
 
fn extend<T: IntoIterator<Item = Entry<D>>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
 
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
 
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl<D> FromIterator<Entry<D>> for BeancountFile<D>
 
impl<D> FromIterator<Entry<D>> for BeancountFile<D>
Auto Trait Implementations§
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