basic
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 §
Greeting macro: expands to a hello string.
Examples
let s = basic::hello!("world");
assert_eq!(s, "hello, world");
Structs §
Widget §
A widget that can be published.
Examples
let mut w = Widget::new("hero");
w.publish();
assert!(w.is_published());
use basic::Widget;
fn main() {
let mut w = Widget::new("hero");
w.publish();
assert!(w.is_published());
}
Implementations §
impl Widget
new
fn new(name: impl Into<String>) -> SelfConstruct 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) -> boolReturns true if publish has been called.
Trait Implementations §
impl Borrow for Widget
borrow
fn borrow(self: &Self) -> &Timpl BorrowMut for Widget
borrow_mut
fn borrow_mut(self: &mut Self) -> &mut Timpl Into for Widget
into
fn into(self: Self) -> UCalls U::from(self).
That is, this conversion is whatever the implementation of
chooses to do.From<T> for U
impl From for Widget
from
fn from(t: T) -> TReturns 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) -> TypeIdimpl Introducer for Widget
introduce
fn introduce(self: &Self) -> Stringimpl 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 §
An old wrapper that has been replaced by Widget.
Examples
// 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) -> &Timpl BorrowMut for LegacyWidget
borrow_mut
fn borrow_mut(self: &mut Self) -> &mut Timpl Into for LegacyWidget
into
fn into(self: Self) -> UCalls U::from(self).
That is, this conversion is whatever the implementation of
chooses to do.From<T> for U
impl From for LegacyWidget
from
fn from(t: T) -> TReturns 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) -> TypeIdimpl 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 §
Status that a widget can be in.
Trait Implementations §
impl Borrow for Status
borrow
fn borrow(self: &Self) -> &Timpl BorrowMut for Status
borrow_mut
fn borrow_mut(self: &mut Self) -> &mut Timpl Into for Status
into
fn into(self: Self) -> UCalls U::from(self).
That is, this conversion is whatever the implementation of
chooses to do.From<T> for U
impl From for Status
from
fn from(t: T) -> TReturns 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) -> TypeIdimpl 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 §
Anything that can introduce itself in one short sentence.
Examples
use basic::{Introducer, Widget};
let w = Widget::new("gamma");
println!("{}", w.introduce());
Required Methods §
introduce
fn introduce(self: &Self) -> StringProduce the introduction line.
Trait Implementations §
impl Introducer for Widget
introduce
fn introduce(self: &Self) -> StringFunctions §
greet §
fn greet(name: &str) -> StringReturns 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
let _w = basic::Widget::new("delta");
let _d: i32 = _w; // type mismatch on purpose