procon_lib_rs

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub CoCo-Japan-pan/procon_lib_rs

:warning: crates/utils/localize_closure/src/lib.rs

Code

//! From <https://github.com/to-omer/competitive-library/blob/master/crates/competitive/src/tools/mlambda.rs>

/// Macro that define closure like macro. Unlike closure, this macro localizes variable capture.
///
/// # Example
/// ```
/// # use localize_closure::mlambda;
/// let graph: Vec<Vec<usize>> = vec![vec![1, 2], vec![2], vec![]];
/// let mut deq = std::collections::VecDeque::new();
/// let mut dist: Vec<usize> = vec![!0; 3];
/// mlambda!(
///     fn push(v: usize, cost: usize) {
///         if dist[v] > cost {
///             dist[v] = cost;
///             deq.push_back(v);
///         }
///     }
/// );
/// push!(0, 0);
/// while let Some(v) = deq.pop_front() {
///     for &to in &graph[v] {
///         push!(to, dist[v] + 1);
///     }
/// }
/// assert_eq!(vec![0, 1, 1], dist);
/// ```
#[macro_export]
macro_rules! mlambda {
    (
        @def ($dol:tt) [$([$x:ident])*][$([$y:ident, $($z:tt)*])*]
        fn $name:ident($($args:tt)*) -> $ret:ty $body:block
    ) => {
        macro_rules! $name {
            ($($dol $x:expr),* $dol(,)?) => {{
                $(let $y $($z)* = $dol $y;)*
                $body
            }}
        }
    };
    (@pre () [$($x:tt)*][$($y:tt)*] fn $name:ident($($args:tt)*) -> $ret:ty $body:block) => {
        $crate::mlambda!(@def ($) [$($x)*][$($y)*] fn $name($($args)*) -> $ret $body)
    };
    (@pre () [$($x:tt)*][$($y:tt)*] fn $name:ident($($args:tt)*) $body:block) => {
        $crate::mlambda!(@pre () [$($x)*][$($y)*] fn $name($($args)*) -> () $body)
    };
    (@pre ($arg:ident $(:$ty:ty)?) [$($x:tt)*][$($y:tt)*] $($rest:tt)*) => {
        $crate::mlambda!(@pre () [$($x)* [$arg]][$($y)* [$arg, $(:$ty)?]] $($rest)*)
    };
    (@pre ($arg:ident $(:$ty:ty)?, $($args:tt)*) [$($x:tt)*][$($y:tt)*] $($rest:tt)*) => {
        $crate::mlambda!(@pre ($($args)*) [$($x)* [$arg]][$($y)* [$arg, $(:$ty)?]] $($rest)*)
    };
    (fn $name:ident($($args:tt)*) $($rest:tt)*) => {
        $crate::mlambda!(@pre ($($args)*) [][] fn $name($($args)*) $($rest)*)
    };
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/site-packages/onlinejudge_verify/languages/rust.py", line 288, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page