Commit 155f6c5d authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Remove direct access to value of option type

parent 7defe3c3
...@@ -8,8 +8,8 @@ package Option_Type is ...@@ -8,8 +8,8 @@ package Option_Type is
type Option is tagged private; type Option is tagged private;
function Just (I : T) return Option; function Just (I : T) return Option;
function Nothing return Option; function Nothing return Option;
function Just (O : Option) return T; -- function Just (O : Option) return T;
function Value (O : Option) return T renames Just; -- function Value (O : Option) return T renames Just;
function Value_Or (O : Option; Default : T) return T; function Value_Or (O : Option; Default : T) return T;
function Has_Value (O : Option) return Boolean; function Has_Value (O : Option) return Boolean;
...@@ -27,7 +27,7 @@ private ...@@ -27,7 +27,7 @@ private
function Nothing return Option is function Nothing return Option is
(Present => False, others => <>); (Present => False, others => <>);
function Just (O : Option) return T is (O.Value); -- function Just (O : Option) return T is (O.Value);
function Value_Or (O : Option; Default : T) return T is function Value_Or (O : Option; Default : T) return T is
(if O.Present then O.Value else Default); (if O.Present then O.Value else Default);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment