forked from mirror/presenterm
1.6 KiB
1.6 KiB
| theme | ||||||||
|---|---|---|---|---|---|---|---|---|
|
Code styling
This presentation shows how to:
- Left-align code blocks.
- Have code blocks without background.
- Execute code snippets.
pub struct Greeter {
prefix: &'static str,
}
impl Greeter {
/// Greet someone.
pub fn greet(&self, name: &str) -> String {
let prefix = self.prefix;
format!("{prefix} {name}!")
}
}
fn main() {
let greeter = Greeter { prefix: "Oh, hi" };
let greeting = greeter.greet("Mark");
println!("{greeting}");
}
Column layouts
The same code as the one before but split into two columns to split the API definition with its usage:
The Greeter type
pub struct Greeter {
prefix: &'static str,
}
impl Greeter {
/// Greet someone.
pub fn greet(&self, name: &str) -> String {
let prefix = self.prefix;
format!("{prefix} {name}!")
}
}
Using the Greeter
fn main() {
let greeter = Greeter {
prefix: "Oh, hi"
};
let greeting = greeter.greet("Mark");
println!("{greeting}");
}
Code execution
Run commands from the presentation and display their output dynamically.
for i in $(seq 1 5)
do
echo "hi $i"
sleep 0.5
done
Code execution - stderr
Output from stderr will also be shown as output.
echo "This is a successful command"
echo "This message redirects to stderr" >&2
echo "This is a successful command again"
man # Missing argument