Skip to main content

ai_agent/types/
utils.rs

1// Source: ~/claudecode/openclaudecode/src/types/utils.rs
2
3/// DeepImmutable is a TypeScript conditional type that recursively makes all
4/// properties readonly. In Rust, immutability is the default, so this type
5/// serves as documentation rather than an active constraint.
6///
7/// TypeScript:
8///   T extends (...args: never[]) => unknown ? T
9///     : T extends readonly (infer U)[] ? ReadonlyArray<DeepImmutable<U>>
10///     : T extends object ? { readonly [K in keyof T]: DeepImmutable<T[K]> }
11///     : T
12///
13/// In Rust, all values are immutable by default unless marked `mut`.
14/// For shared ownership of immutable data, use `Arc<T>`.
15/// For interior mutability patterns, use `RefCell<T>`, `Mutex<T>`, or `RwLock<T>`.
16/// For functions, use `Box<dyn Fn(...)>` or `fn(...)` directly.
17pub type DeepImmutable<T> = T;
18
19/// Permutations type in TypeScript generates all possible orderings of a union.
20/// In Rust, this doesn't have a direct type-level equivalent, but can be
21/// implemented at runtime for enums.
22pub type Permutations<T> = T;