|
| 1 | +use std::{borrow::Cow, rc::Rc, sync::Arc}; |
| 2 | + |
| 3 | +use super::ToElement; |
| 4 | +use frender_element::{CsrElement, Element, SsrElement}; |
| 5 | +use frender_reactive_value::{non_reactive::Uncached, temp_into_static::TempIntoStatic}; |
| 6 | + |
| 7 | +trait ToElementLikeUncachedTempIntoStatic<V: ?Sized + 'static>: |
| 8 | + for<'a> ToElement< |
| 9 | + ToElement<'a>: Element< |
| 10 | + HtmlChildren = <Uncached<TempIntoStatic<&'static V>> as SsrElement>::HtmlChildren, |
| 11 | + RenderStateKind = <Uncached<TempIntoStatic<&'static V>> as CsrElement>::RenderStateKind, |
| 12 | + >, |
| 13 | +> |
| 14 | +where |
| 15 | + TempIntoStatic<&'static V>: SsrElement, |
| 16 | + Uncached<TempIntoStatic<&'static V>>: CsrElement, |
| 17 | +{ |
| 18 | +} |
| 19 | + |
| 20 | +impl<T: ?Sized, V: ?Sized + 'static> ToElementLikeUncachedTempIntoStatic<V> for T |
| 21 | +where |
| 22 | + T: for<'a> ToElement< |
| 23 | + ToElement<'a>: Element< |
| 24 | + HtmlChildren = <Uncached<TempIntoStatic<&'static V>> as SsrElement>::HtmlChildren, |
| 25 | + RenderStateKind = <Uncached<TempIntoStatic<&'static V>> as CsrElement>::RenderStateKind, |
| 26 | + >, |
| 27 | + >, |
| 28 | + TempIntoStatic<&'static V>: SsrElement, |
| 29 | + Uncached<TempIntoStatic<&'static V>>: CsrElement, |
| 30 | +{ |
| 31 | +} |
| 32 | + |
| 33 | +const fn type_assert() |
| 34 | +where |
| 35 | + str: ToElementLikeUncachedTempIntoStatic<str>, |
| 36 | + String: ToElementLikeUncachedTempIntoStatic<str>, |
| 37 | + Cow<'static, str>: ToElementLikeUncachedTempIntoStatic<str>, |
| 38 | + (): TypeAssertCowStr, |
| 39 | + Rc<str>: ToElementLikeUncachedTempIntoStatic<Rc<str>>, |
| 40 | + Arc<str>: ToElementLikeUncachedTempIntoStatic<Arc<str>>, |
| 41 | +{ |
| 42 | +} |
| 43 | + |
| 44 | +const _: () = type_assert(); |
| 45 | + |
| 46 | +trait TypeAssertCowStr { |
| 47 | + type Assert<'a>: ToElement< |
| 48 | + ToElement<'a>: Element< |
| 49 | + HtmlChildren = <Uncached<TempIntoStatic<&'static str>> as SsrElement>::HtmlChildren, |
| 50 | + RenderStateKind = <Uncached<TempIntoStatic<&'static str>> as CsrElement>::RenderStateKind, |
| 51 | + >, |
| 52 | + > |
| 53 | + where |
| 54 | + Self: 'a; |
| 55 | +} |
| 56 | + |
| 57 | +impl TypeAssertCowStr for () { |
| 58 | + type Assert<'a> |
| 59 | + = Cow<'a, str> |
| 60 | + where |
| 61 | + Self: 'a; |
| 62 | +} |
| 63 | + |
| 64 | +// use the above code |
| 65 | +#[test] |
| 66 | +const fn compile_only() { |
| 67 | + type_assert() |
| 68 | +} |
0 commit comments