Skip to content

Commit 324dde1

Browse files
committed
Reuse Inspect.Opt.new_opt options in IO.inspect and Kernel.inspect
Remove deprecated char_lists option
1 parent f461a51 commit 324dde1

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

lib/elixir/lib/inspect/algebra.ex

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,25 @@ defmodule Inspect.Opts do
118118
@typedoc """
119119
Options for building an `Inspect.Opts` struct with `new/1`.
120120
"""
121-
@type new_opts :: [
122-
base: :decimal | :binary | :hex | :octal,
123-
binaries: :infer | :as_binaries | :as_strings,
124-
charlists: :infer | :as_lists | :as_charlists,
125-
custom_options: keyword,
126-
inspect_fun: (any, t -> Inspect.Algebra.t()),
127-
limit: non_neg_integer | :infinity,
128-
pretty: boolean,
129-
printable_limit: non_neg_integer | :infinity,
130-
safe: boolean,
131-
structs: boolean,
132-
syntax_colors: [{color_key, IO.ANSI.ansidata()}],
133-
width: non_neg_integer | :infinity
134-
]
121+
@type new_opt ::
122+
{:base, :decimal | :binary | :hex | :octal}
123+
| {:binaries, :infer | :as_binaries | :as_strings}
124+
| {:charlists, :infer | :as_lists | :as_charlists}
125+
| {:custom_options, keyword}
126+
| {:inspect_fun, (any, t -> Inspect.Algebra.t())}
127+
| {:limit, non_neg_integer | :infinity}
128+
| {:pretty, boolean}
129+
| {:printable_limit, non_neg_integer | :infinity}
130+
| {:safe, boolean}
131+
| {:structs, boolean}
132+
| {:syntax_colors, [{color_key, IO.ANSI.ansidata()}]}
133+
| {:width, non_neg_integer | :infinity}
135134

136135
@doc """
137136
Builds an `Inspect.Opts` struct.
138137
"""
139138
@doc since: "1.13.0"
140-
@spec new(new_opts()) :: t
139+
@spec new([new_opt()]) :: t
141140
def new(opts) do
142141
struct(%Inspect.Opts{inspect_fun: default_inspect_fun()}, opts)
143142
end

lib/elixir/lib/io.ex

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,7 @@ defmodule IO do
128128
@type nodata :: {:error, term} | :eof
129129
@type chardata :: String.t() | maybe_improper_list(char | chardata, String.t() | [])
130130

131-
@type inspect_opts :: [
132-
label: term,
133-
base: :decimal | :binary | :hex | :octal,
134-
binaries: :infer | :as_binaries | :as_strings,
135-
charlists: :infer | :as_lists | :as_charlists,
136-
char_lists: :infer,
137-
custom_options: keyword,
138-
inspect_fun: (any, Inspect.Opts.t() -> Inspect.Algebra.t()),
139-
limit: non_neg_integer | :infinity,
140-
pretty: boolean,
141-
printable_limit: non_neg_integer | :infinity,
142-
safe: boolean,
143-
structs: boolean,
144-
syntax_colors: [{atom, IO.ANSI.ansidata()}],
145-
width: non_neg_integer | :infinity
146-
]
131+
@type inspect_opts :: [Inspect.Opts.new_opt() | {:label, term}]
147132

148133
@typedoc """
149134
Stacktrace information as keyword options for `warn/2`.

lib/elixir/lib/kernel.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ defmodule Kernel do
24562456
See the "Deriving" section of the documentation of the `Inspect`
24572457
protocol for more information.
24582458
"""
2459-
@spec inspect(Inspect.t(), IO.inspect_opts()) :: String.t()
2459+
@spec inspect(Inspect.t(), [Inspect.Opts.new_opt()]) :: String.t()
24602460
def inspect(term, opts \\ []) when is_list(opts) do
24612461
opts = Inspect.Opts.new(opts)
24622462

0 commit comments

Comments
 (0)