File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11package strawman .collections
22
33import Predef .{augmentString => _ , wrapString => _ , _ }
4+ import scala .language .implicitConversions
45import scala .reflect .ClassTag
56
67/** A strawman architecture for new collections. It contains some
@@ -13,7 +14,21 @@ import scala.reflect.ClassTag
1314 */
1415object CollectionStrawMan1 {
1516
16- type LengthType = Long
17+ type LengthTypeUnderlying = Long
18+
19+ final case class LengthType (u : LengthTypeUnderlying ) extends AnyVal {
20+ def + (other : LengthType ) = LengthType (u + other.u)
21+ def - (other : LengthType ) = LengthType (u - other.u)
22+ def / (other : LengthType ) = LengthType (u / other.u)
23+ def * (other : LengthType ) = LengthType (u * other.u)
24+ def < (other : LengthType ) = u < other.u
25+ def > (other : LengthType ) = u > other.u
26+ def <= (other : LengthType ) = u <= other.u
27+ def >= (other : LengthType ) = u >= other.u
28+ }
29+
30+ implicit def intToLengthType (x : Int ): LengthType = LengthType (x)
31+ implicit def lengthTypeToLong (x : LengthType ): Long = x.u.toLong
1732
1833 /* ------------ Base Traits -------------------------------- */
1934
You can’t perform that action at this time.
0 commit comments