Relaxed Sized restrictions on App parameters

This commit is contained in:
Jonathan Johnson 2023-12-28 21:22:32 -08:00
parent f5b8c8cf8b
commit 0fa6a4b3a5
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
2 changed files with 15 additions and 5 deletions

View file

@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- All `&Appplication` bounds now are `?Sized`, enabling `&dyn Application`
parameters.
## v0.2.0 (2023-12-27)
### Breaking Changes

View file

@ -66,6 +66,7 @@ pub struct WindowBuilder<'a, Behavior, Application, AppMessage>
where
Behavior: self::WindowBehavior<AppMessage>,
AppMessage: Message,
Application: ?Sized,
{
owner: &'a Application,
context: Behavior::Context,
@ -76,6 +77,7 @@ impl<'a, Behavior, Application, AppMessage> Deref
where
Behavior: self::WindowBehavior<AppMessage>,
AppMessage: Message,
Application: ?Sized,
{
type Target = WindowAttributes;
@ -89,6 +91,7 @@ impl<'a, Behavior, Application, AppMessage> DerefMut
where
Behavior: self::WindowBehavior<AppMessage>,
AppMessage: Message,
Application: ?Sized,
{
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.attributes
@ -181,7 +184,7 @@ impl Default for WindowAttributes {
impl<'a, Behavior, Application, AppMessage> WindowBuilder<'a, Behavior, Application, AppMessage>
where
Behavior: self::WindowBehavior<AppMessage>,
Application: crate::AsApplication<AppMessage>,
Application: crate::AsApplication<AppMessage> + ?Sized,
AppMessage: Message,
{
pub(crate) fn new(owner: &'a Application, context: Behavior::Context) -> Self {
@ -773,7 +776,7 @@ where
/// initialized, a default [`Context`](Self::Context) will be passed.
fn build<App>(app: &App) -> WindowBuilder<'_, Self, App, AppMessage>
where
App: AsApplication<AppMessage>,
App: AsApplication<AppMessage> + ?Sized,
Self::Context: Default,
{
Self::build_with(app, <Self::Context as Default>::default())
@ -786,7 +789,7 @@ where
context: Self::Context,
) -> WindowBuilder<'_, Self, App, AppMessage>
where
App: AsApplication<AppMessage>,
App: AsApplication<AppMessage> + ?Sized,
{
WindowBuilder::new(app, context)
}
@ -852,7 +855,7 @@ where
/// [`winit::window::WindowBuilder::build`].
fn open<App>(app: &App) -> Result<Option<Window<AppMessage::Window>>, OsError>
where
App: AsApplication<AppMessage>,
App: AsApplication<AppMessage> + ?Sized,
Self::Context: Default,
{
Self::build(app).open()
@ -873,7 +876,7 @@ where
context: Self::Context,
) -> Result<Option<Window<AppMessage::Window>>, OsError>
where
App: AsApplication<AppMessage>,
App: AsApplication<AppMessage> + ?Sized,
{
Self::build_with(app, context).open()
}