Function stageleft::add_private_reexport

source ·
pub fn add_private_reexport(from: Vec<&'static str>, to: Vec<&'static str>)
Expand description

Adds a private module re-export transformation to the type quoting system.

Sometimes, the quote_type function may produce an uncompilable reference to a type inside a private module if the type is re-exported from a public module (because Rust’s type_name only gives the path to the original definition).

This function adds a rewrite rule for such cases, where the from path is replaced with the to path. The paths are given as a list of strings, where each string is a segment of the path. The from path is matched against the beginning of the type path, and if it matches, the to path is substituted in its place. The from path may contain a wildcard * to glob a segment.

§Example

stageleft::add_private_reexport(
    vec!["std", "collections", "hash", "map"],
    vec!["std", "collections", "hash_map"],
);