From 3572319b4cb1a4163624a5fe328886f1928dbc4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 18 Oct 2024 11:33:12 +0100 Subject: feat(vim.validate): improve fast form and deprecate spec form Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument. --- runtime/lua/vim/func/_memoize.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim/func/_memoize.lua') diff --git a/runtime/lua/vim/func/_memoize.lua b/runtime/lua/vim/func/_memoize.lua index 65210351bf..6e557905a7 100644 --- a/runtime/lua/vim/func/_memoize.lua +++ b/runtime/lua/vim/func/_memoize.lua @@ -39,10 +39,8 @@ end --- @param strong? boolean --- @return F return function(hash, fn, strong) - vim.validate({ - hash = { hash, { 'number', 'string', 'function' } }, - fn = { fn, 'function' }, - }) + vim.validate('hash', hash, { 'number', 'string', 'function' }) + vim.validate('fn', fn, 'function') ---@type table> local cache = {} -- cgit