File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -2596,6 +2596,10 @@ ${operatorComment('&' + x.operator, True)}
2596
2596
% end
2597
2597
}
2598
2598
2599
+ % {
2600
+ bitSizes = [ 8 , 16 , 32 , 64 ]
2601
+ } %
2602
+
2599
2603
extension FixedWidthInteger {
2600
2604
/// Returns a random representation of this integer.
2601
2605
///
@@ -2608,14 +2612,10 @@ extension FixedWidthInteger {
2608
2612
@_inlineable
2609
2613
public static func random< T : RandomNumberGenerator > ( using generator: T) - > Self {
2610
2614
switch bitWidth {
2611
- case 8 :
2612
- return Self . init ( truncatingIfNeeded: generator. next ( UInt8 . self) )
2613
- case 16 :
2614
- return Self . init ( truncatingIfNeeded: generator. next ( UInt16 . self) )
2615
- case 32 :
2616
- return Self . init ( truncatingIfNeeded: generator. next ( UInt32 . self) )
2617
- case 64 :
2618
- return Self . init ( truncatingIfNeeded: generator. next ( UInt64 . self) )
2615
+ % for bitSize in bitSizes:
2616
+ case ${ bitSize} :
2617
+ return Self . init ( truncatingIfNeeded: generator. next ( UInt ${ bitSize} . self) )
2618
+ % end
2619
2619
default :
2620
2620
return Self . init ( truncatingIfNeeded: generator. next ( ) )
2621
2621
}
You can’t perform that action at this time.
0 commit comments