From 13757f5ed5d1f0fa8f197ac6922ae3aa80cfd6f7 Mon Sep 17 00:00:00 2001 From: Chad Scherrer Date: Tue, 4 May 2021 06:52:06 -0700 Subject: [PATCH] Base.NamedTuple(itr) = (; itr...) (#741) --- Project.toml | 2 +- README.md | 5 ++++- src/Compat.jl | 5 +++++ test/runtests.jl | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 6fdc5ec8a..346360792 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Compat" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.27.0" +version = "3.28.0" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/README.md b/README.md index fd4d96506..870831f59 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ changes in `julia`. ## Supported features +* `NamedTuple(::Pairs)` ([#37454]) (since Compat 3.28) + * `UUID(::UUID)` and `parse(::Type{UUID}, string)` ([#36018] / [#36199]) (since Compat 3.27) * `cispi(x)` for accurately calculating `cis(pi * x)` ([#38449]) (since Compat 3.25) @@ -238,4 +240,5 @@ Note that you should specify the correct minimum version for `Compat` in the [#29790]: https://github.com/JuliaLang/julia/pull/29790 [#38449]: https://github.com/JuliaLang/julia/pull/38449 [#36018]: https://github.com/JuliaLang/julia/pull/36018 -[#36199]: https://github.com/JuliaLang/julia/pull/36199 \ No newline at end of file +[#36199]: https://github.com/JuliaLang/julia/pull/36199 +[#37454]: https://github.com/JuliaLang/julia/pull/37454 diff --git a/src/Compat.jl b/src/Compat.jl index 92fd5bb2a..64ca11ac8 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -889,6 +889,11 @@ if VERSION < v"1.6.0-DEV.196" Base.parse(::Type{UUID}, s::AbstractString) = UUID(s) end +# https://github.com/JuliaLang/julia/pull/37454 +if VERSION < v"1.6.0-DEV.877" + Base.NamedTuple(itr) = (; itr...) +end + include("iterators.jl") include("deprecated.jl") diff --git a/test/runtests.jl b/test/runtests.jl index 4b9d4e321..f324be773 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -878,3 +878,9 @@ end uuid2 = UUID(uuidstr2) @test parse(UUID, uuidstr2) == uuid2 end + +# https://github.com/JuliaLang/julia/pull/37454 +@testset "Base.NamedTuple(itr) = (; itr...)" begin + f(;kwargs...) = NamedTuple(kwargs) + @test f(a=1, b=2) == (a=1, b=2) +end