Module genco::lang::dart

source ·
Expand description

Specialization for Dart code generation.

String Quoting in Dart

Since Java uses UTF-16 internally, string quoting for high unicode characters is done through surrogate pairs, as seen with the 😊 below.

use genco::prelude::*;

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

String Interpolation in Dart

Strings can be interpolated in Dart, by using the special $_(<string>) escape sequence.

use genco::prelude::*;

let toks: dart::Tokens = quote!($[str](  Hello: $var  ));
assert_eq!("\"  Hello: $var  \"", toks.to_string()?);

let toks: dart::Tokens = quote!($[str](  Hello: $(a + b)  ));
assert_eq!("\"  Hello: ${a + b}  \"", toks.to_string()?);

Structs

  • Config data for Dart formatting.
  • Language specialization for Dart.
  • Format a doc comment where each line is preceeded by ///.
  • Format state for Dart.
  • The import of a Dart type import "dart:math";.

Enums

  • A type-erased language item capable of holding any kind.

Functions

  • Format a doc comment where each line is preceeded by ///.
  • The import of a Dart type import "dart:math";.

Type Aliases

  • Tokens container specialization for Dart.