@@ -18,12 +18,27 @@ to_binary(Val) when is_integer(Val) -> integer_to_binary(Val);
1818to_binary (Val ) when is_function (Val ) -> list_to_binary (io_lib :format (" ~w " , [Val ]));
1919to_binary (Val ) -> Val .
2020
21- -spec to_list (Val :: integer () | list () | binary () | atom () | map ()) -> list ().
21+ -spec to_list (Val :: integer () | list () | binary () | atom () | map () | inet : ip_address () ) -> list ().
2222to_list (Val ) when is_list (Val ) -> Val ;
2323to_list (Val ) when is_map (Val ) -> maps :to_list (Val );
2424to_list (Val ) when is_atom (Val ) -> atom_to_list (Val );
2525to_list (Val ) when is_binary (Val ) -> binary_to_list (Val );
26- to_list (Val ) when is_integer (Val ) -> integer_to_list (Val ).
26+ to_list (Val ) when is_integer (Val ) -> integer_to_list (Val );
27+ to_list ({V0 , V1 , V2 , V3 }= Val ) when (is_integer (V0 ) andalso (V0 >= 0 andalso V0 =< 255 )) andalso
28+ (is_integer (V1 ) andalso (V1 >= 0 andalso V1 =< 255 )) andalso
29+ (is_integer (V2 ) andalso (V2 >= 0 andalso V2 =< 255 )) andalso
30+ (is_integer (V3 ) andalso (V3 >= 0 andalso V3 =< 255 )) ->
31+ io_lib :format (" ~w " , [Val ]);
32+ to_list ({V0 , V1 , V2 , V3 , V4 , V5 , V6 , V7 }= Val )
33+ when (is_integer (V0 ) andalso (V0 >= 0 andalso V0 =< 65535 )) andalso
34+ (is_integer (V1 ) andalso (V1 >= 0 andalso V1 =< 65535 )) andalso
35+ (is_integer (V2 ) andalso (V2 >= 0 andalso V2 =< 65535 )) andalso
36+ (is_integer (V3 ) andalso (V3 >= 0 andalso V3 =< 65535 )) andalso
37+ (is_integer (V4 ) andalso (V4 >= 0 andalso V4 =< 65535 )) andalso
38+ (is_integer (V5 ) andalso (V5 >= 0 andalso V5 =< 65535 )) andalso
39+ (is_integer (V6 ) andalso (V6 >= 0 andalso V6 =< 65535 )) andalso
40+ (is_integer (V7 ) andalso (V7 >= 0 andalso V7 =< 65535 )) ->
41+ io_lib :format (" ~w " , [Val ]).
2742
2843-spec to_atom (Val :: atom () | list () | binary ()) -> atom ().
2944to_atom (Val ) when is_atom (Val ) -> Val ;
0 commit comments