Module genco::lang::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

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

Enums

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

Functions

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

Type Aliases

  • Tokens container specialization for Rust.