@@ -187,45 +187,15 @@ impl FromStr for Ref {
187187 }
188188}
189189
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-
215190/// Number of a pull request
191+ #[ nutype_test_util:: derive( From ) ]
216192#[ nutype( const_fn, derive( Eq , PartialEq , Display , Debug , FromStr , Copy , Clone ) ) ]
217193pub struct PrNumber ( NonZeroU32 ) ;
218194
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-
226195/// Represents owner of a repository
227196///
228197/// E.g. in `helix-editor/helix/master`, this is `helix-editor`
198+ #[ nutype_test_util:: derive( From ) ]
229199#[ nutype(
230200 validate( not_empty) ,
231201 derive(
@@ -237,6 +207,7 @@ pub struct RepoOwner(String);
237207/// Represents name of a repository
238208///
239209/// E.g. in `helix-editor/helix/master`, this is `helix`
210+ #[ nutype_test_util:: derive( From ) ]
240211#[ nutype(
241212 validate( not_empty) ,
242213 derive(
@@ -248,6 +219,7 @@ pub struct RepoName(String);
248219/// Name of a branch in git
249220///
250221/// E.g. in `helix-editor/helix/master`, this is `master`
222+ #[ nutype_test_util:: derive( From ) ]
251223#[ nutype(
252224 validate( not_empty) ,
253225 derive(
@@ -267,6 +239,7 @@ impl FromStr for BranchName {
267239}
268240
269241/// File name of a patch
242+ #[ nutype_test_util:: derive( From ) ]
270243#[ nutype( validate( predicate = |p| !p. as_os_str( ) . is_empty( ) ) , derive( Hash , Eq , PartialEq , Debug , AsRef , Deserialize , Clone , FromStr ) ) ]
271244pub struct PatchName ( PathBuf ) ;
272245
@@ -277,6 +250,7 @@ impl Display for PatchName {
277250}
278251
279252/// Represents a git commit hash
253+ #[ nutype_test_util:: derive( From ) ]
280254#[ nutype(
281255 validate( not_empty, predicate = is_valid_commit_hash) ,
282256 derive( Debug , Eq , PartialEq , Ord , PartialOrd , Clone , AsRef )
0 commit comments