File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
package strawman .collections
2
2
3
3
import Predef .{augmentString => _ , wrapString => _ , _ }
4
+ import scala .language .implicitConversions
4
5
import scala .reflect .ClassTag
5
6
6
7
/** A strawman architecture for new collections. It contains some
@@ -13,7 +14,17 @@ import scala.reflect.ClassTag
13
14
*/
14
15
object CollectionStrawMan1 {
15
16
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
+ }
25
+
26
+ implicit def intToLengthType (x : Int ): LengthType = LengthType (x)
27
+ implicit def lengthTypeToLong (x : LengthType ): Long = x.u.toLong
17
28
18
29
/* ------------ Base Traits -------------------------------- */
19
30
You can’t perform that action at this time.
0 commit comments