git.iko.soy/typeable/nixpkgs
on master help sign in
lib: toHex -> toHexString & toBase -> toBaseDigits

This makes the type of these functions more apparent from the name.

commit6e7822b8f3e495e3c2c12b121ca81d8565298589 authorBas van Dijk <v.dijk.bas@gmail.com> dateMon 20 Jul 2020, 13:14 (6 years ago) parente15815e
4 files changed+16−16
lib/default.nix+1−1 lib/tests/misc.nix+4−4 lib/trivial.nix+10−10 nixos/lib/qemu-flags.nix+1−1
lib/default.nix+1−1
@@ -67,7 +67,7 @@ let
6767 inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
6868 bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
6969 importJSON warn info showWarnings nixpkgsVersion version mod compare
70− splitByAndCompare functionArgs setFunctionArgs isFunction toHex toBase;
70+ splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
7171 inherit (fixedPoints) fix fix' converge extends composeExtensions
7272 makeExtensible makeExtensibleWithCustomName;
7373 inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
lib/tests/misc.nix+4−4
@@ -102,13 +102,13 @@ runTests {
102102 expected = 9;
103103 };
104104
105− testToHex = {
106− expr = toHex 250;
105+ testToHexString = {
106+ expr = toHexString 250;
107107 expected = "FA";
108108 };
109109
110− testToBase = {
111− expr = toBase 2 6;
110+ testToBaseDigits = {
111+ expr = toBaseDigits 2 6;
112112 expected = [ 1 1 0 ];
113113 };
114114
lib/trivial.nix+10−10
@@ -336,13 +336,13 @@ rec {
336336 /* Convert the given positive integer to a string of its hexadecimal
337337 representation. For example:
338338
339− toHex 0 => "0"
339+ toHexString 0 => "0"
340340
341− toHex 16 => "10"
341+ toHexString 16 => "10"
342342
343− toHex 250 => "FA"
343+ toHexString 250 => "FA"
344344 */
345− toHex = i:
345+ toHexString = i:
346346 let
347347 toHexDigit = d:
348348 if d < 10
@@ -357,18 +357,18 @@ rec {
357357 "15" = "F";
358358 }.${toString d};
359359 in
360− lib.concatMapStrings toHexDigit (toBase 16 i);
360+ lib.concatMapStrings toHexDigit (toBaseDigits 16 i);
361361
362− /* `toBase base i` converts the positive integer i to a list of its
362+ /* `toBaseDigits base i` converts the positive integer i to a list of its
363363 digits in the given base. For example:
364364
365− toBase 10 123 => [ 1 2 3 ]
365+ toBaseDigits 10 123 => [ 1 2 3 ]
366366
367− toBase 2 6 => [ 1 1 0 ]
367+ toBaseDigits 2 6 => [ 1 1 0 ]
368368
369− toBase 16 250 => [ 15 10 ]
369+ toBaseDigits 16 250 => [ 15 10 ]
370370 */
371− toBase = base: i:
371+ toBaseDigits = base: i:
372372 let
373373 go = i:
374374 if i < base
nixos/lib/qemu-flags.nix+1−1
@@ -6,7 +6,7 @@ let
66 pkgs.lib.optionalString (n < 16) "0" +
77 (if n > 255
88 then throw "Can't have more than 255 nets or nodes!"
9− else pkgs.lib.toHex n);
9+ else pkgs.lib.toHexString n);
1010in
1111
1212rec {