basic

basic

Basic fixture crate used by the sourcey-rustdoc adapter tests.

Basic fixture crate used by the sourcey-rustdoc adapter tests.

Exercises the minimum surface Phase 1 needs: a free function, a struct with an inherent impl, a trait with one method, a trait impl on the struct, and two doctests (one with hidden setup lines and an explicit main wrapper, one plain).

Macros §

hello §

macro_rules! hello

Greeting macro: expands to a hello string.

Examples
ignore
let s = basic::hello!("world");
assert_eq!(s, "hello, world");

Structs §

Widget §

pub struct basic::Widget { /* ... */ }

A widget that can be published.

Examples
let mut w = Widget::new("hero");
w.publish();
assert!(w.is_published());
Run

Implementations §

impl Widget

new

fn new(name: impl Into<String>) -> Self

Construct a new widget with the given name.

Examples
use basic::Widget;

let w = Widget::new("alpha");
assert!(!w.is_published());

publish

fn publish(self: &mut Self)

Mark the widget as published.

Examples
use basic::Widget;

let mut w = Widget::new("beta");
w.publish();
assert!(w.is_published());

is_published

fn is_published(self: &Self) -> bool

Returns true if publish has been called.

Trait Implementations §

impl Borrow for Widget

borrow

fn borrow(self: &Self) -> &T

impl BorrowMut for Widget

borrow_mut

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

impl Into for Widget

into

fn into(self: Self) -> U

Calls U::from(self).

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

impl From for Widget

from

fn from(t: T) -> T

Returns the argument unchanged.

impl TryInto for Widget

Error

try_into

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

impl TryFrom for Widget

Error

try_from

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

impl Any for Widget

type_id

fn type_id(self: &Self) -> TypeId

impl Introducer for Widget

introduce

fn introduce(self: &Self) -> String

impl Send for Widget

impl Sync for Widget

impl Freeze for Widget

impl UnsafeUnpin for Widget

impl Unpin for Widget

impl UnwindSafe for Widget

impl RefUnwindSafe for Widget

LegacyWidget §

pub struct basic::LegacyWidget { /* ... */ }
👎 Deprecated since 0.0.2: use Widget instead

An old wrapper that has been replaced by Widget.

Examples
should_panic
// Forces a panic at runtime for documentation purposes.
let _w: basic::LegacyWidget = panic!("legacy");

Trait Implementations §

impl Borrow for LegacyWidget

borrow

fn borrow(self: &Self) -> &T

impl BorrowMut for LegacyWidget

borrow_mut

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

impl Into for LegacyWidget

into

fn into(self: Self) -> U

Calls U::from(self).

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

impl From for LegacyWidget

from

fn from(t: T) -> T

Returns the argument unchanged.

impl TryInto for LegacyWidget

Error

try_into

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

impl TryFrom for LegacyWidget

Error

try_from

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

impl Any for LegacyWidget

type_id

fn type_id(self: &Self) -> TypeId

impl Send for LegacyWidget

impl Sync for LegacyWidget

impl Freeze for LegacyWidget

impl UnsafeUnpin for LegacyWidget

impl Unpin for LegacyWidget

impl UnwindSafe for LegacyWidget

impl RefUnwindSafe for LegacyWidget

Enums §

Status §

pub enum basic::Status { /* ... */ }

Status that a widget can be in.

Trait Implementations §

impl Borrow for Status

borrow

fn borrow(self: &Self) -> &T

impl BorrowMut for Status

borrow_mut

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

impl Into for Status

into

fn into(self: Self) -> U

Calls U::from(self).

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

impl From for Status

from

fn from(t: T) -> T

Returns the argument unchanged.

impl TryInto for Status

Error

try_into

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

impl TryFrom for Status

Error

try_from

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

impl Any for Status

type_id

fn type_id(self: &Self) -> TypeId

impl Send for Status

impl Sync for Status

impl Freeze for Status

impl UnsafeUnpin for Status

impl Unpin for Status

impl UnwindSafe for Status

impl RefUnwindSafe for Status

Traits §

Introducer §

pub trait basic::Introducer { /* ... */ }

Anything that can introduce itself in one short sentence.

Examples
no_run
use basic::{Introducer, Widget};

let w = Widget::new("gamma");
println!("{}", w.introduce());

Required Methods §

introduce

fn introduce(self: &Self) -> String

Produce the introduction line.

Trait Implementations §

impl Introducer for Widget

introduce

fn introduce(self: &Self) -> String

Functions §

greet §

fn greet(name: &str) -> String

Returns a greeting for the given name.

Examples
use basic::greet;

assert_eq!(greet("Ada"), "hello, Ada");

describe §

fn describe(w: &Widget) -> String
#[must_use]

Inspect a widget's display string.

Examples
compile_fail
let _w = basic::Widget::new("delta");
let _d: i32 = _w; // type mismatch on purpose