about summary refs log tree commit diff
path: root/library/std/src/fs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-19 21:16:01 +0100
committerGitHub <noreply@github.com>2025-02-19 21:16:01 +0100
commit84e9f2900758902fbbe6d09ec0f35546c220dedf (patch)
treed243042f4fb3b864cacbe50f6d6dddc9b798c0a9 /library/std/src/fs
parented49386d3aa3a445a9889707fd405df01723eced (diff)
parenteec49bbf59c922060a5785a47d885529e6cb2ac8 (diff)
Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-se
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants

This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature.

The constants are currently applied in the `alloc`, `core` and `std` libraries.
Diffstat (limited to 'library/std/src/fs')
-rw-r--r--library/std/src/fs/tests.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index 8e307f57cf9..1a266f71965 100644
--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -1,5 +1,6 @@
 use rand::RngCore;
 
+use crate::char::MAX_LEN_UTF8;
 use crate::fs::{self, File, FileTimes, OpenOptions};
 use crate::io::prelude::*;
 use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
@@ -155,7 +156,7 @@ fn file_test_io_non_positional_read() {
 #[test]
 fn file_test_io_seek_and_tell_smoke_test() {
     let message = "ten-four";
-    let mut read_mem = [0; 4];
+    let mut read_mem = [0; MAX_LEN_UTF8];
     let set_cursor = 4 as u64;
     let tell_pos_pre_read;
     let tell_pos_post_read;
@@ -356,7 +357,7 @@ fn file_test_io_seek_shakedown() {
     let chunk_one: &str = "qwer";
     let chunk_two: &str = "asdf";
     let chunk_three: &str = "zxcv";
-    let mut read_mem = [0; 4];
+    let mut read_mem = [0; MAX_LEN_UTF8];
     let tmpdir = tmpdir();
     let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt");
     {
@@ -621,7 +622,7 @@ fn file_test_directoryinfo_readdir() {
         check!(w.write(msg));
     }
     let files = check!(fs::read_dir(dir));
-    let mut mem = [0; 4];
+    let mut mem = [0; MAX_LEN_UTF8];
     for f in files {
         let f = f.unwrap().path();
         {