Skip to main content

s

Macro s 

Source
macro_rules! s {
    ($start:tt : $end:expr) => { ... };
    ($start:tt : $end:tt : $step:expr) => { ... };
    ($start:tt :) => { ... };
    ($start:tt :: $step:expr) => { ... };
    (: $end:tt) => { ... };
    (: $end:tt : $step:expr) => { ... };
    (:: $step:expr) => { ... };
    (:) => { ... };
}
Expand description

Create a Slice with python-like syntax.

s!(1..5)    // Slice { start: 1, end: Some(5), step: 1 }
s!(1:)      // Slice { start: 1, end: None, step: 1 }
s!(1::2)    // Slice { start: 1, end: None, step: 2 }
s!(..5)     // Slice { start: 0, end: Some(5), step: 1 }
s!(:)       // Slice { start: 0, end: None, step: 1 }
s!(::3)     // Slice { start: 0, end: None, step: 3 }