1414// limitations under the License.
1515
1616use crate :: displayer:: { DisplayProxy , DisplayerOf } ;
17+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
1718use crate :: trait_flag:: { self , TraitFlags } ;
1819use core:: cmp:: Ordering ;
1920use core:: fmt;
@@ -180,12 +181,14 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
180181/// let n_from_thread = std::thread::spawn(|| &N).join().unwrap();
181182/// assert_eq!(N, *n_from_thread);
182183/// ```
184+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
183185#[ repr( transparent) ]
184186pub struct Amount < const TF : TraitFlags , Unit , Repr > (
185187 Repr ,
186188 PhantomData < core:: sync:: atomic:: AtomicPtr < Unit > > ,
187189) ;
188190
191+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
189192impl < const TF : TraitFlags , Unit , Repr : Copy > Amount < TF , Unit , Repr > {
190193 // @TODO
191194 /// Returns the wrapped value.
@@ -208,6 +211,7 @@ impl<const TF: TraitFlags, Unit, Repr: Copy> Amount<TF, Unit, Repr> {
208211 }
209212}
210213
214+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
211215impl < const TF : TraitFlags , Unit , Repr > Amount < TF , Unit , Repr > {
212216 /// `new` is a synonym for `from` that can be evaluated in
213217 /// compile time. The main use-case of this functions is defining
@@ -217,6 +221,7 @@ impl<const TF: TraitFlags, Unit, Repr> Amount<TF, Unit, Repr> {
217221 }
218222}
219223
224+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
220225impl < const TF : TraitFlags , Unit : Default , Repr > Amount < TF , Unit , Repr > {
221226 // @TODO similar but without &self
222227 //
@@ -242,6 +247,7 @@ impl<const TF: TraitFlags, Unit: Default, Repr> Amount<TF, Unit, Repr> {
242247 }
243248}
244249
250+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
245251impl < const TF : TraitFlags , Unit , Repr > Amount < TF , Unit , Repr >
246252where
247253 Unit : DisplayerOf < Self > , //@TODO cleanup: Amount<TF, Unit, Repr>>,
@@ -275,6 +281,7 @@ where
275281 }
276282}
277283
284+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
278285impl < const TF : TraitFlags , Unit , Repr > From < Repr > for Amount < TF , Unit , Repr > {
279286 fn from ( repr : Repr ) -> Self {
280287 Self :: new ( repr)
@@ -287,6 +294,7 @@ impl<const TF: TraitFlags, Unit, Repr> From<Repr> for Amount<TF, Unit, Repr> {
287294// `PartialEq<Wrapper<T>>` require `T` to implement `PartialEq`, which
288295// is not what we want: `T` is phantom in our case.
289296
297+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
290298impl < const TF : TraitFlags , Unit , Repr : Clone > Clone for Amount < TF , Unit , Repr > {
291299 fn clone ( & self ) -> Self {
292300 Amount ( self . 0 . clone ( ) , PhantomData )
@@ -311,32 +319,38 @@ impl<Unit, Repr: Default> Default
311319 }
312320}
313321
322+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
314323impl < const TF : TraitFlags , Unit , Repr : PartialEq > PartialEq for Amount < TF , Unit , Repr > {
315324 fn eq ( & self , rhs : & Self ) -> bool {
316325 self . 0 . eq ( & rhs. 0 )
317326 }
318327}
319328
329+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
320330impl < const TF : TraitFlags , Unit , Repr : Eq > Eq for Amount < TF , Unit , Repr > { }
321331
332+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
322333impl < const TF : TraitFlags , Unit , Repr : PartialOrd > PartialOrd for Amount < TF , Unit , Repr > {
323334 fn partial_cmp ( & self , rhs : & Self ) -> Option < Ordering > {
324335 self . 0 . partial_cmp ( & rhs. 0 )
325336 }
326337}
327338
339+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
328340impl < const TF : TraitFlags , Unit , Repr : Ord > Ord for Amount < TF , Unit , Repr > {
329341 fn cmp ( & self , rhs : & Self ) -> Ordering {
330342 self . 0 . cmp ( & rhs. 0 )
331343 }
332344}
333345
346+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
334347impl < const TF : TraitFlags , Unit , Repr : Hash > Hash for Amount < TF , Unit , Repr > {
335348 fn hash < H : Hasher > ( & self , state : & mut H ) {
336349 self . 0 . hash ( state)
337350 }
338351}
339352
353+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
340354impl < const TF : TraitFlags , Unit , Repr > Add for Amount < TF , Unit , Repr >
341355where
342356 Repr : AddAssign + Copy ,
@@ -348,6 +362,7 @@ where
348362 }
349363}
350364
365+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
351366impl < const TF : TraitFlags , Unit , Repr > AddAssign for Amount < TF , Unit , Repr >
352367where
353368 Repr : AddAssign + Copy ,
@@ -357,6 +372,7 @@ where
357372 }
358373}
359374
375+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
360376impl < const TF : TraitFlags , Unit , Repr > SubAssign for Amount < TF , Unit , Repr >
361377where
362378 Repr : SubAssign + Copy ,
@@ -366,6 +382,7 @@ where
366382 }
367383}
368384
385+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
369386impl < const TF : TraitFlags , Unit , Repr > Sub for Amount < TF , Unit , Repr >
370387where
371388 Repr : SubAssign + Copy ,
@@ -378,6 +395,7 @@ where
378395 }
379396}
380397
398+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
381399impl < const TF : TraitFlags , Unit , Repr > MulAssign < Repr > for Amount < TF , Unit , Repr >
382400where
383401 Repr : MulAssign + Copy ,
@@ -387,6 +405,7 @@ where
387405 }
388406}
389407
408+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
390409impl < const TF : TraitFlags , Unit , Repr > Mul < Repr > for Amount < TF , Unit , Repr >
391410where
392411 Repr : MulAssign + Copy ,
@@ -399,6 +418,7 @@ where
399418 }
400419}
401420
421+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
402422impl < const TF : TraitFlags , Unit , Repr > Div < Self > for Amount < TF , Unit , Repr >
403423where
404424 Repr : Div < Repr > + Copy ,
@@ -410,6 +430,7 @@ where
410430 }
411431}
412432
433+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
413434impl < const TF : TraitFlags , Unit , Repr > fmt:: Debug for Amount < TF , Unit , Repr >
414435where
415436 Repr : fmt:: Debug ,
@@ -419,6 +440,7 @@ where
419440 }
420441}
421442
443+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
422444impl < const TF : TraitFlags , Unit , Repr > fmt:: Display for Amount < TF , Unit , Repr >
423445where
424446 Repr : fmt:: Display ,
@@ -435,13 +457,15 @@ where
435457// We want serialization format of `Repr` and the `Amount` to match
436458// exactly, that's why we have to provide custom instances.
437459#[ cfg( feature = "serde" ) ]
460+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
438461impl < const TF : TraitFlags , Unit , Repr : Serialize > Serialize for Amount < TF , Unit , Repr > {
439462 fn serialize < S : Serializer > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error > {
440463 self . 0 . serialize ( serializer)
441464 }
442465}
443466
444467#[ cfg( feature = "serde" ) ]
468+ #[ cfg_attr( feature = "unstable_generic_const_own_type" , allow( deprecated) ) ]
445469impl < ' de , const TF : TraitFlags , Unit , Repr > Deserialize < ' de > for Amount < TF , Unit , Repr >
446470where
447471 Repr : Deserialize < ' de > ,
0 commit comments