11use std:: {
2- borrow:: Cow ,
32 collections:: BTreeMap ,
43 fmt:: { self , Debug , Display , Formatter } ,
54 num:: NonZeroUsize ,
@@ -13,6 +12,10 @@ use serde::Serialize;
1312
1413use crate :: wpt:: metadata:: { maybe_collapsed:: MaybeCollapsed , BuildProfile , Platform } ;
1514
15+ pub use self :: disabled_string:: DisabledString ;
16+
17+ mod disabled_string;
18+
1619/// A non-empty set of expected outcomes in a [`Test`] or [`Subtest`].
1720///
1821/// The default expected test outcome is a "good" outcome, where testing passes. The `Out` type
@@ -207,62 +210,6 @@ where
207210
208211impl < Out > Eq for Expected < Out > where Out : EnumSetType + Eq { }
209212
210- #[ derive( Clone , Debug , Eq , PartialEq , Serialize ) ]
211- pub struct DisabledString ( Cow < ' static , str > ) ;
212-
213- impl DisabledString {
214- const FALSE : & ' static str = "@False" ;
215-
216- pub fn new ( inner : String ) -> Self {
217- Self ( if inner == Self :: FALSE {
218- // OPT: It can be expensive to store `Default`-generated copies of this, so let's avoid
219- // heap allocations for this case specifically.
220- Self :: FALSE . into ( )
221- } else {
222- inner. into ( )
223- } )
224- }
225-
226- fn value ( & self ) -> & str {
227- self . 0 . as_ref ( )
228- }
229-
230- pub fn is_disabled ( & self ) -> bool {
231- self . value ( ) != Self :: FALSE
232- }
233- }
234-
235- impl Default for DisabledString {
236- fn default ( ) -> Self {
237- Self :: new ( Self :: FALSE . into ( ) )
238- }
239- }
240-
241- impl Display for DisabledString {
242- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
243- Display :: fmt ( self . value ( ) , f)
244- }
245- }
246-
247- #[ test]
248- fn disabled_string ( ) {
249- let asdf = DisabledString :: new ( "asdf" . into ( ) ) ;
250- assert_eq ! ( asdf, DisabledString ( "asdf" . to_string( ) . into( ) ) ) ;
251- assert_eq ! ( asdf. value( ) , "asdf" ) ;
252-
253- assert_eq ! (
254- & DisabledString :: new( "@False" . into( ) ) . 0 ,
255- & DisabledString :: FALSE
256- ) ;
257-
258- assert ! ( !DisabledString :: new( DisabledString :: FALSE . into( ) ) . is_disabled( ) ) ;
259- assert ! ( DisabledString :: new( "asdf" . into( ) ) . is_disabled( ) ) ;
260- assert ! (
261- DisabledString :: new( "https://bugzilla.mozilla.org/show_bug.cgi?id=1958061" . into( ) )
262- . is_disabled( )
263- ) ;
264- }
265-
266213/// A completely flat representation of [`NormalizedPropertyValue`] suitable for byte
267214/// representation in memory.
268215#[ derive( Debug , Default , Clone , Copy , Eq , PartialEq , Serialize ) ]
0 commit comments