#[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 duplicate 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> 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