We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
usize
read_to_string
1 parent 175e043 commit c72c762Copy full SHA for c72c762
library/std/src/fs.rs
@@ -346,7 +346,7 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
346
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
347
fn inner(path: &Path) -> io::Result<String> {
348
let mut file = File::open(path)?;
349
- let size = file.metadata().map(|m| m.len()asusize).ok();
+ let size = file.metadata().map(|m| usize::try_from(m.len()).unwrap_or(usize::MAX)).ok();
350
let mut string = String::new();
351
string.try_reserve_exact(size.unwrap_or(0))?;
352
io::default_read_to_string(&mut file, &mut string, size)?;
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments