33//! This module provides functionality to compute differences between `LinkML` schemas,
44//! including structural differences, semantic changes, and breaking change detection.
55
6+ use crate :: utils:: safe_cast:: usize_to_f64;
67use linkml_core:: prelude:: * ;
78use serde:: { Deserialize , Serialize } ;
89use std:: collections:: { HashMap , HashSet } ;
@@ -307,8 +308,8 @@ impl SchemaDiffer {
307308 // Compare attributes
308309 let old_attrs: HashSet < _ > = old_class. attributes . keys ( ) . cloned ( ) . collect ( ) ;
309310 let new_attrs: HashSet < _ > = new_class. attributes . keys ( ) . cloned ( ) . collect ( ) ;
310- let attr_intersection = old_attrs. intersection ( & new_attrs) . count ( ) as f64 ;
311- let attr_union = old_attrs. union ( & new_attrs) . count ( ) as f64 ;
311+ let attr_intersection = usize_to_f64 ( old_attrs. intersection ( & new_attrs) . count ( ) ) ;
312+ let attr_union = usize_to_f64 ( old_attrs. union ( & new_attrs) . count ( ) ) ;
312313
313314 if attr_union > 0.0 {
314315 score += attr_intersection / attr_union;
@@ -330,8 +331,8 @@ impl SchemaDiffer {
330331 // Compare mixins
331332 let old_mixins: HashSet < _ > = old_class. mixins . iter ( ) . cloned ( ) . collect ( ) ;
332333 let new_mixins: HashSet < _ > = new_class. mixins . iter ( ) . cloned ( ) . collect ( ) ;
333- let mixin_intersection = old_mixins. intersection ( & new_mixins) . count ( ) as f64 ;
334- let mixin_union = old_mixins. union ( & new_mixins) . count ( ) as f64 ;
334+ let mixin_intersection = usize_to_f64 ( old_mixins. intersection ( & new_mixins) . count ( ) ) ;
335+ let mixin_union = usize_to_f64 ( old_mixins. union ( & new_mixins) . count ( ) ) ;
335336
336337 if mixin_union > 0.0 {
337338 score += mixin_intersection / mixin_union;
0 commit comments