Module rust

Source
Expand description

Specialization for Rust code generation.

§Examples

use genco::prelude::*;

let toks: rust::Tokens = quote! {
    fn foo() -> u32 {
        42
    }
};

assert_eq!(
    vec![
        "fn foo() -> u32 {",
        "    42",
        "}",
    ],
    toks.to_file_vec()?
);

§String Quoting in Rust

Rust uses UTF-8 internally, string quoting is with the exception of escape sequences a one-to-one translation.

use genco::prelude::*;

let toks: rust::Tokens = quote!("start π 😊 \n \x7f ÿ $ end");
assert_eq!("\"start π 😊 \\n \\x7f ÿ $ end\"", toks.to_string()?);

Structs§

Config
Language configuration for Rust.
Format
Format state for Rust.
Import
The import of a Rust type use std::collections::HashMap.
Rust
Language specialization for Rust.

Enums§

Any
A type-erased language item capable of holding any kind.
ImportMode
The import mode to use when generating import statements.

Functions§

import
The import of a Rust type use std::collections::HashMap.

Type Aliases§

Tokens
Tokens container specialization for Rust.