@@ -187,45 +187,15 @@ impl FromStr for Ref {
187
187
}
188
188
}
189
189
190
- #[ cfg( test) ]
191
- impl From < & str > for RepoOwner {
192
- fn from ( value : & str ) -> Self {
193
- Self :: try_new ( value) . unwrap ( )
194
- }
195
- }
196
- #[ cfg( test) ]
197
- impl From < & str > for RepoName {
198
- fn from ( value : & str ) -> Self {
199
- Self :: try_new ( value) . unwrap ( )
200
- }
201
- }
202
- #[ cfg( test) ]
203
- impl From < & str > for BranchName {
204
- fn from ( value : & str ) -> Self {
205
- Self :: try_new ( value) . unwrap ( )
206
- }
207
- }
208
- #[ cfg( test) ]
209
- impl From < & str > for Commit {
210
- fn from ( value : & str ) -> Self {
211
- Self :: try_new ( value) . unwrap ( )
212
- }
213
- }
214
-
215
190
/// Number of a pull request
191
+ #[ nutype_test_util:: derive( From ) ]
216
192
#[ nutype( const_fn, derive( Eq , PartialEq , Display , Debug , FromStr , Copy , Clone ) ) ]
217
193
pub struct PrNumber ( NonZeroU32 ) ;
218
194
219
- #[ cfg( test) ]
220
- impl From < u32 > for PrNumber {
221
- fn from ( value : u32 ) -> Self {
222
- Self :: new ( NonZeroU32 :: new ( value) . unwrap ( ) )
223
- }
224
- }
225
-
226
195
/// Represents owner of a repository
227
196
///
228
197
/// E.g. in `helix-editor/helix/master`, this is `helix-editor`
198
+ #[ nutype_test_util:: derive( From ) ]
229
199
#[ nutype(
230
200
validate( not_empty) ,
231
201
derive(
@@ -237,6 +207,7 @@ pub struct RepoOwner(String);
237
207
/// Represents name of a repository
238
208
///
239
209
/// E.g. in `helix-editor/helix/master`, this is `helix`
210
+ #[ nutype_test_util:: derive( From ) ]
240
211
#[ nutype(
241
212
validate( not_empty) ,
242
213
derive(
@@ -248,6 +219,7 @@ pub struct RepoName(String);
248
219
/// Name of a branch in git
249
220
///
250
221
/// E.g. in `helix-editor/helix/master`, this is `master`
222
+ #[ nutype_test_util:: derive( From ) ]
251
223
#[ nutype(
252
224
validate( not_empty) ,
253
225
derive(
@@ -267,6 +239,7 @@ impl FromStr for BranchName {
267
239
}
268
240
269
241
/// File name of a patch
242
+ #[ nutype_test_util:: derive( From ) ]
270
243
#[ nutype( validate( predicate = |p| !p. as_os_str( ) . is_empty( ) ) , derive( Hash , Eq , PartialEq , Debug , AsRef , Deserialize , Clone , FromStr ) ) ]
271
244
pub struct PatchName ( PathBuf ) ;
272
245
@@ -277,6 +250,7 @@ impl Display for PatchName {
277
250
}
278
251
279
252
/// Represents a git commit hash
253
+ #[ nutype_test_util:: derive( From ) ]
280
254
#[ nutype(
281
255
validate( not_empty, predicate = is_valid_commit_hash) ,
282
256
derive( Debug , Eq , PartialEq , Ord , PartialOrd , Clone , AsRef )
0 commit comments