I have a method that tried to match a slice of [u8] to a number of byte string literals:
pub(crate) fn from_slice(slice: &[u8]) -> Option<SqlStateCode> {
match slice {
b"3030303030" => Some(SqlStateCode::SuccessfulCompletion),
b"3031303030" => Some(SqlStateCode::Warning),
b"3031303043" => Some(SqlStateCode::DynamicResultSetsReturned),
_=> None
}
}
Except it won't work unless I replace the byte string literal with an array:
[30, 31, 30, 30, 43] => Some(SqlStateCode::DynamicResultSetsReturned)
Is there a way to make this work with the literal?