Skip to content

Array, Dictionary: add into_read_only() + is_read_only() #1096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2025

Conversation

Bromeon
Copy link
Member

@Bromeon Bromeon commented Mar 23, 2025

Modeled Godot's make_read_only() as into_read_only(), so it can be used directly on construction:

let array = array![1, 2].into_read_only();

I don't expect people to use this that much in Rust, but it's a Godot feature that we should support, and "read-only-ness" can also have an impact on other functions.

As best-effort, this PR also adds panics in Debug mode if a mutating method is called on a read-only Array/Dictionary.

Should mark the last item on the original builtin feature list and thus closes #310.

@Bromeon Bromeon added feature Adds functionality to the library c: core Core components labels Mar 23, 2025
@GodotRust
Copy link

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

@Bromeon Bromeon added this pull request to the merge queue Mar 23, 2025
Merged via the queue into master with commit b7ea495 Mar 23, 2025
46 checks passed
@Bromeon Bromeon deleted the feature/collections-read-only branch March 23, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for builtin feature-completeness
2 participants