Rust Programming Tutorial #28 - Defining Traits

Published: 11 December 2017
on channel: dcode
23,771
452

Similar to interfaces in other languages, traits allow you to set 'rules' or 'requirements' for a particular struct in order for it to be considered to be 'something'.

In this video we create a trait called 'HasVoiceBox' which says that any Struct implementing this trait must have a speak() and can_speak() method defined on it.

For more information refer to the Rust documentation:
https://doc.rust-lang.org/1.8.0/book/...

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


On this page of the site you can watch the video online Rust Programming Tutorial #28 - Defining Traits with a duration of hours minute second in good quality, which was uploaded by the user dcode 11 December 2017, share the link with friends and acquaintances, this video has already been watched 23,771 times on youtube and it was liked by 452 viewers. Enjoy your viewing!