File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -251,12 +251,23 @@ impl From<RawFlags> for IndividualFlags {
251251}
252252
253253impl NodeFlags {
254+ /// Create a new flags instance with `IS_SAMPLE` set.
255+ pub fn new_sample ( ) -> Self {
256+ Self :: IS_SAMPLE
257+ }
258+
254259 /// We do not enforce valid flags in the library.
255260 /// This function will return `true` if any bits
256261 /// are set that do not correspond to allowed flags.
257262 pub fn is_valid ( & self ) -> bool {
258263 true
259264 }
265+
266+ /// Returns `true` if flags contains `IS_SAMPLE`,
267+ /// and `false` otherwise.
268+ pub fn is_sample ( & self ) -> bool {
269+ self . contains ( NodeFlags :: IS_SAMPLE )
270+ }
260271}
261272
262273impl IndividualFlags {
@@ -267,3 +278,20 @@ impl IndividualFlags {
267278 true
268279 }
269280}
281+
282+ #[ cfg( test) ]
283+ mod tests {
284+ use super :: * ;
285+
286+ #[ test]
287+ fn node_is_not_sample ( ) {
288+ let n = NodeFlags :: default ( ) ;
289+ assert ! ( !n. is_sample( ) ) ;
290+ }
291+
292+ #[ test]
293+ fn node_is_sample ( ) {
294+ let n = NodeFlags :: new_sample ( ) ;
295+ assert ! ( n. is_sample( ) ) ;
296+ }
297+ }
You can’t perform that action at this time.
0 commit comments