File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 88// which is annoying with this clippy lint
99#![ allow( clippy:: default_constructed_unit_structs) ]
1010
11- use std:: fs:: File ;
11+ use std:: { fs:: File , io :: BufReader } ;
1212
1313use :: minijinja:: { machinery:: WhitespaceConfig , syntax:: SyntaxConfig } ;
1414use camino:: Utf8PathBuf ;
@@ -50,8 +50,9 @@ fn main() {
5050
5151 // Open the existing translation file if one was provided
5252 let mut tree = if let Some ( path) = & options. existing {
53- let mut file = File :: open ( path) . expect ( "Failed to open existing translation file" ) ;
54- serde_json:: from_reader ( & mut file) . expect ( "Failed to parse existing translation file" )
53+ let file = File :: open ( path) . expect ( "Failed to open existing translation file" ) ;
54+ let mut reader = BufReader :: new ( file) ;
55+ serde_json:: from_reader ( & mut reader) . expect ( "Failed to parse existing translation file" )
5556 } else {
5657 TranslationTree :: default ( )
5758 } ;
Original file line number Diff line number Diff line change 44// SPDX-License-Identifier: AGPL-3.0-only
55// Please see LICENSE in the repository root for full details.
66
7- use std:: { collections:: HashMap , fs:: File , str:: FromStr } ;
7+ use std:: { collections:: HashMap , fs:: File , io :: BufReader , str:: FromStr } ;
88
99use camino:: { Utf8Path , Utf8PathBuf } ;
1010use icu_list:: { ListError , ListFormatter , ListLength } ;
@@ -135,12 +135,14 @@ impl Translator {
135135 Err ( source) => return Err ( LoadError :: InvalidLocale { path, source } ) ,
136136 } ;
137137
138- let mut file = match File :: open ( & path) {
138+ let file = match File :: open ( & path) {
139139 Ok ( file) => file,
140140 Err ( source) => return Err ( LoadError :: ReadFile { path, source } ) ,
141141 } ;
142142
143- let content = match serde_json:: from_reader ( & mut file) {
143+ let mut reader = BufReader :: new ( file) ;
144+
145+ let content = match serde_json:: from_reader ( & mut reader) {
144146 Ok ( content) => content,
145147 Err ( source) => return Err ( LoadError :: Deserialize { path, source } ) ,
146148 } ;
You can’t perform that action at this time.
0 commit comments