11use frender_common:: {
2- convert:: { FromMut , IdentityAs , IntoMut } ,
2+ convert:: { FromMut , IntoMut } ,
33 impl_many, TempStr ,
44} ;
55pub use frender_csr:: render:: { RenderContext , RenderWithContext } ;
@@ -23,9 +23,7 @@ pub trait RenderTextFrom<V>:
2323/// Trait alias for [`RenderTextFrom`] with all known primitive types.
2424pub trait RenderTextFromKnown :
2525 RenderTextFrom < & ' static str >
26- + for < ' a > RenderTextFrom < TempStr < & ' a str > , Text = Self :: TextFromTempStr >
2726 + RenderTextFrom < StringElement >
28- + for < ' a > RenderTextFrom < & ' a StringElement , Text = Self :: TextFromRefStringElement >
2927 + RenderTextFrom < i8 >
3028 + RenderTextFrom < u8 >
3129 + RenderTextFrom < i16 >
@@ -41,6 +39,9 @@ pub trait RenderTextFromKnown:
4139 + RenderTextFrom < f32 >
4240 + RenderTextFrom < f64 >
4341 + RenderTextFrom < char >
42+ //
43+ + for < ' a > RenderTextFrom < TempStr < & ' a str > , Text = Self :: TextFromTempStr >
44+ + for < ' a > RenderTextFrom < & ' a StringElement , Text = Self :: TextFromRefStringElement >
4445{
4546 type TextFromTempStr : UiHandle < Self > + ' static ;
4647 type TextFromRefStringElement : UiHandle < Self > + ' static ;
@@ -76,20 +77,42 @@ where
7677 type TextFromRefStringElement = TextFromRefStringElement ;
7778}
7879
80+ pub trait RenderIntoTextKnownKind {
81+ type RenderIntoText < R : ?Sized + RenderTextFromKnown > : UiHandle < R > + ' static ;
82+ }
83+
7984pub trait RenderIntoTextKnown : Sized {
85+ type RenderIntoTextKnownKind : RenderIntoTextKnownKind ;
86+ type StaticRenderIntoTextKnown : ' static
87+ + RenderIntoTextKnown < RenderIntoTextKnownKind = Self :: RenderIntoTextKnownKind > ;
8088 type RenderTextFromSelf < R : ?Sized + RenderTextFromKnown > : ?Sized
81- + RenderTextFrom < Self , Text : UiHandle < R > >
89+ + for < ' a > RenderWithContext <
90+ RenderContext < ' a > : FromMut < R :: RenderContext < ' a > > + IntoMut < R :: RenderContext < ' a > > ,
91+ > + RenderTextFrom <
92+ Self ,
93+ Text = <Self :: RenderIntoTextKnownKind as RenderIntoTextKnownKind >:: RenderIntoText < R > ,
94+ > + RenderTextFrom <
95+ Self :: StaticRenderIntoTextKnown ,
96+ Text = <Self :: RenderIntoTextKnownKind as RenderIntoTextKnownKind >:: RenderIntoText < R > ,
97+ > + FromMut < R >
98+ + IntoMut < R > ;
99+ }
100+
101+ pub trait SimpleStaticRenderIntoTextKnown : ' static + Sized {
102+ type SimpleStaticRenderIntoText < R : ?Sized + RenderTextFromKnown > : UiHandle < R > + ' static ;
103+ type SimpleStaticRenderTextFromSelf < R : ?Sized + RenderTextFromKnown > : ?Sized
104+ + for < ' a > RenderWithContext <
105+ RenderContext < ' a > : FromMut < R :: RenderContext < ' a > > + IntoMut < R :: RenderContext < ' a > > ,
106+ > + RenderTextFrom < Self , Text = Self :: SimpleStaticRenderIntoText < R > >
82107 + FromMut < R >
83108 + IntoMut < R > ;
84109}
85110
86111impl_many ! (
87- impl <__> RenderIntoTextKnown
112+ impl <__> SimpleStaticRenderIntoTextKnown
88113 for each_of![
89114 & ' static str ,
90- TempStr <& str >,
91115 StringElement ,
92- & StringElement ,
93116 i8 ,
94117 u8 ,
95118 i16 ,
@@ -107,10 +130,43 @@ impl_many!(
107130 char ,
108131 ]
109132 {
110- type RenderTextFromSelf <R : ?Sized + RenderTextFromKnown > = R ;
133+ type SimpleStaticRenderIntoText <R : ?Sized + RenderTextFromKnown > =
134+ <R as RenderTextFrom <Self >>:: Text ;
135+ type SimpleStaticRenderTextFromSelf <R : ?Sized + RenderTextFromKnown > = R ;
111136 }
112137) ;
113138
139+ /// Self as Kind
140+ impl < T : SimpleStaticRenderIntoTextKnown > RenderIntoTextKnownKind for T {
141+ type RenderIntoText < R : ?Sized + RenderTextFromKnown > = T :: SimpleStaticRenderIntoText < R > ;
142+ }
143+
144+ impl < T : SimpleStaticRenderIntoTextKnown > RenderIntoTextKnown for T {
145+ type RenderIntoTextKnownKind = T ;
146+ type StaticRenderIntoTextKnown = T ;
147+ type RenderTextFromSelf < R : ?Sized + RenderTextFromKnown > = T :: SimpleStaticRenderTextFromSelf < R > ;
148+ }
149+
150+ impl RenderIntoTextKnownKind for TempStr < & ' static str > {
151+ type RenderIntoText < R : ?Sized + RenderTextFromKnown > = R :: TextFromTempStr ;
152+ }
153+
154+ impl RenderIntoTextKnown for TempStr < & str > {
155+ type RenderIntoTextKnownKind = TempStr < & ' static str > ;
156+ type StaticRenderIntoTextKnown = TempStr < & ' static str > ;
157+ type RenderTextFromSelf < R : ?Sized + RenderTextFromKnown > = R ;
158+ }
159+
160+ impl RenderIntoTextKnownKind for & ' static StringElement {
161+ type RenderIntoText < R : ?Sized + RenderTextFromKnown > = R :: TextFromRefStringElement ;
162+ }
163+
164+ impl RenderIntoTextKnown for & StringElement {
165+ type RenderIntoTextKnownKind = & ' static StringElement ;
166+ type StaticRenderIntoTextKnown = & ' static StringElement ;
167+ type RenderTextFromSelf < R : ?Sized + RenderTextFromKnown > = R ;
168+ }
169+
114170pub trait Render : RenderWithContext {
115171 fn log ( & mut self , v : & str ) ;
116172
0 commit comments