@@ -680,14 +680,6 @@ impl Entity {
680680 self . 0 . get ( key)
681681 }
682682
683- pub fn insert ( & mut self , key : & str , value : Value ) -> Result < Option < Value > , InternError > {
684- self . 0 . insert ( key, value)
685- }
686-
687- pub fn remove ( & mut self , key : & str ) -> Option < Value > {
688- self . 0 . remove ( key)
689- }
690-
691683 pub fn contains_key ( & self , key : & str ) -> bool {
692684 self . 0 . contains_key ( key)
693685 }
@@ -723,15 +715,6 @@ impl Entity {
723715 }
724716 }
725717
726- /// Convenience method to save having to `.into()` the arguments.
727- pub fn set (
728- & mut self ,
729- name : & str ,
730- value : impl Into < Value > ,
731- ) -> Result < Option < Value > , InternError > {
732- self . 0 . insert ( name, value. into ( ) )
733- }
734-
735718 /// Merges an entity update `update` into this entity.
736719 ///
737720 /// If a key exists in both entities, the value from `update` is chosen.
@@ -749,8 +732,8 @@ impl Entity {
749732 pub fn merge_remove_null_fields ( & mut self , update : Entity ) -> Result < ( ) , InternError > {
750733 for ( key, value) in update. 0 . into_iter ( ) {
751734 match value {
752- Value :: Null => self . remove ( & key) ,
753- _ => self . insert ( & key, value) ?,
735+ Value :: Null => self . 0 . remove ( & key) ,
736+ _ => self . 0 . insert ( & key, value) ?,
754737 } ;
755738 }
756739 Ok ( ( ) )
@@ -901,6 +884,27 @@ impl Entity {
901884 }
902885}
903886
887+ /// Convenience methods to modify individual attributes for tests.
888+ /// Production code should not use/need this.
889+ #[ cfg( debug_assertions) ]
890+ impl Entity {
891+ pub fn insert ( & mut self , key : & str , value : Value ) -> Result < Option < Value > , InternError > {
892+ self . 0 . insert ( key, value)
893+ }
894+
895+ pub fn remove ( & mut self , key : & str ) -> Option < Value > {
896+ self . 0 . remove ( key)
897+ }
898+
899+ pub fn set (
900+ & mut self ,
901+ name : & str ,
902+ value : impl Into < Value > ,
903+ ) -> Result < Option < Value > , InternError > {
904+ self . 0 . insert ( name, value. into ( ) )
905+ }
906+ }
907+
904908impl < ' a > From < & ' a Entity > for Cow < ' a , Entity > {
905909 fn from ( entity : & ' a Entity ) -> Self {
906910 Cow :: Borrowed ( entity)
0 commit comments