Mercurial > prosody-hg
comparison util/set.lua @ 13033:a863e4237b91
util.set: Change tostring format to {a, b, c}
Makes it easier to make out where the set starts and ends in cases where
it may get embedded and tostring()-ed in a log message.
{ } taken over from util.array for consistency with some other systems
syntax for Sets, e.g. Python
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 06 Apr 2023 16:30:26 +0200 |
| parents | 895a82c5d8d4 |
| children | dee26e4cfb2b |
comparison
equal
deleted
inserted
replaced
| 13032:ea4923bebca9 | 13033:a863e4237b91 |
|---|---|
| 184 function set_mt.__tostring(set) | 184 function set_mt.__tostring(set) |
| 185 local s, items = { }, set._items; | 185 local s, items = { }, set._items; |
| 186 for item in pairs(items) do | 186 for item in pairs(items) do |
| 187 s[#s+1] = tostring(item); | 187 s[#s+1] = tostring(item); |
| 188 end | 188 end |
| 189 return t_concat(s, ", "); | 189 return "{"..t_concat(s, ", ").."}"; |
| 190 end | 190 end |
| 191 | 191 |
| 192 function set_mt.__freeze(set) | 192 function set_mt.__freeze(set) |
| 193 local s = {}; | 193 local s = {}; |
| 194 for item in pairs(set._items) do | 194 for item in pairs(set._items) do |
