Skip to content

Instantly share code, notes, and snippets.

@nemosupremo
Created September 13, 2018 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemosupremo/7da00fe45162f56e74cee242bda5e656 to your computer and use it in GitHub Desktop.
Save nemosupremo/7da00fe45162f56e74cee242bda5e656 to your computer and use it in GitHub Desktop.
let byte_offset = bit_idx / 8;
let byte = match val {
database::Value::String(s) => {
if byte_offset < s.len() {
s[byte_offset]
}
0 as u8
},
database::Value::Integer(i) => {
let s = &Bytes::from(i.to_string());
if byte_offset < s.len() {
s[byte_offset]
}
0 as u8
},
_ => 0 return Err(Error::InvalidType)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment