Skip to content

Commit

Permalink
rebar
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Jan 21, 2017
1 parent 610a2fe commit ac1aaf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ erl_crash.dump
.rebar
logs
_build
doc
8 changes: 5 additions & 3 deletions src/coers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
to_bool/2
]).

-export_type([result/0]).

%% Results of coercion are wrapped into a result record
-record(result, {
succeeded :: boolean(),
Expand Down Expand Up @@ -102,7 +104,7 @@ maybe_string(List) when is_list(List) ->
maybe_string(_) -> false.

%% @doc try to coers term into string
-spec to_string(term()) -> string().
-spec to_string(any()) -> string().
to_string(Term) when is_bitstring(Term) ->
List = binary_to_list(Term),
to_string(List);
Expand All @@ -115,7 +117,7 @@ to_string(Term) ->
end.

%% @doc Replace value if coercion failed
%% @doc the suceeded flag is preserved
%% the suceeded flag is preserved
-spec to_string(term(), term()) -> result().
to_string(Term, Default) ->
unless(to_string(Term), Default).
Expand Down Expand Up @@ -182,7 +184,7 @@ to_int(Obj) when is_atom(Obj) ->
to_int(_) -> new(false, 0).

%% @doc try coercion or define a default value
%% @doc the suceeded flag is preserved
%% the suceeded flag is preserved
-spec to_int(term(), term()) -> result().
to_int(Term, Default) ->
unless(to_int(Term), Default).
Expand Down

0 comments on commit ac1aaf0

Please sign in to comment.