ctb_formats_rust/rust.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3This file is part of Collective Toolbox, a database and document workspace and utilities.
4Copyright (C) 2026 Collective Toolbox Developers
5Contact: info@collectivetoolbox.com
6
7This program is free software: you can redistribute it and/or modify it under
8the terms of the GNU Affero General Public License as published by the Free
9Software Foundation, either version 3 of the License, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
15
16You should have received a copy of the GNU Affero General Public License along
17with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20//! Helpers for Rust programming language.
21
22#[allow(
23 unused_imports,
24 clippy::wildcard_imports,
25 reason = "Standard workspace crate prelude"
26)]
27pub(crate) use ctb_utilities::*;
28
29// static RUST_DATA_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/data");
30
31// pub(crate) fn get_rust_data(key: &str) -> Option<Vec<u8>> {
32// get_embedded_asset(&RUST_DATA_DIR, key)
33// }
34
35use check_keyword::CheckKeyword;
36
37/// Checks whether a string is a reserved keyword in Rust.
38#[must_use]
39pub fn is_reserved_word<T>(word: &T) -> bool
40where
41 T: ?Sized + AsRef<str>,
42{
43 word.as_ref().is_keyword()
44}
45
46#[cfg(test)]
47#[allow(
48 clippy::panic,
49 clippy::expect_used,
50 clippy::unwrap_used,
51 clippy::unwrap_in_result,
52 clippy::panic_in_result_fn,
53 clippy::indexing_slicing,
54 clippy::arithmetic_side_effects,
55 reason = "Standard repository test boilerplate"
56)]
57mod tests {
58 use crate::utilities::{assert_vec_u8_eq, assert_vec_u8_ok_eq};
59 use ctb_formats_utilities::assert_string_ok_eq;
60
61 use super::*;
62}