Hello you need to my ask something about rust

What does this lines of code mean?

pub trait CacheableItem: Clone + Default + fmt::Debug + Decodable + Encodable {
  type Address: AsRef<[u8]> + Clone + fmt::Debug + Eq + Hash; 
  fn is_null(&self) -> bool;

impl<T: Summary + Clone + Default > Controller<T> 

fn is_null(&self) -> bool
// Other codes


Can you be a little more specific? There are a lot of different language features being used there, and not a lot of context for what the actual goal is.

If you don't know where to start The Rust Book may be a good choice for learning more.

just wondering what that means
<T: Debug + Clone>

What does he mean by "Debug + Clone" in this line?

Also, could a struct or enumeration be used instead of using trait in this line, for example:

struct Point {
    x: i32,
    y: i32,

<T: Point>
<T: Point + Debug + Clone>

<T: Debug + Clone> means roughly "Each time this item is used there will be a concrete type in place of T, but we don't know anything about that type except that it must implement both Debug and Clone"

You can't use a struct there, only traits.


In the future, please properly format your code:

I know that some people answer questions that aren't properly formatted, but I certainly don't.

Sorry didn't see the formatting option I formatted it now

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.