-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2351 from iced-rs/custom-renderer-injection
Type-Driven Renderer Fallback
- Loading branch information
Showing
56 changed files
with
1,886 additions
and
1,447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::Primitive; | ||
|
||
use std::sync::Arc; | ||
|
||
/// A piece of data that can be cached. | ||
pub trait Cached: Sized { | ||
/// The type of cache produced. | ||
type Cache; | ||
|
||
/// Loads the [`Cache`] into a proper instance. | ||
/// | ||
/// [`Cache`]: Self::Cache | ||
fn load(cache: &Self::Cache) -> Self; | ||
|
||
/// Caches this value, producing its corresponding [`Cache`]. | ||
/// | ||
/// [`Cache`]: Self::Cache | ||
fn cache(self) -> Self::Cache; | ||
} | ||
|
||
impl<T> Cached for Primitive<T> { | ||
type Cache = Arc<Self>; | ||
|
||
fn load(cache: &Arc<Self>) -> Self { | ||
Self::Cache { | ||
content: cache.clone(), | ||
} | ||
} | ||
|
||
fn cache(self) -> Arc<Self> { | ||
Arc::new(self) | ||
} | ||
} | ||
|
||
#[cfg(debug_assertions)] | ||
impl Cached for () { | ||
type Cache = (); | ||
|
||
fn load(_cache: &Self::Cache) -> Self {} | ||
|
||
fn cache(self) -> Self::Cache {} | ||
} |
Oops, something went wrong.