Examples
Doctests
Aggregated doctests across the workspace.
Doctests
8 runnable examples.
basic::greet
use basic::greet;
assert_eq!(greet("Ada"), "hello, Ada");
basic::Widget
let mut w = Widget::new("hero");
w.publish();
assert!(w.is_published());
new
use basic::Widget;
let w = Widget::new("alpha");
assert!(!w.is_published());
publish
use basic::Widget;
let mut w = Widget::new("beta");
w.publish();
assert!(w.is_published());
basic::Introducer
no_run
use basic::{Introducer, Widget};
let w = Widget::new("gamma");
println!("{}", w.introduce());
basic::LegacyWidget
should_panic
// Forces a panic at runtime for documentation purposes.
let _w: basic::LegacyWidget = panic!("legacy");
basic::describe
compile_fail
let _w = basic::Widget::new("delta");
let _d: i32 = _w; // type mismatch on purpose
basic::hello
ignore
let s = basic::hello!("world");
assert_eq!(s, "hello, world");