bevy/crates/bevy_text/src
Paweł Grabarz 07ed1d053e Implement and require #[derive(Component)] on all component structs (#2254)
This implements the most minimal variant of #1843 - a derive for marker trait. This is a prerequisite to more complicated features like statically defined storage type or opt-out component reflection.

In order to make component struct's purpose explicit and avoid misuse, it must be annotated with `#[derive(Component)]` (manual impl is discouraged for compatibility). Right now this is just a marker trait, but in the future it might be expanded. Making this change early allows us to make further changes later without breaking backward compatibility for derive macro users.

This already prevents a lot of issues, like using bundles in `insert` calls. Primitive types are no longer valid components as well. This can be easily worked around by adding newtype wrappers and deriving `Component` for them.

One funny example of prevented bad code (from our own tests) is when an newtype struct or enum variant is used. Previously, it was possible to write `insert(Newtype)` instead of `insert(Newtype(value))`. That code compiled, because function pointers (in this case newtype struct constructor) implement `Send + Sync + 'static`, so we allowed them to be used as components. This is no longer the case and such invalid code will trigger a compile error.


Co-authored-by: = <=>
Co-authored-by: TheRawMeatball <therawmeatball@gmail.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-10-03 19:23:44 +00:00
..
draw.rs Implement rotation for Text2d (#2084) 2021-05-06 03:55:55 +00:00
error.rs Fix errors and panics to typical Rust conventions (#968) 2020-12-02 11:31:16 -08:00
font.rs color spaces and representation (#1572) 2021-03-17 23:59:51 +00:00
font_atlas.rs Subpixel text positioning (#1196) 2021-01-03 12:39:11 -08:00
font_atlas_set.rs Faster compilation of bevy_diagnostic (#1235) 2021-01-12 13:21:45 -08:00
font_loader.rs Add support for OTF fonts (#1200) 2021-01-03 12:10:23 -08:00
glyph_brush.rs Expose more info in PositionedGlyph (#1319) 2021-01-26 11:53:55 -08:00
lib.rs Replace .insert_resource(T::default()) calls with init_resource::<T>() (#2807) 2021-09-13 14:02:28 +00:00
pipeline.rs Rich text (#1245) 2021-01-24 17:07:43 -08:00
text.rs Implement and require #[derive(Component)] on all component structs (#2254) 2021-10-03 19:23:44 +00:00
text2d.rs System Param Lifetime Split (#2605) 2021-08-15 20:51:53 +00:00