This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
// format a number in two’s complement representation | |
let a: i8 = -1; | |
assert_eq!(format!("{:b}", a), "11111111"); | |
// concatenate 3 bit slices | |
let b: i8 = (0b10 << 4) + (0b10 << 2) + (0b10); | |
assert_eq!(b, 0b101010); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const queryObjectId = Symbol("sql_query") | |
const sql = (string, ...values) => { | |
const isQuery = query => query.hasOwnProperty(queryObjectId) | |
let text = '' | |
for (const [i, s] of string.entries()) { | |
text += s | |
if (i !== string.length - 1) { | |
if (isQuery(values[i])) { |
NewerOlder