Macro assertables::assert_starts_with

source ·
macro_rules! assert_starts_with {
    ($a:expr, $b:expr $(,)?) => { ... };
    ($a:expr, $b:expr, $($message:tt)+) => { ... };
}
Expand description

Assert an expression (such as a string) starts with an expression (such as a string).

Pseudocode:
a.starts_with(b)

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

let a = "alfa";
let b = "al";
assert_starts_with!(a, b);

let a = "alfa";
let b = "fa";
assert_starts_with!(a, b);
// assertion failed: `assert_starts_with!(a, b)`
// https://docs.rs/assertables/8.7.0/assertables/macro.assert_starts_with.html
//  a label: `a`,
//  a debug: `\"alfa\"`,
//  b label: `b`,
//  b debug: `\"fa\"`

§Module macros