1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Helpers for working with attribute collections.
use ;
/// Splits a slice of attributes into doc and non-doc groups.
///
/// # Examples
///
/// ```
/// use whitaker_common::attributes::{split_doc_attributes, Attribute, AttributeKind, AttributePath};
///
/// let doc = Attribute::new(AttributePath::from("doc"), AttributeKind::Outer);
/// let allow = Attribute::new(AttributePath::from("allow"), AttributeKind::Outer);
/// let attributes = vec![doc.clone(), allow.clone()];
/// let (docs, rest) = split_doc_attributes(&attributes);
/// assert_eq!(docs.len(), 1);
/// assert_eq!(rest.len(), 1);
/// ```
/// Returns the subset of attributes that apply as outer attributes.
///
/// # Examples
///
/// ```
/// use whitaker_common::attributes::{outer_attributes, Attribute, AttributeKind, AttributePath};
///
/// let inner = Attribute::new(AttributePath::from("doc"), AttributeKind::Inner);
/// let outer = Attribute::new(AttributePath::from("test"), AttributeKind::Outer);
/// let attributes = vec![inner, outer.clone()];
/// let outer_only = outer_attributes(&attributes);
/// assert_eq!(outer_only, vec![&outer]);
/// ```
/// Returns `true` when any attribute marks the item as test-like.
///
/// # Examples
///
/// ```
/// use whitaker_common::attributes::{has_test_like_attribute, Attribute, AttributeKind, AttributePath};
///
/// let attr = Attribute::new(AttributePath::from("tokio::test"), AttributeKind::Outer);
/// assert!(has_test_like_attribute(&[attr]));
/// ```
/// Returns `true` when any attribute marks the item as test-like, accounting
/// for custom attribute paths supplied at runtime.
///
/// # Examples
///
/// ```
/// use whitaker_common::attributes::{has_test_like_attribute_with, Attribute, AttributeKind, AttributePath};
///
/// let attr = Attribute::new(AttributePath::from("custom::test"), AttributeKind::Outer);
/// let additional = vec![AttributePath::from("custom::test")];
/// assert!(has_test_like_attribute_with(&[attr], &additional));
/// ```