You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some problems matching some bytes but maybe it is because I don't really understand how matching should work. As a reduced test case I have:
let%test "match bytestring" =
let str = "\x01\x02" in
let bstr = Bytestring.of_string str in
match%b bstr with
| {| b1::8, b2::8 |} ->
print_endline ((string_of_int b1) ^ " - " ^ (string_of_int b2));
true
| {| _rest |} -> false
which as I understand should print "1 - 2", but instead is failing the test (getting to the _rest branch). If I change it to something like:
let%test "match bytestring" =
let str = "\x01\x02" in
let bstr = Bytestring.of_string str in
match%b bstr with
| {| b1::8, b2::8, rest |} ->
print_endline ((string_of_int b1) ^ " - " ^ (string_of_int b2) ^ " - " ^ (string_of_int (Bytestring.length rest)));
true
| {| _rest |} -> false
I got "0 - 0 - 2" printed which means in this case it takes the first branch, but it is not consuming anything for b1 and b2 and rest is just the whole bytestring that was matched.
Is there something wrong in how I try to match bytestrings?
The text was updated successfully, but these errors were encountered:
I am having some problems matching some bytes but maybe it is because I don't really understand how matching should work. As a reduced test case I have:
which as I understand should print "1 - 2", but instead is failing the test (getting to the _rest branch). If I change it to something like:
I got "0 - 0 - 2" printed which means in this case it takes the first branch, but it is not consuming anything for b1 and b2 and rest is just the whole bytestring that was matched.
Is there something wrong in how I try to match bytestrings?
The text was updated successfully, but these errors were encountered: