Show-option: convenient methods and macro for showing Options to user

Library for displaying Options to user without unnecessary conversions and allocations.

use show_option::prelude::*;
 
println!("received bytes: {}", None::<usize>.show_or("none")); // "received bytes: none"
println!("received: {}", Some(20).show_suffixed_or(" bytes", "none")); // "received: 20 bytes"

println!("amount: {}", Some(20).show_prefixed_or("$", "-")); // "amount: $20"
println!("amount: {}", format_option!(Some(20), "${}", "-")); // "amount: $20"

Repository: GitHub - kriomant/show-option: Rust library for displaying Option's
Documentation: show_option - Rust

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.