opentitanlib/util/regex.rs
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#[macro_export]
6macro_rules! regex {
7 ($lit:literal) => {{
8 static RE: ::std::sync::LazyLock<::regex::Regex> =
9 ::std::sync::LazyLock::new(|| ::regex::Regex::new($lit).unwrap());
10 &*RE
11 }};
12 (b; $lit:literal) => {{
13 static RE: ::std::sync::LazyLock<::regex::bytes::Regex> =
14 ::std::sync::LazyLock::new(|| ::regex::bytes::Regex::new($lit).unwrap());
15 &*RE
16 }};
17}