nanvm_lib/vm/string/
from.rs1use crate::vm::{Any, IVm, String, ToAny, ToString};
2
3impl<A: IVm> From<&str> for String<A> {
4 fn from(value: &str) -> Self {
5 value.encode_utf16().to_string()
6 }
7}
8
9impl<A: IVm> From<&str> for Any<A> {
10 fn from(value: &str) -> Self {
11 let s: String<_> = value.into();
12 s.to_any()
13 }
14}
15
16impl<A: IVm> From<String<A>> for std::string::String {
20 fn from(value: String<A>) -> Self {
21 char::decode_utf16(value)
22 .map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
23 .collect()
24 }
25}