aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-10-28 16:49:41 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 17:16:05 +0100
commit6d521dae843ee098e823e1c4a3bb2e426409dcea (patch)
tree86fb8de57d92c37ee5bd20b1ba40d1d083196243 /lib/stdlib/src
parente0e056a62c240542decac2e2b3765a5399efae62 (diff)
downloadotp-6d521dae843ee098e823e1c4a3bb2e426409dcea.tar.gz
otp-6d521dae843ee098e823e1c4a3bb2e426409dcea.tar.bz2
otp-6d521dae843ee098e823e1c4a3bb2e426409dcea.zip
stdlib: Enable io_lib:format/* for hamt maps
This is a commit to enable printouts of hashmaps during development and will be enhanced once hashmaps are in place.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/io_lib.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/stdlib/src/io_lib.erl b/lib/stdlib/src/io_lib.erl
index e90cda0533..24ae83da9c 100644
--- a/lib/stdlib/src/io_lib.erl
+++ b/lib/stdlib/src/io_lib.erl
@@ -296,8 +296,8 @@ write(T, D) when is_tuple(T) ->
write_tail(tl(tuple_to_list(T)), D-1, $,)],
$}]
end;
-%write(Term, D) when is_map(Term) -> write_map(Term, D);
-write(Term, D) -> write_map(Term, D).
+write(Term, D) when is_map(Term) -> write_map(Term, D);
+write(Term, D) -> write_hashmap(Term, D).
%% write_tail(List, Depth, CharacterBeforeDots)
%% Test the terminating case first as this looks better with depth.
@@ -315,6 +315,9 @@ write_port(Port) ->
write_ref(Ref) ->
erlang:ref_to_list(Ref).
+write_hashmap(Map,D) ->
+ ["#{", write_map_body(hashmap:to_list(Map),D), $}].
+
write_map(Map, D) when is_integer(D) ->
[$#,${,write_map_body(maps:to_list(Map), D),$}].