问题描述
有 sp_std 模块,https://docs.rs/sp-std/3.0.0/sp_std/fmt/index.html
但是使用格式!或字符串给出错误:
let Vote_string = format!("{}-{}",account_string,phrase_string);
错误:在此范围内找不到宏 format
let phrase_string = String::from_utf8(phrase.clone()).unwrap();
^^^^^^ 使用未声明的类型 String
导入use sp_std::string::String;
不起作用。
解决方法
Shawn 在上述评论中的回答是最好的:
一般来说,您不应该在运行时进行字符串操作之类的操作。这通常意味着您没有正确地将运行时用于关键的共识驱动逻辑。但是,要将两个字符串连接为 Vec,您只需将一个 vec 扩展为另一个。 doc.rust-lang.org/std/vec/struct.Vec.html#method.append