unicode作为向量阵列的范围

发布于 2025-02-01 14:52:33 字数 108 浏览 2 评论 0 原文

我试图将Unicodes从 \ u0300 中获取为 \ u036f 作为Rust中的数组或向量。

我尝试了几件事,但是那些还没有奏效。

I'm trying to get the unicodes from \u0300 to \u036f as an array or a vector in Rust.

I tried several things but those haven't worked yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请叫√我孤独 2025-02-08 14:52:33

您可以创建 char s的范围,然后将它们收集到 vec

Vec::from_iter('\u{0300}'..='\u{036f}')

Playground

创建一个数组更加困难,但也可能有可能:

const LEN: usize = '\u{036f}' as usize - '\u{0300}' as usize;
let mut arr = ['\0'; LEN];
for (item, ch) in std::iter::zip(&mut arr, '\u{0300}'..='\u{036f}') {
    *item = ch;
}

游乐场

You can create a range of chars, and collect them into a Vec:

Vec::from_iter('\u{0300}'..='\u{036f}')

Playground.

Creating an array is a little more difficult, but also possible:

const LEN: usize = '\u{036f}' as usize - '\u{0300}' as usize;
let mut arr = ['\0'; LEN];
for (item, ch) in std::iter::zip(&mut arr, '\u{0300}'..='\u{036f}') {
    *item = ch;
}

Playground.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文