From Trait in Rust

From trait in Rust allow types to be created or converted from other types. From trait is used in the rust standard library. It's simple and yet effective. Is common to see From used with Into. However today I want to focus on the From trait. Thinking about coupling point of view you end up coupling 2 or more types, however, in sense of convenience is pretty useful since you dont need to lookup for other structs or external converters. You can use From in order to make it easy to convert from basic types to your types.I have a simple video showing From trait in action. Let's get started!

The Video

The Code

https://github.com/diegopacheco/rust-playground/tree/master/from-trait-fun

Cheers,

Diego Pacheco

Popular posts from this blog

Kafka Streams with Java 15

Rust and Java Interoperability

HMAC in Java