Skip to content

Commit

Permalink
Make DriverCtx publicly constructable again (#821)
Browse files Browse the repository at this point in the history
Follow-up to #808

Also adds a test to limit the risk of future regression.
  • Loading branch information
DJMcNab authored Jan 14, 2025
1 parent 51a3556 commit 8fd5bde
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion masonry/src/app_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ use crate::{Action, RenderRoot, WidgetId};
///
/// Currently holds a reference to the [`RenderRoot`].
pub struct DriverCtx<'a> {
pub(crate) render_root: &'a mut RenderRoot,
// We make no guarantees about the fields of this struct, but
// they must all be public so that the type can be constructed
// externally.
// This is needed for external users, whilst our external API
// is not yet designed.
#[doc(hidden)]
pub render_root: &'a mut RenderRoot,
}

/// A trait for defining how your app interacts with the Masonry widget tree.
Expand Down Expand Up @@ -40,3 +46,15 @@ impl DriverCtx<'_> {
self.render_root.needs_rewrite_passes()
}
}

#[cfg(doctest)]
/// Doctests aren't collected under `cfg(test)`; we can use `cfg(doctest)` instead
mod doctests {
/// ```no_run
/// use masonry::DriverCtx;
/// let _ctx = DriverCtx {
/// render_root: unimplemented!()
/// };
/// ```
const _DRIVER_CTX_EXTERNALLY_CONSTRUCTIBLE: () = {};
}

0 comments on commit 8fd5bde

Please sign in to comment.