@@ -14,28 +14,25 @@ trait ByteVectorPlatform {
14
14
15
15
given FromDigits {
16
16
override inline def fromDigits (digits : String ): ByteVector =
17
- $ {ByteVectorFromDigits (' digits , Expr (10 ))}
17
+ $ {digitsToByteVector (' digits , Expr (10 ))}
18
18
override inline def fromDigits (digits : String , radix : Int ): ByteVector =
19
- $ {ByteVectorFromDigits (' digits , ' radix )}
19
+ $ {digitsToByteVector (' digits , ' radix )}
20
20
}
21
21
}
22
22
23
23
24
- object ByteVectorFromDigits {
25
-
26
- def apply (digits : Expr [String ], radix : Expr [Int ])(given qctx : QuoteContext ): Expr [ByteVector ] =
27
- (digits, radix) match {
28
- case (Const (ds), Const (r)) =>
29
- if (r == 16 ) {
30
- ' {ByteVector .fromValidHex($digits.tail)}
31
- } else {
32
- qctx.error(s " unsupported radix $r" , radix)
33
- ' {ByteVector .empty}
34
- }
35
- case other =>
36
- ' {
37
- if ($radix == 16 ) ByteVector .fromValidHex($digits.tail)
38
- else throw FromDigits .MalformedNumber (" unsupported radix" )
39
- }
40
- }
41
- }
24
+ def digitsToByteVector (digits : Expr [String ], radix : Expr [Int ])(given qctx : QuoteContext ): Expr [ByteVector ] =
25
+ (digits, radix) match {
26
+ case (Const (ds), Const (r)) =>
27
+ if (r == 16 ) {
28
+ ' {ByteVector .fromValidHex($digits.tail)}
29
+ } else {
30
+ qctx.error(s " unsupported radix $r" , radix)
31
+ ' {ByteVector .empty}
32
+ }
33
+ case other =>
34
+ ' {
35
+ if ($radix == 16 ) ByteVector .fromValidHex($digits.tail)
36
+ else throw FromDigits .MalformedNumber (" unsupported radix" )
37
+ }
38
+ }
0 commit comments