oak_rust/language/
mod.rs

1#[doc = include_str!("readme.md")]
2use crate::{ast::RustRoot, lexer::RustTokenType, parser::RustElementType};
3use oak_core::{Language, LanguageCategory};
4use serde::{Deserialize, Serialize};
5
6/// Rust 语言配置和元数据。
7#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub struct RustLanguage {
9    /// Allow using `unsafe` blocks and functions
10    pub allow_unsafe: bool,
11    /// Allow using `async` functions and blocks
12    pub allow_async: bool,
13    /// Enable experimental features
14    pub experimental_features: bool,
15}
16
17impl Default for RustLanguage {
18    fn default() -> Self {
19        Self { allow_unsafe: true, allow_async: true, experimental_features: false }
20    }
21}
22
23impl Language for RustLanguage {
24    const NAME: &'static str = "rust";
25    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
26
27    type TokenType = RustTokenType;
28    type ElementType = RustElementType;
29    type TypedRoot = RustRoot;
30}