1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 19:02:22 +01:00

HighlightingAssets: Make .syntaxes() and syntax_for_file_name() failable

Or rather, introduce new versions of these methods and deprecate the old ones.

This is preparation to enable robust and user-friendly support for lazy-loading.
With lazy-loading, we don't know if the SyntaxSet is valid until after we try to
use it, so wherever we try to use it, we need to return a Result. See discussion
about panics in #1747.
This commit is contained in:
Martin Nordholts
2021-07-27 09:43:51 +02:00
parent c0e09662b4
commit a81009607a
6 changed files with 95 additions and 39 deletions

View File

@@ -26,7 +26,7 @@ fn no_duplicate_extensions() {
let mut extensions = HashSet::new();
for syntax in assets.syntaxes() {
for syntax in assets.get_syntaxes().expect("this is a #[test]") {
for extension in &syntax.file_extensions {
assert!(
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),