Inspect.Opts

Inspect.Opts

Defines the Inspect.Opts used by the Inspect protocol.

The following fields are available:

  • :structs - when false, structs are not formatted by the inspect protocol, they are instead printed as maps, defaults to true.

  • :binaries - when :as_strings all binaries will be printed as strings, non-printable bytes will be escaped.

    When :as_binaries all binaries will be printed in bit syntax.

    When the default :infer, the binary will be printed as a string if it is printable, otherwise in bit syntax.

  • :charlists - when :as_charlists all lists will be printed as char lists, non-printable elements will be escaped.

    When :as_lists all lists will be printed as lists.

    When the default :infer, the list will be printed as a charlist if it is printable, otherwise as list.

  • :limit - limits the number of items that are printed for tuples, bitstrings, and lists, does not apply to strings nor charlists, defaults to 50.

  • :pretty - if set to true enables pretty printing, defaults to false.

  • :width - defaults to 80 characters, used when pretty is true or when printing to IO devices. Set to 0 to force each item to be printed on its own line.

  • :base - prints integers as :binary, :octal, :decimal, or :hex, defaults to :decimal. When inspecting binaries any :base other than :decimal implies binaries: :as_binaries.

  • :safe - when false, failures while inspecting structs will be raised as errors instead of being wrapped in the Inspect.Error exception. This is useful when debugging failures and crashes for custom inspect implementations

  • :syntax_colors - when set to a keyword list of colors the output will be colorized. The keys are types and the values are the colors to use for each type. e.g. [number: :red, atom: :blue]. Types can include :number, :atom, regex, :tuple, :map, :list, and :reset. Colors can be any IO.ANSI.ansidata/0 as accepted by IO.ANSI.format/1.

Summary

Types

color_key()
t()

Types

color_key()

color_key() :: atom

t()

t() :: %Inspect.Opts{base: :decimal | :binary | :hex | :octal, binaries: :infer | :as_binaries | :as_strings, char_lists: :infer | :as_lists | :as_char_lists, charlists: :infer | :as_lists | :as_charlists, limit: pos_integer | :infinity, pretty: boolean, safe: boolean, structs: boolean, syntax_colors: [{color_key, IO.ANSI.ansidata}], width: pos_integer | :infinity}

© 2012–2017 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/elixir/1.4.5/Inspect.Opts.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部