MCPcopy Create free account
hub / github.com/arcjet/gravity / case_dispatch_name

Function case_dispatch_name

cmd/gravity/src/lib.rs:45–53  ·  view source on GitHub ↗

Kebab-case Go name for the type a variant case dispatches against in a type-switch.

(variant_name: &str, case: &Case, resolve: &Resolve)

Source from the content-addressed store, hash-verified

43/// Kebab-case Go name for the type a variant case dispatches against in a
44/// type-switch.
45pub fn case_dispatch_name(variant_name: &str, case: &Case, resolve: &Resolve) -> String {
46 match case_dispatch_kind(case, resolve) {
47 CaseDispatchKind::DirectRecord => match case.ty {
48 Some(Type::Id(payload_id)) => qualified_type_name(payload_id, resolve),
49 _ => unreachable!("DirectRecord requires a Type::Id payload"),
50 },
51 CaseDispatchKind::Wrapped => format!("{variant_name}-{}", case.name),
52 }
53}
54
55/// Returns a globally-unique kebab-case name suitable for deriving a Go
56/// identifier from a WIT type. WIT lets two interfaces declare types of

Callers 1

emitMethod · 0.85

Calls 2

case_dispatch_kindFunction · 0.85
qualified_type_nameFunction · 0.85

Tested by

no test coverage detected