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
ERROR: Found invalid undo record! Undo record len=18446744073709546430, rec_offset=8509, next_rec_offset=3323 | |
use std::num::Wrapping; | |
fn main() { | |
let t = Wrapping(0u64) - (Wrapping(8509u64) - Wrapping(3323u64)); | |
println!("{}", t); | |
} |
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
// Copyright 2023 Pelikan Foundation LLC. | |
// Licensed under the Apache License, Version 2.0 | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
//! Common, performance-oriented mechanisms of parsing byte strings into various types | |
/// maximum length of a string that could be stored as a u64 in Redis | |
/// comment from redis/util.h | |
/// > Bytes needed for long -> str + '\0' |
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 incr(&mut self, incr: &Incr) -> Response { | |
let value = if let Some(item) = self.data.get(incr.key()) { | |
match item.value() { | |
seg::Value::Bytes(b) => None, | |
seg::Value::U64(v) => { | |
Some(v) | |
} | |
} | |
} else { | |
Some(0) |
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
use std::cell::RefCell; | |
use std::collections::HashMap; | |
use std::rc::Rc; | |
struct Node<V> { | |
value: Option<V>, | |
terminal: bool, | |
children: HashMap<char, Node<V>>, | |
} |
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
struct SparseVector { | |
pub compressed: Vec<(usize, i32)> | |
} | |
/** | |
* `&self` means the method takes an immutable reference. | |
* If you need a mutable reference, change it to `&mut self` instead. | |
*/ | |
impl SparseVector { | |
fn new(nums: Vec<i32>) -> Self { |
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
[package] | |
name = "particular" | |
version = "0.1.0" | |
authors = ["Dermot Haughey <hderms@gmail.com>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
piston = "0.52.1" |
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
use std::{ | |
collections::hash_map::DefaultHasher, | |
hash::{Hash, Hasher}, | |
}; | |
const SIZE: usize = 2 << 12; | |
const CHAIN_CAPACITY: usize = 16; | |
struct HashTable<K: Hash + PartialEq, V> { | |
table: Vec<Vec<(K, V)>>, | |
} | |
impl<K: Hash + PartialEq, V> HashTable<K, V> { |
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
use std::cmp::{min, max}; | |
impl Solution { | |
pub fn interval_intersection(first_list: Vec<Vec<i32>>, second_list: Vec<Vec<i32>>) -> Vec<Vec<i32>> { | |
let mut i: usize = 0; | |
let mut j: usize = 0; | |
let mut vec: Vec<Vec<i32>> = Vec::with_capacity(max(first_list.len(), second_list.len())); | |
while (i < first_list.len() && j < second_list.len()) { | |
let left = &first_list[i]; | |
let right = &second_list[j]; |
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
impl Solution { | |
pub fn valid_palindrome(s: String) -> bool { | |
let mut i: usize = 0; | |
let mut j: usize = s.len() - 1; | |
let s = s.as_bytes(); | |
loop { | |
if s[i] != s[j] { | |
return Solution::is_palindrome(s.clone(), i + 1, j) || Solution::is_palindrome(s.clone(), i, j - 1); | |
} | |
i += 1; |
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
while let Some(chunk) = stream.next().await { | |
let c: UploadFileRequest = chunk?; | |
hasher.update(&c.chunk); | |
temp_file.write(&c.chunk).unwrap(); | |
} | |
println!("temp file path is {:?}", temp_file.path()); | |
temp_file.flush().unwrap() |
NewerOlder