MCPcopy Index your code
hub / github.com/github/copilot-sdk / wrapOption

Function wrapOption

scripts/codegen/rust.ts:844–857  ·  view source on GitHub ↗
(rustType: string, isRequired: boolean)

Source from the content-addressed store, hash-verified

842}
843
844function wrapOption(rustType: string, isRequired: boolean): string {
845 if (isRequired) return rustType;
846 // Already wrapped in Option — don't double-wrap.
847 if (rustType.startsWith("Option<")) {
848 return rustType;
849 }
850 // Non-required Vec/HashMap must be Option<Vec<…>> / Option<HashMap<…>>
851 // so the SDK can distinguish "field omitted" (None) from "explicitly
852 // empty" (Some(vec![])). Bare Vec/HashMap with #[serde(default)] would
853 // serialize as `[]`/`{}` for unset fields, which patch-style request
854 // types (e.g. SessionUpdateOptionsParams) interpret as "clear the
855 // list" — silently wiping server-side state set elsewhere.
856 return `Option<${rustType}>`;
857}
858
859// ── Struct emission ─────────────────────────────────────────────────────────
860

Callers 1

resolveRustTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…