Skip to content

Conversation

@Bromeon
Copy link
Member

@Bromeon Bromeon commented Nov 9, 2025

Addresses some of the open questions from #1396 regarding mutable default values.
Conservatively disallows many types, we can probably open them up over time.

One future approach would be to allow immutable values where types support them, e.g.:

#[opt] object: Option<Gd<RefCounted>>,
// We can safely use None here.

#[opt] v: Variant,
// We can safely use Variant::nil() here. Recreated each time.

Or, have an override like:

#[opt(default = allow_mut(...))] object: Gd<RefCounted>,

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: register Register classes, functions and other symbols to GDScript labels Nov 9, 2025
@Bromeon Bromeon added this to the 0.4.x milestone Nov 9, 2025
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1406

@Bromeon Bromeon force-pushed the qol/opt-constrained-types branch from b1d58fe to b9498a7 Compare November 9, 2025 22:51
unsafe impl GodotImmutable for u16 {}
unsafe impl GodotImmutable for i32 {}
unsafe impl GodotImmutable for u32 {}
unsafe impl GodotImmutable for i64 {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: register Register classes, functions and other symbols to GDScript quality-of-life No new functionality, but improves ergonomics/internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants