mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-16 10:12:26 +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:
@@ -235,7 +235,9 @@ impl<'a> PrettyPrinter<'a> {
|
||||
}
|
||||
|
||||
pub fn syntaxes(&self) -> impl Iterator<Item = &SyntaxReference> {
|
||||
self.assets.syntaxes().iter()
|
||||
// We always use assets from the binary, which are guaranteed to always
|
||||
// be valid, so get_syntaxes() can never fail here
|
||||
self.assets.get_syntaxes().unwrap().iter()
|
||||
}
|
||||
|
||||
/// Pretty-print all specified inputs. This method will "use" all stored inputs.
|
||||
|
Reference in New Issue
Block a user