tree-sitter/lib/language/language.rs
Max Brunsfeld 38137c71b2 feat!: introduce tree-sitter-language crate for grammar crates to depend on
Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-05-24 21:54:07 -04:00

20 lines
609 B
Rust

/// LanguageFn wraps a C function that returns a pointer to a tree-sitter grammer.
#[repr(transparent)]
pub struct LanguageFn(unsafe extern "C" fn() -> *const ());
impl LanguageFn {
/// Creates a `LanguageFn`.
///
/// # Safety
///
/// Only call this with language functions generated from grammars
/// by the Tree-sitter CLI.
pub const unsafe fn from_raw(f: unsafe extern "C" fn() -> *const ()) -> Self {
Self(f)
}
/// Gets the function wrapped by this `LanguageFn`.
pub const fn into_raw(self) -> unsafe extern "C" fn() -> *const () {
self.0
}
}