11use std:: { pin:: Pin , task:: Poll } ;
22
3- use crate :: {
4- csr:: StateUnmount ,
5- strings:: { known:: KnownCsrStr , CsrStr } ,
6- IntoStaticStrCache , ToAsRefStr ,
7- } ;
3+ use crate :: { csr:: StateUnmount , strings:: known:: KnownCsrStr , IntoStaticStrCache , ToAsRefStr } ;
84
95use super :: { ReactiveValue , ReactiveValueState } ;
106
@@ -37,40 +33,6 @@ impl<T: KnownCsrStr> ReactiveValue<str> for T {
3733 type ReactiveValueKind = str ;
3834 ) ;
3935
40- #[ cfg( todo) ]
41- type StateUnpinned = CsrStrReactiveState < T :: StaticStrCache > ;
42-
43- #[ cfg( todo) ]
44- fn _reactive_value_render_init_unpinned < R > (
45- self ,
46- update : impl FnOnce ( & str ) -> R ,
47- ) -> ( Self :: StateUnpinned , R ) {
48- let cache = self . into_into_static_str_cache ( ) . into_static_str_cache ( ) ;
49- let res = update ( cache. to_as_ref_str ( ) . as_ref ( ) ) ;
50- ( CsrStrReactiveState ( cache) , res)
51- }
52-
53- #[ cfg( todo) ]
54- fn _reactive_value_render_init_with_old_state_unpinned < R > (
55- self ,
56- update : impl FnOnce ( & str ) -> R ,
57- CsrStrReactiveState ( cache) : & mut Self :: StateUnpinned ,
58- ) -> R {
59- self . into_into_static_str_cache ( )
60- . update_into_static_str_cache ( cache) ;
61- let res = update ( cache. to_as_ref_str ( ) . as_ref ( ) ) ;
62- res
63- }
64-
65- #[ cfg( todo) ]
66- fn _reactive_value_render_update_unpinned < R > (
67- self ,
68- update : impl FnOnce ( & str ) -> R ,
69- CsrStrReactiveState ( cache) : & mut Self :: StateUnpinned ,
70- ) -> Option < R > {
71- crate :: strings:: csr:: update_into_cache ( self , update, cache)
72- }
73-
7436 type UnpinnedState = CsrStrReactiveState < T :: StaticStrCache > ;
7537
7638 type UnpinnedStateDefault = Option < Self :: UnpinnedState > ;
@@ -79,22 +41,31 @@ impl<T: KnownCsrStr> ReactiveValue<str> for T {
7941 self ,
8042 renderer : impl super :: RenderValueOnce < str , RenderOutput = Out > ,
8143 ) -> ( Self :: UnpinnedState , Out ) {
82- todo ! ( )
44+ let cache = self . into_into_static_str_cache ( ) . into_static_str_cache ( ) ;
45+ let res = renderer. render_value_once_update ( cache. to_as_ref_str ( ) . as_ref ( ) ) ;
46+ ( CsrStrReactiveState ( cache) , res)
8347 }
8448
8549 fn reactive_value_render_init_with_old_state_unpinned < Out > (
8650 self ,
8751 renderer : impl super :: RenderValueOnce < str , RenderOutput = Out > ,
88- old_state : & mut Self :: UnpinnedState ,
52+ CsrStrReactiveState ( cache ) : & mut Self :: UnpinnedState ,
8953 ) -> Out {
90- todo ! ( )
54+ self . into_into_static_str_cache ( )
55+ . update_into_static_str_cache ( cache) ;
56+ let res = renderer. render_value_once_update ( cache. to_as_ref_str ( ) . as_ref ( ) ) ;
57+ res
9158 }
9259
9360 fn reactive_value_render_update_unpinned < Out > (
9461 self ,
9562 renderer : impl super :: RenderValueOnce < str , RenderOutput = Out > ,
96- state : & mut Self :: UnpinnedState ,
63+ CsrStrReactiveState ( cache ) : & mut Self :: UnpinnedState ,
9764 ) -> Option < Out > {
98- todo ! ( )
65+ crate :: strings:: csr:: update_into_cache (
66+ self ,
67+ |v| renderer. render_value_once_update ( v) ,
68+ cache,
69+ )
9970 }
10071}
0 commit comments