rakata_formats/derive_support.rs
1//! What the `GffModel` derive's generated code calls.
2//!
3//! A proc macro has no `$crate`, so its output names paths in full and they
4//! have to resolve somewhere. Nothing here is meant to be written by hand.
5
6use rakata_core::ResRef;
7
8/// Builds a [`ResRef`] from a declared literal.
9///
10/// # Panics
11///
12/// Panics if the literal is not a valid resref, meaning longer than sixteen
13/// bytes or not ASCII. The derive calls this from a `const` block, so the
14/// panic fails the build at the offending declaration rather than at run
15/// time, and an invalid default cannot be quietly replaced by a blank.
16#[must_use]
17pub const fn resref_default(text: &str) -> ResRef {
18 match ResRef::const_new(text) {
19 Ok(value) => value,
20 Err(_) => panic!("a declared resref default is not a valid resref"),
21 }
22}