pub trait Register<L> where
    L: Lang
{ fn register(self, tokens: &mut Tokens<L>); }
Expand description

Helper trait to convert something into a stream of registrations.

Thanks to this, we can provide a flexible number of arguments to register(), like a tuple.

This is trait is very similar to FormatInto, except that it constrains the types that can be “registered” to only language items. An implementation of register must not be used as a substitute for FormatInto.

Examples

use genco::prelude::*;

let mut tokens = rust::Tokens::new();

let hash_map = rust::import("std::collections", "HashMap");
let btree_map = rust::import("std::collections", "BTreeMap");

tokens.register((hash_map, btree_map));

assert_eq!(
    vec![
        "use std::collections::{BTreeMap, HashMap};",
    ],
    tokens.to_file_vec()?,
);

Required methods

Convert the type into tokens.

Implementations on Foreign Types

Implementors