File tree Expand file tree Collapse file tree 7 files changed +678
-0
lines changed
Expand file tree Collapse file tree 7 files changed +678
-0
lines changed Original file line number Diff line number Diff line change 1717
1818use std:: fmt:: Display ;
1919
20+ use unicode_segmentation:: UnicodeSegmentation ;
21+
2022use super :: AsStr ;
2123use crate :: error:: Error ;
2224
@@ -52,3 +54,33 @@ impl<T: Url> Url for Option<T> {
5254 }
5355 }
5456}
57+
58+ impl super :: length:: HasSimpleLength for url:: Url {
59+ fn length ( & self ) -> usize {
60+ self . as_str ( ) . len ( )
61+ }
62+ }
63+
64+ impl super :: length:: HasChars for url:: Url {
65+ fn num_chars ( & self ) -> usize {
66+ self . as_str ( ) . chars ( ) . count ( )
67+ }
68+ }
69+
70+ impl super :: length:: HasGraphemes for url:: Url {
71+ fn num_graphemes ( & self ) -> usize {
72+ self . as_str ( ) . graphemes ( true ) . count ( )
73+ }
74+ }
75+
76+ impl super :: length:: HasBytes for url:: Url {
77+ fn num_bytes ( & self ) -> usize {
78+ self . as_str ( ) . len ( )
79+ }
80+ }
81+
82+ impl super :: length:: HasUtf16CodeUnits for url:: Url {
83+ fn num_code_units ( & self ) -> usize {
84+ self . as_str ( ) . encode_utf16 ( ) . count ( )
85+ }
86+ }
Original file line number Diff line number Diff line change 1+ -- -
2+ source : garde / tests / ./ rules / url .rs
3+ expression : snapshot
4+ -- -
5+ Struct {
6+ field : Url {
7+ scheme : " https" ,
8+ cannot_be_a_base : false ,
9+ username : " " ,
10+ password : None ,
11+ host : Some (
12+ Domain (
13+ " www.youtube.com" ,
14+ ),
15+ ),
16+ port : None ,
17+ path : " /" ,
18+ query : None ,
19+ fragment : None ,
20+ },
21+ v : Struct {
22+ default : Url {
23+ scheme : " https" ,
24+ cannot_be_a_base : false ,
25+ username : " " ,
26+ password : None ,
27+ host : Some (
28+ Domain (
29+ " www.youtube.com" ,
30+ ),
31+ ),
32+ port : None ,
33+ path : " /" ,
34+ query : None ,
35+ fragment : None ,
36+ },
37+ simple : Url {
38+ scheme : " https" ,
39+ cannot_be_a_base : false ,
40+ username : " " ,
41+ password : None ,
42+ host : Some (
43+ Domain (
44+ " www.youtube.com" ,
45+ ),
46+ ),
47+ port : None ,
48+ path : " /" ,
49+ query : None ,
50+ fragment : None ,
51+ },
52+ bytes : Url {
53+ scheme : " https" ,
54+ cannot_be_a_base : false ,
55+ username : " " ,
56+ password : None ,
57+ host : Some (
58+ Domain (
59+ " www.youtube.com" ,
60+ ),
61+ ),
62+ port : None ,
63+ path : " /" ,
64+ query : None ,
65+ fragment : None ,
66+ },
67+ chars : Url {
68+ scheme : " https" ,
69+ cannot_be_a_base : false ,
70+ username : " " ,
71+ password : None ,
72+ host : Some (
73+ Domain (
74+ " www.youtube.com" ,
75+ ),
76+ ),
77+ port : None ,
78+ path : " /" ,
79+ query : None ,
80+ fragment : None ,
81+ },
82+ graphemes : Url {
83+ scheme : " https" ,
84+ cannot_be_a_base : false ,
85+ username : " " ,
86+ password : None ,
87+ host : Some (
88+ Domain (
89+ " www.youtube.com" ,
90+ ),
91+ ),
92+ port : None ,
93+ path : " /" ,
94+ query : None ,
95+ fragment : None ,
96+ },
97+ utf_16_code_units : Url {
98+ scheme : " https" ,
99+ cannot_be_a_base : false ,
100+ username : " " ,
101+ password : None ,
102+ host : Some (
103+ Domain (
104+ " www.youtube.com" ,
105+ ),
106+ ),
107+ port : None ,
108+ path : " /" ,
109+ query : None ,
110+ fragment : None ,
111+ },
112+ },
113+ }
114+ field : length is lower than 30
115+ v .bytes : length is lower than 30
116+ v .chars : length is lower than 30
117+ v .default : length is lower than 30
118+ v .graphemes : length is lower than 30
119+ v .simple : length is lower than 30
120+ v .utf_16_code_units : length is lower than 30
121+
122+ Tuple (
123+ Url {
124+ scheme: " https" ,
125+ cannot_be_a_base: false ,
126+ username: " " ,
127+ password: None ,
128+ host: Some (
129+ Domain (
130+ " www.youtube.com" ,
131+ ),
132+ ),
133+ port: None ,
134+ path: " /" ,
135+ query: None ,
136+ fragment: None ,
137+ },
138+ )
139+ [0 ]: length is lower than 30
Original file line number Diff line number Diff line change 1+ -- -
2+ source : garde / tests / ./ rules / url .rs
3+ expression : snapshot
4+ -- -
5+ Struct {
6+ default : Url {
7+ scheme : " https" ,
8+ cannot_be_a_base : false ,
9+ username : " " ,
10+ password : None ,
11+ host : Some (
12+ Domain (
13+ " www.youtube.com" ,
14+ ),
15+ ),
16+ port : None ,
17+ path : " /" ,
18+ query : None ,
19+ fragment : None ,
20+ },
21+ simple : Url {
22+ scheme : " https" ,
23+ cannot_be_a_base : false ,
24+ username : " " ,
25+ password : None ,
26+ host : Some (
27+ Domain (
28+ " www.youtube.com" ,
29+ ),
30+ ),
31+ port : None ,
32+ path : " /" ,
33+ query : None ,
34+ fragment : None ,
35+ },
36+ bytes : Url {
37+ scheme : " https" ,
38+ cannot_be_a_base : false ,
39+ username : " " ,
40+ password : None ,
41+ host : Some (
42+ Domain (
43+ " www.youtube.com" ,
44+ ),
45+ ),
46+ port : None ,
47+ path : " /" ,
48+ query : None ,
49+ fragment : None ,
50+ },
51+ chars : Url {
52+ scheme : " https" ,
53+ cannot_be_a_base : false ,
54+ username : " " ,
55+ password : None ,
56+ host : Some (
57+ Domain (
58+ " www.youtube.com" ,
59+ ),
60+ ),
61+ port : None ,
62+ path : " /" ,
63+ query : None ,
64+ fragment : None ,
65+ },
66+ graphemes : Url {
67+ scheme : " https" ,
68+ cannot_be_a_base : false ,
69+ username : " " ,
70+ password : None ,
71+ host : Some (
72+ Domain (
73+ " www.youtube.com" ,
74+ ),
75+ ),
76+ port : None ,
77+ path : " /" ,
78+ query : None ,
79+ fragment : None ,
80+ },
81+ utf_16_code_units : Url {
82+ scheme : " https" ,
83+ cannot_be_a_base : false ,
84+ username : " " ,
85+ password : None ,
86+ host : Some (
87+ Domain (
88+ " www.youtube.com" ,
89+ ),
90+ ),
91+ port : None ,
92+ path : " /" ,
93+ query : None ,
94+ fragment : None ,
95+ },
96+ }
97+ bytes : length is lower than 30
98+ chars : length is lower than 30
99+ default : length is lower than 30
100+ graphemes : length is lower than 30
101+ simple : length is lower than 30
102+ utf_16_code_units : length is lower than 30
You can’t perform that action at this time.
0 commit comments