@@ -3385,9 +3385,9 @@ test "indexOfMax" {
33853385}
33863386
33873387/// Finds the indices of the smallest and largest number in a slice. O(n).
3388- /// Returns an anonymous struct with the fields `index_min` and `index_max` .
3388+ /// Returns the indices of the smallest and largest numbers in that order .
33893389/// `slice` must not be empty.
3390- pub fn indexOfMinMax (comptime T : type , slice : []const T ) IndexOfMinMaxResult {
3390+ pub fn indexOfMinMax (comptime T : type , slice : []const T ) struct { usize , usize } {
33913391 assert (slice .len > 0 );
33923392 var minVal = slice [0 ];
33933393 var maxVal = slice [0 ];
@@ -3403,15 +3403,13 @@ pub fn indexOfMinMax(comptime T: type, slice: []const T) IndexOfMinMaxResult {
34033403 maxIdx = i + 1 ;
34043404 }
34053405 }
3406- return .{ . index_min = minIdx , . index_max = maxIdx };
3406+ return .{ minIdx , maxIdx };
34073407}
34083408
3409- pub const IndexOfMinMaxResult = struct { index_min : usize , index_max : usize };
3410-
34113409test "indexOfMinMax" {
3412- try testing .expectEqual (IndexOfMinMaxResult { . index_min = 0 , . index_max = 6 }, indexOfMinMax (u8 , "abcdefg" ));
3413- try testing .expectEqual (IndexOfMinMaxResult { . index_min = 1 , . index_max = 0 }, indexOfMinMax (u8 , "gabcdef" ));
3414- try testing .expectEqual (IndexOfMinMaxResult { . index_min = 0 , . index_max = 0 }, indexOfMinMax (u8 , "a" ));
3410+ try testing .expectEqual (.{ 0 , 6 }, indexOfMinMax (u8 , "abcdefg" ));
3411+ try testing .expectEqual (.{ 1 , 0 }, indexOfMinMax (u8 , "gabcdef" ));
3412+ try testing .expectEqual (.{ 0 , 0 }, indexOfMinMax (u8 , "a" ));
34153413}
34163414
34173415pub fn swap (comptime T : type , a : * T , b : * T ) void {
0 commit comments