diff options
author | Markus Unterwaditzer <markus@unterwaditzer.net> | 2021-11-26 18:38:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 18:38:58 +0100 |
commit | dced8066f77f570dd3e396ec3570c71aa86c454e (patch) | |
tree | 2fb81d5f411319948c135dfaaa78bc5da6783621 /generate_entities.py | |
parent | 029c13426634e58adb3996c9a5e4d79c3e8437f2 (diff) |
Read html from io::BufRead (#8)
Diffstat (limited to 'generate_entities.py')
-rw-r--r-- | generate_entities.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/generate_entities.py b/generate_entities.py index 1a1407d..449146c 100644 --- a/generate_entities.py +++ b/generate_entities.py @@ -18,7 +18,7 @@ pub struct CharRef { pub characters: &'static str, } -pub fn try_read_character_reference(first_char: char, mut try_read: impl FnMut(&str) -> bool) -> Option<CharRef> { +pub fn try_read_character_reference<E>(first_char: char, mut try_read: impl FnMut(&str) -> Result<bool, E>) -> Result<Option<CharRef>, E> { """) for key, value in key_and_value: @@ -31,9 +31,9 @@ pub fn try_read_character_reference(first_char: char, mut try_read: impl FnMut(& first_char = key[0] key = key[1:] f.write(""" - if first_char == '%(first_char)s' && try_read("%(key)s") { - return Some(CharRef { name: "%(key)s", characters: "%(characters)s" }); + if first_char == '%(first_char)s' && try_read("%(key)s")? { + return Ok(Some(CharRef { name: "%(key)s", characters: "%(characters)s" })); } """ % {"key": key, "characters": characters, "first_char": first_char}) - f.write(" None }"); + f.write(" Ok(None) }"); |