@@ -213,7 +213,7 @@ pub(crate) fn resolve_value<'a, 'bp>(
213213 // - Operations and conditionals -
214214 // -----------------------------------------------------------------------------
215215 ValueExpr :: Not ( value_expr) => {
216- let value = resolve_value ( value_expr, ctx) else { return ValueKind :: Null } ;
216+ let value = resolve_value ( value_expr, ctx) ;
217217 // let ValueKind::Bool(val) = resolve_value(value_expr, ctx) else { return ValueKind::Null };
218218 ValueKind :: Bool ( !value. truthiness ( ) )
219219 }
@@ -252,9 +252,6 @@ pub(crate) fn resolve_value<'a, 'bp>(
252252 _ => ValueKind :: Null ,
253253 } ,
254254 ValueExpr :: Either ( first, second) => {
255- let s1 = format ! ( "{first:?}" ) ;
256- let s2 = format ! ( "{second:?}" ) ;
257-
258255 let value = resolve_value ( first, ctx) ;
259256 match value {
260257 ValueKind :: Null => resolve_value ( second, ctx) ,
@@ -331,17 +328,12 @@ fn resolve_index<'bp>(
331328) -> ValueExpr < ' bp > {
332329 match src {
333330 ValueExpr :: DynMap ( value) | ValueExpr :: Composite ( value) => {
334- let type_info = value. type_info ( ) ;
335331 let state = or_null ! ( value. as_state( ) ) ;
336332 let map = match state. as_any_map ( ) {
337- Some ( map) => {
338- anathema_debug:: debug_to_file!( "there is a {type_info:?} | {:?}" , value. key( ) ) ;
339- map
340- }
333+ Some ( map) => map,
341334 None => {
342335 // This will happen in the event of an `Option<DynMap>`
343336 // where the `Option` is `None`
344- anathema_debug:: debug_to_file!( "there is no {type_info:?} | {:?}" , value. key( ) ) ;
345337 value. subscribe ( ctx. sub ) ;
346338 ctx. sub_to . push ( value. sub_key ( ) ) ;
347339 return ValueExpr :: Null ;
@@ -367,14 +359,8 @@ fn resolve_index<'bp>(
367359 ctx. sub_to . push ( value. sub_key ( ) ) ;
368360 let state = or_null ! ( value. as_state( ) ) ;
369361 let list = match state. as_any_list ( ) {
370- Some ( list) => {
371- let key = value. owned_key ( ) ;
372- value. unsubscribe ( ctx. sub ) ;
373- ctx. sub_to . remove ( value. sub_key ( ) ) ;
374- list
375- }
362+ Some ( list) => list,
376363 None => {
377- let key = value. owned_key ( ) ;
378364 value. subscribe ( ctx. sub ) ;
379365 ctx. sub_to . push ( value. sub_key ( ) ) ;
380366 return ValueExpr :: Null ;
@@ -388,11 +374,7 @@ fn resolve_index<'bp>(
388374 //
389375 // If the value does exist unsubscribe from the underlying map / state
390376 let val = match val {
391- Some ( val) => {
392- value. unsubscribe ( ctx. sub ) ;
393- ctx. sub_to . remove ( value. sub_key ( ) ) ;
394- val
395- }
377+ Some ( val) => val,
396378 None => {
397379 value. subscribe ( ctx. sub ) ;
398380 ctx. sub_to . push ( value. sub_key ( ) ) ;
@@ -513,7 +495,7 @@ fn float_op(lhs: f64, rhs: f64, op: Op) -> f64 {
513495
514496#[ cfg( test) ]
515497mod test {
516- use anathema_state:: { Changes , Map , States , drain_changes} ;
498+ use anathema_state:: { Changes , Map , Maybe , States , drain_changes} ;
517499 use anathema_templates:: expressions:: { ident, index, num, strlit} ;
518500
519501 use crate :: testing:: setup;
@@ -570,6 +552,8 @@ mod test {
570552 test. with_state ( |state| state. list . remove ( 0 ) ) ;
571553
572554 drain_changes ( & mut changes) ;
555+ assert ! ( !changes. is_empty( ) ) ;
556+
573557 for ( subs, _) in changes. drain ( ) {
574558 if subs. iter ( ) . any ( |sub| sub == value. sub ) {
575559 value. reload ( & test. attributes ) ;
@@ -588,13 +572,13 @@ mod test {
588572 // let expr = index(index(ident("state"), strlit("opt_map")), strlit("key"));
589573 let expr = index ( ident ( "state" ) , strlit ( "opt_map" ) ) ;
590574
591- let mut value = test. eval ( & expr) ;
575+ let value = test. eval ( & expr) ;
592576 assert ! ( value. as_str( ) . is_none( ) ) ;
593577
594578 test. with_state ( |state| {
595579 let mut map = Map :: empty ( ) ;
596580 map. insert ( "key" , 123 ) ;
597- state. opt_map . set ( Some ( map) ) ;
581+ state. opt_map . set ( Maybe :: some ( map) ) ;
598582 } ) ;
599583
600584 drain_changes ( & mut changes) ;
0 commit comments