首页 > 解决方案 > 如何在 no_std 环境中连接字符串?

问题描述

我正在尝试&str在不使用 std 的情况下连接两个字符串 () 或在 Rust 中转换字符串中的字节数组。我看到了,core::str::from_utf8但这不是我要找的。

我正在寻找类似的东西

let b: [u8; 2] = [97, 98];
let result: &str = core::str::array_to_string(b); // "ab"

或者

let a: &str = "Hello ";
let b: &str = "world !";
let result: &str = core::str::concatenate(a, b);

标签: stringrustconcatenation

解决方案


推荐阅读