News Score: Score the News, Sort the News, Rewrite the Headlines

An introduction to advanced Rust traits and generics

Hello world! In this post we’re going to give a quick refresher course on Rust traits and generics, as well as implementing some more advanced trait bounds and type signatures. A quick refresher on Rust traits Writing a Rust trait is as simple as this: pub trait MyTrait { fn some_method(&self) -> String; } Whenever a type implements MyTrait, you can guarantee that it will implement the some_method() function. To implement a trait simply requires that you implement the required methods (the ones ...

Read more at shuttle.rs

© News Score  score the news, sort the news, rewrite the headlines