I'm trying to print a custom type:
struct Node<T> {
prev: Option<Box<Node<T>>>,
element: T,
next: Option<Box<Node<T>>>,
}
Now, the problem:
print!(
"{0} -> {1}",
String::from(node.element),
String::from(node.next)
);
error[E0277]: the trait bound `std::string::String: std::convert::From<T>` is not satisfied
--> src/lib.rs:10:9
|
10 | String::from(node.element),
| ^^^^^^^^^^^^ the trait `std::convert::From<T>` is not implemented for `std::string::String`
|
= help: consider adding a `where std::string::String: std::convert::From<T>` bound
= note: required by `std::convert::From::from`
error[E0277]: the trait bound `std::string::String: std::convert::From<std::option::Option<std::boxed::Box<Node<T>>>>` is not satisfied
--> src/lib.rs:11:9
|
11 | String::from(node.next)
| ^^^^^^^^^^^^ the trait `std::convert::From<std::option::Option<std::boxed::Box<Node<T>>>>` is not implemented for `std::string::String`
|
= help: the following implementations were found:
<std::string::String as std::convert::From<&'a str>>
<std::string::String as std::convert::From<std::borrow::Cow<'a, str>>>
<std::string::String as std::convert::From<std::boxed::Box<str>>>
= note: required by `std::convert::From::from`
How to cast node.element
to String
and Option<Box<Node<T>>>
to String
?