Function mt940::parse_fields
source · [−]Expand description
Parse a MT940 statement to a list of its fields.
ⓘ
ignored stuff in front
blah blah
:123:something
:456:something else
:789:even with
new line
like this
:012:and then more stuff
The result will be a Vec
of Field
s.
There is no validation of the contents of the Field
s. The contents could be nonsensical.
Example
use mt940::{parse_fields, Field};
let input = "ignored stuff in front\r\n\
blah blah\r\n\
:123:something\r\n\
:456:something else\r\n\
:789:even with\r\n\
new line\r\n\
like this\r\n\
:012:and then more stuff\r\n\
\r\n";
let expected = vec![
Field::new("123", "something"),
Field::new("456", "something else"),
Field::new("789", "even with\nnew line\nlike this"),
Field::new("012", "and then more stuff"),
];
let input_parsed = parse_fields(input).unwrap();
assert_eq!(expected, input_parsed);