1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate;
use File;
use io;
use ;
/// Reads a `Formula` from a file using the given `FormulaFactory`.
///
/// If the file has multiple lines, the result will be the conjunction ([`FormulaFactory::and`])
/// of the formulas in each line.
///
/// If the file cannot be read or contains an invalid formula, a respective [`io::Error`] is returned.
///
/// # Examples
///
/// Assume there is a file `path/to/my-formula.txt` with the contents:
/// ```text
/// (A | B)
/// ~(C => A)
/// E
/// ```
///
/// ```no_run
/// # use logicng::formulas::{FormulaFactory, ToFormula};
/// # use logicng::io::read_formula;
/// let f = FormulaFactory::new();
/// let my_formula = read_formula("path/to/my-formula.txt", &f).expect("Something went wrong");
/// let expected = "(A | B) & ~(C => A) & E".to_formula(&f);
/// assert_eq!(my_formula, expected)
/// ```