Struct show_notes::e001::TVShow

source ·
pub struct TVShow {
    pub theme: String,
    pub year: i32,
    director: String,
}
Expand description

This is a sample structure, to demonstrate rustdoc/cargo doc.

All of this will be attached to the structure definition when you see it live on the site. If you need to document members, you can do it inline!

It’s worth taking a look at the source for this: you can see how private and public fields are handled differently in the documentation.

Fields§

§theme: String

Here is a string telling us what the theme song was.

§year: i32

Here is the year the show premiered.

§director: String

Here is the director—but (s)he’s rather shy and private.

Implementations§

source§

impl TVShow

You can also document the implementation. This is usually not going to be something you particularly need with a struct, because you can just attach the documentation to the struct itself. However, it is the kind of thing that could be useful if you are implementing a trait. (More on that in a later episode!)

source

pub fn new(theme: &str, year: i32, director: &str) -> TVShow

This documents a fairly ho-hum structure constructor.

let a_struct = TVShow::new("The Answer", 42, "Joss Whedon");

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.