util: Add awful.util.table.crush

Allow to replace copy pasted code used to apply class heritage in
much of wibox.widget
This commit is contained in:
Emmanuel Lepage Vallee 2016-01-15 22:05:24 -05:00
parent 502c3631d2
commit 3d2b31bbb9
1 changed files with 12 additions and 0 deletions

View File

@ -399,6 +399,18 @@ function util.table.join(...)
return ret return ret
end end
--- Override elements in the first table by the one in the second
-- @tparam table t the table to be overriden
-- @tparam table set the table used to override members of `t`
-- @treturn table t (for convenience)
function util.table.crush(t, set)
for k, v in pairs(set) do
t[k] = v
end
return t
end
--- Check if a table has an item and return its key. --- Check if a table has an item and return its key.
-- @param t The table. -- @param t The table.
-- @param item The item to look for in values of the table. -- @param item The item to look for in values of the table.