@@ -26,6 +26,19 @@ use syn::{parse_macro_input, DeriveInput};
2626/// `World::remove`. Monomorphic `Bundle` implementations are slightly more efficient than the
2727/// polymorphic implementations for tuples, and can be convenient when combined with other derives
2828/// like `serde::Deserialize`.
29+ ///
30+ /// # Example
31+ /// ```ignore
32+ /// #[derive(Bundle)]
33+ /// struct Foo {
34+ /// x: i32,
35+ /// y: char,
36+ /// }
37+ ///
38+ /// let mut world = World::new();
39+ /// let e = world.spawn(Foo { x: 42, y: 'a' });
40+ /// assert_eq!(*world.get::<i32>(e).unwrap(), 42);
41+ /// ```
2942#[ proc_macro_derive( Bundle ) ]
3043pub fn derive_bundle ( input : TokenStream ) -> TokenStream {
3144 let input = parse_macro_input ! ( input as DeriveInput ) ;
@@ -41,6 +54,25 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
4154/// Queries structs can be passed to the type parameter of `World::query`. They must have exactly
4255/// one lifetime parameter, and all of their fields must be queries (e.g. references) using that
4356/// lifetime.
57+ ///
58+ /// # Example
59+ /// ```ignore
60+ /// #[derive(Query, Debug, PartialEq)]
61+ /// struct Foo<'a> {
62+ /// x: &'a i32,
63+ /// y: &'a mut bool,
64+ /// }
65+ ///
66+ /// let mut world = World::new();
67+ /// let e = world.spawn((42, false));
68+ /// assert_eq!(
69+ /// world.query_one_mut::<Foo>(e).unwrap(),
70+ /// Foo {
71+ /// x: &42,
72+ /// y: &mut false
73+ /// }
74+ /// );
75+ /// ```
4476#[ proc_macro_derive( Query ) ]
4577pub fn derive_query ( input : TokenStream ) -> TokenStream {
4678 let input = parse_macro_input ! ( input as DeriveInput ) ;
0 commit comments