mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
lib.gvariant.mkArray: refactor
This commit is contained in:
parent
feb74fca37
commit
e1ae8a8194
1 changed files with 3 additions and 2 deletions
|
|
@ -194,11 +194,12 @@ rec {
|
|||
vs = map mkValue (
|
||||
if elems == [ ] then throw "Please create empty array with mkEmptyArray." else elems
|
||||
);
|
||||
firstType = (head vs).type;
|
||||
elemType =
|
||||
if lib.any (t: (head vs).type != t) (map (v: v.type) vs) then
|
||||
if lib.any (v: v.type != firstType) vs then
|
||||
throw "Elements in a list should have same type."
|
||||
else
|
||||
(head vs).type;
|
||||
firstType;
|
||||
in
|
||||
mkPrimitive (type.arrayOf elemType) vs
|
||||
// {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue