1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! How the Dart binding spells a tagged-union narrowing, in the form the field resolver needs
//! to render a doc snippet that steps into a variant payload.
//!
//! ~keep Unlike C#, the authority here is not alef. The Dart binding is flutter_rust_bridge
//! output (see `backends::dart`), so `<Union>_<Variant>` is frb/freezed's own subclass naming
//! and alef renders nothing that could be read as the source of truth. The one place that
//! naming is already encoded and proven against a compiled consumer is the assertion emitter's
//! `narrow_tagged_union_expression`; this builds the same two facts so the snippet path and the
//! assertion path cannot spell the cast differently. The payload accessor goes through
//! `codegen::naming::dart_tuple_field_identifier`, which is what the binding generator itself
//! uses to name a tuple field, so `_0` becomes `field0` here for the same reason it does there.
use cratedart_tuple_field_identifier;
use crateEnumDef;
use crateVariantAccessorMap;
/// Build the Dart narrowing map: the freezed subclass to cast to, plus the accessor for the
/// payload inside it.
///
/// Only variants carrying exactly one field are included. A unit variant has no payload to
/// step into, and a multi-field variant has no single accessor that could stand for one, so
/// offering either would render a member that does not exist.
pub