tree-sitter/crates/language/src/language.rs
Max Brunsfeld 0fdf569571
Reorganize rust crates into a flat crates directory, simplify some CI steps (#4496)
* Move all rust crates (except lib) into crates dir, w/o nesting

* Remove stale path from .gitattributes

* Rename lib.rs files for easier navigation

* Rename mod.rs file for easier navigation

* Fix emscripten-version path

* Fix fixtures dir paths

* Use the default rustfmt settings

* Don't use nightly on CI
2025-06-06 14:25:37 -07:00

23 lines
665 B
Rust

#![no_std]
/// `LanguageFn` wraps a C function that returns a pointer to a tree-sitter grammar.
#[repr(transparent)]
#[derive(Clone, Copy)]
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`].
#[must_use]
pub const fn into_raw(self) -> unsafe extern "C" fn() -> *const () {
self.0
}
}