macro_rules! embedded_dictionary {
($dir:literal, $loader:ident) => { ... };
}Expand description
Generates the embedded-dictionary loader for a dictionary crate.
The dictionary data is baked into the binary with include_bytes!,
reading from the LINDERA_WORKDIR directory populated by the crate’s
build script.
The data is bound to statics rather than consts deliberately. A const
body is encoded into the crate’s metadata, so a const here would put a copy
of every dictionary byte into lib.rmeta at roughly 4x its size — several
hundred megabytes per dictionary crate, re-read by every downstream crate.
The data is private to load() below and never const-evaluated, so a static
is all that is needed.
$dir— the dictionary subdirectory insideLINDERA_WORKDIR(e.g."/lindera-ipadic").$loader— the public loader struct name (e.g.EmbeddedIPADICLoader).
§Example
ⓘ
lindera_dictionary::embedded_dictionary!("/lindera-ipadic", EmbeddedIPADICLoader);