bevyengine / bevyengine/bevy

`Null` type in `bevy_reflect`

Open
#18,707 0 comments 0 reactions 0 assignees View on GitHub
A-Reflection C-Feature X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

When using one of the `Dynamic*` types, it is very difficult to clear a field that's already been set or to explicitly not provide a value.

## What solution would you like?

I would like to see a `Null` type (bikeshed exact name for it later). The `FromReflect` derive macro should be updated to treat instances of this type as if the field wasn't set.

## What alternative(s) have you considered?

I haven't really been able to come up with another way to handle it.

## Additional context

I've been playing around with setting up some kind of interop between `bevy_reflect` and python types using the [`pyo3`](https://crates.io/crates/pyo3) crate and I've been struggling to deal with `None` values from python.

Contributor guide

Open the contributing guide

Research direction

Start by reading the bevy_reflect Dynamic* types and the FromReflect derive macro, focusing on how missing fields are currently represented. Done means a Null type is defined and FromReflect treats it as though the field was not provided; the exact name and design still need to be settled.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.