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.
This commit is contained in:
Matthias Krüger 2025-02-19 21:16:01 +01:00 committed by GitHub
commit 84e9f29007
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 49 additions and 18 deletions

View file

@ -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();
{