mirror of
https://github.com/ziglang/zig.git
synced 2026-01-06 05:25:10 +00:00
Use tuples in multiTrait
This commit is contained in:
parent
0328537ca6
commit
dc4fea983d
@ -9,11 +9,7 @@ const meta = @import("../meta.zig");
|
||||
|
||||
pub const TraitFn = fn (type) bool;
|
||||
|
||||
//////Trait generators
|
||||
|
||||
// TODO convert to tuples when #4335 is done
|
||||
pub const TraitList = []const TraitFn;
|
||||
pub fn multiTrait(comptime traits: TraitList) TraitFn {
|
||||
pub fn multiTrait(comptime traits: var) TraitFn {
|
||||
const Closure = struct {
|
||||
pub fn trait(comptime T: type) bool {
|
||||
inline for (traits) |t|
|
||||
@ -39,7 +35,7 @@ test "std.meta.trait.multiTrait" {
|
||||
}
|
||||
};
|
||||
|
||||
const isVector = multiTrait(&[_]TraitFn{
|
||||
const isVector = multiTrait(.{
|
||||
hasFn("add"),
|
||||
hasField("x"),
|
||||
hasField("y"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user