text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ZePedroResende/cram path: /src/node/io/mod.rs #![allow(dead_code)] mod dns; use crate::node::Node; use crossbeam::Receiver; use dns::Dns; use std::collections::HashMap; use std::thread; use crate::serializers::*; pub struct Io { input_channel: Receiver<(i8, Vec<u8>, String)>, port: u...
code_fim
hard
{ "lang": "rust", "repo": "ZePedroResende/cram", "path": "/src/node/io/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: urs-of-the-backwoods/fresco path: /intonaco/src/component.rs // // Fresco Framework for Multi-Language Programming // Copyright 2015-2016 Peter Althainz // // Distributed under the Apache License, Version 2.0 // (See attached file LICENSE or copy at // http://www.apache.org/licenses/LI...
code_fim
hard
{ "lang": "rust", "repo": "urs-of-the-backwoods/fresco", "path": "/intonaco/src/component.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get(&self) -> Arc<T> { self.data.get() } // remark those functions are not logically threadsafe, although technically. Reading values during adding, setting setters is ok. // Having two threads simultaneously adding setters is not working, one thread might overwrite changes...
code_fim
hard
{ "lang": "rust", "repo": "urs-of-the-backwoods/fresco", "path": "/intonaco/src/component.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> for t in 0..n_jobs { let s = sender.clone(); pool.execute(move|| { let test_task = TaskTest::new(t); for i in 0..10 { // println!("{:?}# hello {}", test_task, i); // let wait_secs = die.sample(&mut rng); // thread::sleep(time::Duration::from_millis(wait_secs)...
code_fim
hard
{ "lang": "rust", "repo": "wgr1984/rusty-pieces", "path": "/rust_test_parallel2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wgr1984/rusty-pieces path: /rust_test_parallel2/src/main.rs // extern crate rand; // extern crate rayon; // use rand::{Rng, thread_rng}; // use rand::distributions::Alphanumeric; // use rayon::prelude::*; // fn main() { // let mut vec: Vec<(String, Vec<String>)> = vec![(String::new(), vec![S...
code_fim
medium
{ "lang": "rust", "repo": "wgr1984/rusty-pieces", "path": "/rust_test_parallel2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let handle = recv.for_each_concurrent(4, |item| async move { println!("Item receveived: {}", item); // thread::sleep(time::Duration::from_millis(100)); }); // let handle = recv.for_each(|item| { // println!("Item receveived: {}", item); // // thread::sleep(time::Duration::from_millis...
code_fim
hard
{ "lang": "rust", "repo": "wgr1984/rusty-pieces", "path": "/rust_test_parallel2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michaelmez39/sorts path: /tests/sort_tests.rs use sorts; use rand::prelude::*; macro_rules! time { ($x:expr, $n:expr) => {{ (0..$n).fold(std::time::Duration::new(0, 0), |acc, _| { let now = std::time::Instant::now(); $x; acc + now.elapsed() ...
code_fim
hard
{ "lang": "rust", "repo": "michaelmez39/sorts", "path": "/tests/sort_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut test_vec: Vec<usize> = (0..100).rev().collect(); sorts::insertion_sort(&mut test_vec); assert_sorted_ascending(&test_vec); } // #[test] // fn check_odd_even() { // let mut rng = rand::thread_rng(); // let mut test_vec: Vec<usize> = (0..100_000).map(|_| rng.gen::<usize>()).coll...
code_fim
medium
{ "lang": "rust", "repo": "michaelmez39/sorts", "path": "/tests/sort_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pierrechevalier83/unicode_types path: /src/generated/supplemental_arrows_a.rs /// An enum to represent all characters in the SupplementalArrowsA block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum SupplementalArrowsA { /// \u{27f0}: '⟰' UpwardsQuadrupleArrow, /// \u{2...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/supplemental_arrows_a.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|> let index: u32 = (*self).into(); use std::convert::TryFrom; Self::try_from(index + 1).ok() } } impl SupplementalArrowsA { /// The character with the lowest index in this unicode block pub fn new() -> Self { SupplementalArrowsA::UpwardsQuadrupleArrow } ...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/supplemental_arrows_a.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dhimasdewanto/learn_actix_web path: /src/routes/index_route.rs use actix_web::{HttpResponse, get}; use crate::repositories::NOTEREPO; <|fim_suffix|> HttpResponse::Ok().json(list_notes) }<|fim_middle|>#[get("/")] pub async fn index() -> HttpResponse { let list_notes = unsafe { NO...
code_fim
medium
{ "lang": "rust", "repo": "dhimasdewanto/learn_actix_web", "path": "/src/routes/index_route.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[get("/")] pub async fn index() -> HttpResponse { let list_notes = unsafe { NOTEREPO.get_notes() }; HttpResponse::Ok().json(list_notes) }<|fim_prefix|>// repo: dhimasdewanto/learn_actix_web path: /src/routes/index_route.rs use actix_web::{HttpResponse, get}; <|fim_middle|>use crate...
code_fim
easy
{ "lang": "rust", "repo": "dhimasdewanto/learn_actix_web", "path": "/src/routes/index_route.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = String::from_utf8(b)?; Ok(s) } /* func zip(in []byte) []byte { var b bytes.Buffer gz := gzip.NewWriter(&b) _, err := gz.Write(in) if err != nil { panic(err) } err = gz.Flush() if err != nil { panic(err) } err = gz.Close() if err != ni...
code_fim
hard
{ "lang": "rust", "repo": "carlosb1/projects-rust", "path": "/rust-ddd-example/src/signal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carlosb1/projects-rust path: /rust-ddd-example/src/signal.rs #![warn(rust_2018_idioms)] #![allow(dead_code)] use anyhow::Result; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Method, Request, Response, Server, StatusCode}; use std::net::SocketAddr; use std::str::FromStr; ...
code_fim
hard
{ "lang": "rust", "repo": "carlosb1/projects-rust", "path": "/rust-ddd-example/src/signal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonygod/rust-project-euler path: /euler54/src/poker/hand.rs use super::card::*; use super::hand_type::*; use std::fmt::{Display, Error, Formatter}; pub struct Hand { pub cards: Vec<Card>, } use itertools::Itertools; impl Display for Hand { fn fmt(&self, f: &mut Formatter) -> Result<(),...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler54/src/poker/hand.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl PartialEq for Hand { fn eq(&self, other: &Self) -> bool { self.hand_type().eq(&other.hand_type()) } } impl Hand { // 统计各种牌点出现的次数,例如:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 0, 0] // 表示五张牌里有3张10,1张J(11点),1张Q(12点) fn cards_stat(&self) -> Vec<u8> { // 对不同的牌计数 ...
code_fim
hard
{ "lang": "rust", "repo": "sonygod/rust-project-euler", "path": "/euler54/src/poker/hand.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nayeemrmn/dprint-plugin-typescript path: /src/swc/parse_swc_ast.rs use std::collections::{HashMap}; use std::path::Path; use std::rc::Rc; use swc_common::{ errors::{Handler, Emitter, DiagnosticBuilder}, FileName, comments::{Comment, SingleThreadedComments, SingleThreadedCommentsMap}, Sou...
code_fim
hard
{ "lang": "rust", "repo": "nayeemrmn/dprint-plugin-typescript", "path": "/src/swc/parse_swc_ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Emitter for EmptyEmitter { fn emit(&mut self, _: &DiagnosticBuilder<'_>) { // for now, we don't care about diagnostics so do nothing } fn should_show_explain(&self) -> bool { false } } fn format_diagnostic(error: &DiagnosticBuilder, file_text: &str) -> String { /...
code_fim
hard
{ "lang": "rust", "repo": "nayeemrmn/dprint-plugin-typescript", "path": "/src/swc/parse_swc_ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Load thoughts in memory (heap?) let thoughts = std::fs::read_to_string("thoughts.txt")?; // Add a new thought if let Some(i) = &args.thought { let mut file = OpenOptions::new() .append(true) .create(true) .open("thoughts.txt")?; write...
code_fim
medium
{ "lang": "rust", "repo": "wilhide/random_thoughts", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wilhide/random_thoughts path: /src/main.rs use std::io::{ Result, Write }; use std::fs::OpenOptions; use structopt::StructOpt; use rand::Rng; #[derive(Debug, StructOpt)] struct Cmd { #[structopt(short = "a", long = "add", help = "Add a thought", conflicts_with("random"))] thought: Optio...
code_fim
hard
{ "lang": "rust", "repo": "wilhide/random_thoughts", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn print_random(thoughts: &str) { let mut vec = Vec::new(); for thought in thoughts.lines() { vec.push(thought); } let mut rng = rand::thread_rng(); let n = rng.gen_range(0, vec.len()); println!("{}", vec[n]); } fn main() -> Result<()> { let args = Cmd::from_args(); ...
code_fim
medium
{ "lang": "rust", "repo": "wilhide/random_thoughts", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jackywathy/mipsy path: /crates/mipsy_interactive/src/interactive/commands/exit.rs use super::*; #[allow(unreachable_code)] pub(crate) fn exit_command() -> Command { command( "exit", vec!["ex", "quit", "q"], vec![]<|fim_suffix|> |_state, _label, _args| { ...
code_fim
medium
{ "lang": "rust", "repo": "Jackywathy/mipsy", "path": "/crates/mipsy_interactive/src/interactive/commands/exit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> |_state, _label, _args| { std::process::exit(0) } ) }<|fim_prefix|>// repo: Jackywathy/mipsy path: /crates/mipsy_interactive/src/interactive/commands/exit.rs use super::*; #[allow(unreachable_code)] pub(crate) fn exit_command() -> Command { command( "exit", ...
code_fim
medium
{ "lang": "rust", "repo": "Jackywathy/mipsy", "path": "/crates/mipsy_interactive/src/interactive/commands/exit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, vec![], "exit mipsy", "Immediately exits mipsy", |_state, _label, _args| { std::process::exit(0) } ) }<|fim_prefix|>// repo: Jackywathy/mipsy path: /crates/mipsy_interactive/src/interactive/commands/exit.rs use super::*; #[allow(unreachable_code)...
code_fim
medium
{ "lang": "rust", "repo": "Jackywathy/mipsy", "path": "/crates/mipsy_interactive/src/interactive/commands/exit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn JP_C(&mut self) { let c = self.get_c(); self.jp(c); } pub fn JP_NC(&mut self) { let c = self.get_c(); self.jp(!c); } fn jr(&mut self, pred: bool) { use std::mem; let n = unsafe { mem::transmute::<u8, i8>(self.mmu.read_byte(self.p...
code_fim
medium
{ "lang": "rust", "repo": "JJag/gb-rust", "path": "/src/gb/cpu/instrs/jp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JJag/gb-rust path: /src/gb/cpu/instrs/jp.rs use crate::gb::cpu::*; impl Cpu { fn jp(&mut self, pred: bool) { let nn = self.read_immediate_word(); if pred { self.pc = nn; } } pub fn JP_aHL(&mut self) { let hl = self.hl(); self.pc =...
code_fim
hard
{ "lang": "rust", "repo": "JJag/gb-rust", "path": "/src/gb/cpu/instrs/jp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone)] pub(super) struct TransactionHeader { pub(super) version: u8, pub(super) user_root: Option<(PageNumber, Checksum)>, pub(super) system_root: Option<(PageNumber, Checksum)>, pub(super) freed_root: Option<(PageNumber, Checksum)>, pub(super) transaction_id: TransactionId, ...
code_fim
hard
{ "lang": "rust", "repo": "cberner/redb", "path": "/src/tree_store/page_store/header.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cberner/redb path: /src/tree_store/page_store/header.rs freed table root checksum // 8 bytes: last committed transaction id // 4 bytes: number of full regions // 4 bytes: data pages in partial trailing region // 8 bytes: region tracker page number // 16 bytes: slot checksum // // Commit slot 1 (...
code_fim
hard
{ "lang": "rust", "repo": "cberner/redb", "path": "/src/tree_store/page_store/header.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(super) fn to_bytes(&self) -> [u8; TRANSACTION_SIZE] { let mut result = [0; TRANSACTION_SIZE]; result[VERSION_OFFSET] = self.version; if let Some((page, checksum)) = self.user_root { result[USER_ROOT_NON_NULL_OFFSET] = 1; result[USER_ROOT_PAGE_OFFSET....
code_fim
hard
{ "lang": "rust", "repo": "cberner/redb", "path": "/src/tree_store/page_store/header.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { panic!() } #[no_mangle] pub static _EXCEPTIONS: Exceptions = Exceptions { ..exceptions::DEFAULT_HANDLERS }; #[no_mangle] pub static _INTERRUPTS: Interrupts = Interrupts { ..interrupts::DEFAULT_HANDLERS };<|fim_prefix|>// repo: jamesmunns/bluepill path: /examples/panic.rs //! Wha...
code_fim
medium
{ "lang": "rust", "repo": "jamesmunns/bluepill", "path": "/examples/panic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamesmunns/bluepill path: /examples/panic.rs //! What happens when `panic!` is invoked? //! //! Find out with this app #![no_std] extern crate demopill; use demopill::exceptions::{self, Exceptions}; use demopill::interrupts::{self, Interrupts}; fn main() { panic!() } <|fim_suffix|>#[no_...
code_fim
medium
{ "lang": "rust", "repo": "jamesmunns/bluepill", "path": "/examples/panic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub static _EXCEPTIONS: Exceptions = Exceptions { ..exceptions::DEFAULT_HANDLERS }; #[no_mangle] pub static _INTERRUPTS: Interrupts = Interrupts { ..interrupts::DEFAULT_HANDLERS };<|fim_prefix|>// repo: jamesmunns/bluepill path: /examples/panic.rs //! What happens when `panic!` is i...
code_fim
medium
{ "lang": "rust", "repo": "jamesmunns/bluepill", "path": "/examples/panic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// An handle to a waiting thread: one the thread wait ends an event is sent pub struct Delay { signal: Option<mpsc::Sender<()>>, /// The duration of the delay pub duration: Duration, } impl Delay { /// Creates a `Delay` event that will be sent through the event `channel` after the secifi...
code_fim
hard
{ "lang": "rust", "repo": "garro95/pcp-rs", "path": "/src/event.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garro95/pcp-rs path: /src/event.rs use super::handle::Error; use super::map::{InboundMap, OutboundMap}; use super::state::{Alert, AtomicState}; use super::IpAddress; use crate::types::{ MapResponsePayload, OpCode, PacketOption, Parsable, PeerResponsePayload, ResponsePacketSlice, Response...
code_fim
hard
{ "lang": "rust", "repo": "garro95/pcp-rs", "path": "/src/event.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Delay { /// Creates a `Delay` event that will be sent through the event `channel` after the secified /// amount of `time` pub fn by<Ip: IpAddress>(time: Duration, id: usize, channel: mpsc::Sender<Event<Ip>>) -> Self { let (tx, rx) = mpsc::channel(); thread::spawn(move || {...
code_fim
hard
{ "lang": "rust", "repo": "garro95/pcp-rs", "path": "/src/event.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn run_intcode(h: &mut HashMap<i64, i64>) { let mut current_op_index: i64 = 0; let mut relative_base = 0; let mut first_input = true; while current_op_index < h.len() as i64 { let op = *h.get(&current_op_index).unwrap(); let mut op_digits: Vec<char> = op.to_string().chars...
code_fim
hard
{ "lang": "rust", "repo": "tylerXMD/advent_of_code_2019", "path": "/day9/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tylerXMD/advent_of_code_2019 path: /day9/part1/src/main.rs use std::fs::File; use std::io::Read; use std::collections::HashMap; #[derive(Debug)] enum ParameterMode { Position, Immediate, Relative } impl From<char> for ParameterMode { fn from(num: char) -> ParameterMode { ...
code_fim
hard
{ "lang": "rust", "repo": "tylerXMD/advent_of_code_2019", "path": "/day9/part1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if op_code == "01" { let first_value = get_value(&h, current_op_index+1, &param_first, relative_base); let second_value = get_value(&h, current_op_index+2, &param_second, relative_base); store_value(h, current_op_index+3, first_value+second_value, &param_third,...
code_fim
hard
{ "lang": "rust", "repo": "tylerXMD/advent_of_code_2019", "path": "/day9/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { let cases = vec![ ( vec![1, 0, -1, 0, -2, 2], 0, vec![vec![-1, 0, 0, 1], vec![-2, -1, 1, 2], vec![-2, 0, 0, 2]], ), ( vec![-3, -2, -1, 0, 0, 1, 2, 3], 0, vec![ vec![-3, -...
code_fim
hard
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/four_sum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CNife/leetcode path: /rust/finished/src/four_sum.rs use std::cmp::Ordering::*; use std::collections::HashSet; pub fn four_sum(mut nums: Vec<i32>, target: i32) -> Vec<Vec<i32>> { if nums.len() < 4 { return vec![]; } nums.sort_unstable(); <|fim_suffix|> let cases = vec![ ...
code_fim
hard
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/four_sum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinityb/webplayer path: /src/util/json.rs use serde; use serde_json; use std::error::Error; use std::io::{Read, Write}; use postgres::types::{FromSql, ToSql, IsNull, Type}; #[derive(Debug)] pub struct JsonDocument(String); impl JsonDocument { pub fn empty() -> JsonDocument { Jso...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/webplayer", "path": "/src/util/json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ::std::ops::Deref for JsonDocument { type Target = str; fn deref(&self) -> &str { &self.0 } } impl FromSql for JsonDocument { fn from_sql(ty: &Type, mut raw: &[u8]) -> Result<JsonDocument, Box<Error + Sync + Send>> { if let Type::Jsonb = *ty { ...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/webplayer", "path": "/src/util/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e used as an offset from the MRT base address in order to access the registers for the allocated channel. If all timer channels are running, CHAN = 0xF. See text above for more details."] #[inline(always)] pub fn chan(&self) -> CHAN_R { CHAN_R::new(((self.bits >> 4) & 0x0f) as u8) } }<...
code_fim
medium
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/mrt0/idle_ch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/mrt0/idle_ch.rs #[doc = "Reader of register IDLE_CH"] pub type R = crate::R<u32, super::IDLE_CH>; #[doc = "Reader of field `CHAN`"] pub type CHAN_R = crate::R<u8, u8>; <|fim_suffix|>e used as an offset from the MRT base address in order to access the registers for th...
code_fim
medium
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/mrt0/idle_ch.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_iter(input: impl Read) -> Fallible<impl Iterator<Item = Fallible<C2HLine>>> { let rdr = csv::ReaderBuilder::new() .flexible(true) .has_headers(false) .delimiter(b'\t') .from_reader(input); Ok(rdr.into_records().map(|result| -> Fallible<C2HLine> { let ...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/analysis-purgatory", "path": "/c2h-bug-finder/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_fix() { let input = "s 'foo' 'bar' 0 a 0 0 327 a 5572078638964173662 327 13 a 3360248271971874541 340 20 a 5572078638964173668 360 6 a 4799148352916656454 366 14 a 4799148352916656452 380 380 a 4183562578850463929 760 1 a 4183562578850463927 761 381 a 4799148352916656457 38...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/analysis-purgatory", "path": "/c2h-bug-finder/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelarmstrong/analysis-purgatory path: /c2h-bug-finder/src/main.rs <String> = env::args().collect(); let subcommand = argv.get(1).expect("Must have 2 arguments (find/fix and c2h file to check)"); let path = argv.get(2).expect("Must have 2 arguments (find/fix and c2h file to check)"); ...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/analysis-purgatory", "path": "/c2h-bug-finder/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vcvtqq2ps.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vcvtqq2ps_1() { run_t...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vcvtqq2ps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VCVTQQ2PS, operand1: Some(Direct(XMM3)), operand2: Some(Direct(XMM27)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K6), broadcast: None }, &[98, 145, 252, 142, 91, 219]...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vcvtqq2ps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VCVTQQ2PS, operand1: Some(Direct(XMM16)), operand2: Some(Direct(YMM23)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K1), broadcast: None }, &[98, 161, 252, 169, 91, 199...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vcvtqq2ps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samlet/pallet-fixtures path: /helpers/util/src/shipment.rs use frame_support::{ codec::{Decode, Encode}, decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure, sp_runtime::RuntimeDebug, // traits::EnsureOrigin, }; use fixed::types::U16F16; use cr...
code_fim
hard
{ "lang": "rust", "repo": "samlet/pallet-fixtures", "path": "/helpers/util/src/shipment.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] pub enum ReadingType { Humidity, Pressure, Shock, Tilt, Temperature, Vibration, } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] pub struct Reading<Moment> { pub device_id: DeviceId, pub reading_t...
code_fim
hard
{ "lang": "rust", "repo": "samlet/pallet-fixtures", "path": "/helpers/util/src/shipment.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut set3 = ValueSet::new(); assert!(set3.sadd(b"123".to_vec(), 100)); assert!(set3.sadd(b"456".to_vec(), 100)); assert!(set3.sadd(b"foo".to_vec(), 100)); assert_eq!(set.sinter(vec![&set2, &set3]), HashSet::from_iter(vec![ b"123".to_vec(), ...
code_fim
hard
{ "lang": "rust", "repo": "zhangf911/rsedis", "path": "/database/src/set.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut set = ValueSet::new(); assert!(set.sadd(b"123".to_vec(), 100)); assert!(set.sadd(b"456".to_vec(), 100)); assert!(set.sadd(b"789".to_vec(), 100)); let mut set2 = ValueSet::new(); assert!(set2.sadd(b"123".to_vec(), 100)); assert!(set2.sadd(b"4...
code_fim
hard
{ "lang": "rust", "repo": "zhangf911/rsedis", "path": "/database/src/set.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangf911/rsedis path: /database/src/set.rs use std::collections::VecMap; use std::collections::HashSet; use dbutil::usize_to_vec; use dbutil::vec_to_usize; use rand::thread_rng; use rand::distributions::{Sample, IndependentSample, Range}; #[derive(PartialEq, Debug, Clone)] pub enum ValueSet ...
code_fim
hard
{ "lang": "rust", "repo": "zhangf911/rsedis", "path": "/database/src/set.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let i = (c as usize) - 0x20; self.data(&font::ASCII[i]); self.data(&[0x00]); } fn print(&mut self, s: &str) { for c in s.bytes() { self.print_char(c); } } fn set_position(&mut self, x: u8, y: u8) { assert!(x <= 84); ass...
code_fim
hard
{ "lang": "rust", "repo": "dancek/pcd8544-hal", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dancek/pcd8544-hal path: /src/lib.rs #![deny(unsafe_code)] //#![deny(warnings)] #![no_std] #[macro_use(block)] extern crate nb; extern crate embedded_hal; // TODO: feature flag extern crate fpa; mod pcd8544_spi; mod pcd8544_gpio; mod font; pub mod demo; <|fim_suffix|>pub trait Pcd8544 { ...
code_fim
medium
{ "lang": "rust", "repo": "dancek/pcd8544-hal", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for c in s.bytes() { self.print_char(c); } } fn set_position(&mut self, x: u8, y: u8) { assert!(x <= 84); assert!(y < 6); self.command(0x40 + y); self.command(0x80 + x); } // note: data direction is vertical: [1 2 3 4 5 6] ...
code_fim
medium
{ "lang": "rust", "repo": "dancek/pcd8544-hal", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nathanfaucett/rs-executable_memory path: /benches/bench.rs #![feature(test)] extern crate executable_memory; extern crate test; use executable_memory::ExecutableMemory; use test::Bencher; use std::mem; #[bench] fn bench_native(b: &mut Bencher) { #[inline(never)] fn f() -> u32 { test:...
code_fim
medium
{ "lang": "rust", "repo": "nathanfaucett/rs-executable_memory", "path": "/benches/bench.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> memory[0] = 0xb8; memory[1] = 0xff; memory[2] = 0xff; memory[3] = 0xff; memory[4] = 0xff; memory[5] = 0xc3; let f: fn() -> u32 = unsafe { mem::transmute((&memory[0..6]).as_ptr()) }; b.iter(f); }<|fim_prefix|>// repo: nathanfaucett/rs-executable_memory path: /benches/bench.rs #![feature(...
code_fim
hard
{ "lang": "rust", "repo": "nathanfaucett/rs-executable_memory", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lse, _ => continue, } } else { return false; } } }<|fim_prefix|>// repo: ebsnet/blockchain path: /bin/invoice_generator/src/ask.rs use std::io::Read; pub fn ask(msg: &str) -> bool { let mut inp = [b'0']; let mut stdin = ::std::io::stdin...
code_fim
medium
{ "lang": "rust", "repo": "ebsnet/blockchain", "path": "/bin/invoice_generator/src/ask.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ebsnet/blockchain path: /bin/invoice_generator/src/ask.rs use std::io::Read; pub fn ask(msg: &str) -> bool { let mut inp = [b'0']; let mut stdin = ::std::io::<|fim_suffix|>lse, _ => continue, } } else { return false; } } }<|fim...
code_fim
hard
{ "lang": "rust", "repo": "ebsnet/blockchain", "path": "/bin/invoice_generator/src/ask.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eklavya/cryptopals-rs path: /src/lib.rs mod base64; mod bytes; mod eng; mod hex; #[cfg(test)] mod tests { use std::io::{BufRead, BufReader}; use std::{collections::HashSet, fs::File}; use crate::base64::B64; use crate::bytes::Bytes; use crate::eng::{char_freq_score, log_wei...
code_fim
hard
{ "lang": "rust", "repo": "eklavya/cryptopals-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn challenge7() { let content = B64(BufReader::new(File::open("resources/chal7").unwrap()) .lines() .map(|l| l.unwrap()) .collect::<String>()); let inp = content.to_bytes(); let cipher = Cipher::aes_128_ecb(); let key = b"...
code_fim
hard
{ "lang": "rust", "repo": "eklavya/cryptopals-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn guess_test() { let lines = Hex("0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f6b".into()); let content = lines.to_bytes(); assert_eq!( vec![ ...
code_fim
hard
{ "lang": "rust", "repo": "eklavya/cryptopals-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // write use array of char and length let hello2 = "Hello world!\n"; unsafe { libc::write(1, hello2.as_ptr() as *const _, hello2.len()); } 0 }<|fim_prefix|>// repo: hg2ecz/minimal-Rust-Linux path: /hello1/src/main.rs #![no_std] #![no_main] #[panic_handler] fn my_panic(_info: ...
code_fim
hard
{ "lang": "rust", "repo": "hg2ecz/minimal-Rust-Linux", "path": "/hello1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hg2ecz/minimal-Rust-Linux path: /hello1/src/main.rs #![no_std] #![no_main] #[panic_handler] fn my_panic(_info: &core::panic::PanicInfo) -> ! { loop {} } <|fim_suffix|> // write use array of char and length let hello2 = "Hello world!\n"; unsafe { libc::write(1, hello2.as_...
code_fim
hard
{ "lang": "rust", "repo": "hg2ecz/minimal-Rust-Linux", "path": "/hello1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sources = room .find(find::SOURCES) .into_iter() .filter(|source| { let has_construction_site = source .pos() .find_in_range(find::CONSTRUCTION_SITES, 1) .into_iter() .next() .is_som...
code_fim
hard
{ "lang": "rust", "repo": "snorrwe/xenos", "path": "/src/constructions/containers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snorrwe/xenos path: /src/constructions/containers.rs use super::geometry::*; use super::*; use screeps::{ constants::StructureType, find, objects::{HasPosition, Room, StructureProperties}, ReturnCode, }; <|fim_suffix|> let sources = room .find(find::SOURCES) ....
code_fim
hard
{ "lang": "rust", "repo": "snorrwe/xenos", "path": "/src/constructions/containers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(self) fn flag((input, bit_offset): (&[u8], usize)) -> IResult<(&[u8], usize), bool> { if input.is_empty() { return Err(nom::Err::Incomplete(Needed::new(1))); } let flag = flag_is_set(input[0], bit_offset); if bit_offset == 7 { return Ok(((&input[1..], 0), flag)); } ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/libwifi", "path": "/src/parsers/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/libwifi path: /src/parsers/mod.rs use nom::{IResult, Needed}; mod components; mod frame_types; pub use components::*; pub use frame_types::*; <|fim_suffix|> if bit == 0 { let mask = 1; (data & mask) > 0 } else { let mask = 1 << bit; (data & mask)...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/libwifi", "path": "/src/parsers/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let metric = sync::Arc::new(Some(Telemetry::default())); let mut res = Vec::new(); assert!(parse_statsd("a.b:12.1|g\nb_c:13.2|c", &mut res, metric)); assert_eq!(2, res.len()); assert_eq!(res[0].aggr_method, AggregationMethod::Set); assert_eq!(res[0].name, "...
code_fim
hard
{ "lang": "rust", "repo": "skade/cernan", "path": "/src/protocols/statsd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_metric_parse_invalid_no_value() { let metric = sync::Arc::new(Some(Telemetry::default())); let mut res = Vec::new(); assert!(!parse_statsd("foo:", &mut res, metric)); } #[test] fn test_metric_multiple() { let metric = sync::Arc::new(Some...
code_fim
hard
{ "lang": "rust", "repo": "skade/cernan", "path": "/src/protocols/statsd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: skade/cernan path: /src/protocols/statsd.rs use metric; use std::str::FromStr; use std::sync; use time; /// Valid message formats are: /// /// - `<str:metric_name>:<f64:value>|<str:type>` /// - `<str:metric_name>:<f64:value>|c|@<f64:sample_rate>` /// p /// Multiple metrics can be sent in a sing...
code_fim
hard
{ "lang": "rust", "repo": "skade/cernan", "path": "/src/protocols/statsd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-ral/src/imxrt106/peripherals/pwm.rs the PWM_X pin represents the "on" or "active" state. pub const POLX_1: u16 = 0b1; } } /// PWM_B Output Polarity pub mod POLB { /// Offset (9 bits) pub const offset: u16 = 9; ...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/imxrt-rs", "path": "/imxrt-ral/src/imxrt106/peripherals/pwm.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Capture Value 1 Cycle Register pub mod SMCVAL1CYC0 { /// CVAL1CYC pub mod CVAL1CYC { /// Offset (0 bits) pub const offset: u16 = 0; /// Mask (4 bits: 0b1111 << 0) pub const mask: u16 = 0b1111 << offset; /// Read-only values (empty) pub mod R {} ...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/imxrt-rs", "path": "/imxrt-ral/src/imxrt106/peripherals/pwm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// 0b0: Disable fractional cycle placement for PWM_B. pub const FRAC45_EN_0: u16 = 0b0; /// 0b1: Enable fractional cycle placement for PWM_B. pub const FRAC45_EN_1: u16 = 0b1; } } /// Fractional Delay Circuit Power Up pub mod FRAC_PU {...
code_fim
hard
{ "lang": "rust", "repo": "mitchmindtree/imxrt-rs", "path": "/imxrt-ral/src/imxrt106/peripherals/pwm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn delim(i: &str) -> IResult<&str, &str> { recognize(many0(one_of(", ")))(i) } // dairy, fish fn parse_allergens(i: &str) -> IResult<&str, Vec<&str>> { many1(delimited(delim, alpha1, delim))(i) } pub fn parse_food(i: &str) -> IResult<&str, (Vec<&str>, Vec<&str>)> { map( all_consuming...
code_fim
medium
{ "lang": "rust", "repo": "mike-barber/advent-of-code-2020-rust", "path": "/day21/src/parse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mike-barber/advent-of-code-2020-rust path: /day21/src/parse.rs use nom::{ bytes::complete::tag, character::complete::*, combinator::{all_consuming, map, recognize}, multi::*, sequence::*, IResult, }; // mxmxvkd kfcds sqjhc nhms (contains dairy, fish) // mxmxvkd kfcds sq...
code_fim
hard
{ "lang": "rust", "repo": "mike-barber/advent-of-code-2020-rust", "path": "/day21/src/parse.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn ingredients_correct() { assert_eq!( parse_ingredients("mxmxvkd kfcds sqjhc nhms"), Ok(("", vec!["mxmxvkd", "kfcds", "sqjhc", "nhms"])) ); } #[test] fn allergens_correc() { assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "mike-barber/advent-of-code-2020-rust", "path": "/day21/src/parse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, other: &Self, ) -> Ordering { self.partial_cmp(other).unwrap() } } impl Into<f64> for Voltage { fn into(self) -> f64 { self.to_volts() } }<|fim_prefix|>// repo: peku33/logicblocks path: /Controller/src/datatypes/voltage.rs use anyhow::{ensure, Error}...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/datatypes/voltage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peku33/logicblocks path: /Controller/src/datatypes/voltage.rs use anyhow::{ensure, Error}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; <|fim_suffix|> &self, other: &Self, ) -> Ordering { self.partial_cmp(other).unwrap() } } impl Into<f64> for Volt...
code_fim
hard
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/datatypes/voltage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Thibi2000/aoc2020 path: /src/day3.rs fn count_trees(map: &Vec<Vec<char>>, (a, b): (usize, usize)) -> i64 { <|fim_suffix|>pub fn solve(lines: Vec<String>) -> (i64, i64) { let slopes = vec![(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; let mut res: i64 = 1; let vec: Vec<Vec<char>> = lines .int...
code_fim
medium
{ "lang": "rust", "repo": "Thibi2000/aoc2020", "path": "/src/day3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn solve(lines: Vec<String>) -> (i64, i64) { let slopes = vec![(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; let mut res: i64 = 1; let vec: Vec<Vec<char>> = lines .into_iter() .map(|line| line.chars().collect()) .collect(); slopes .iter() .for_each(|slope| res *= count_trees(&vec, *s...
code_fim
medium
{ "lang": "rust", "repo": "Thibi2000/aoc2020", "path": "/src/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (bytes_opt, income) = match self { &mut SendingConsumeMethod(ref mut fut) => { let (income, outgo) = try_ready!(fut.poll()); drop(outgo); (None, income) } &mut ReceivingDeliverd(ref mut del) => { ...
code_fim
hard
{ "lang": "rust", "repo": "AtsukiTak/amqpr", "path": "/src/unsync/local_channel/subscribe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (local_ch, sub_stream) } struct ItemChecker { consumer_tag: String, expect: Expect, } enum Expect { ConsumeOk, Deliver, ContentHeader, ContentBody, } // {{{ impl of ItemChecker impl ItemChecker { fn check<'a, 'b>(&'a mut self, frame: &'b Frame) -> bool { let ne...
code_fim
hard
{ "lang": "rust", "repo": "AtsukiTak/amqpr", "path": "/src/unsync/local_channel/subscribe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AtsukiTak/amqpr path: /src/unsync/local_channel/subscribe.rs use futures::{Future, Stream, Poll, Async}; use ex_futures::sink::{SinkExt, UnsyncCloneable}; use ex_futures::stream::StreamExt; use amqpr_api::basic::consume::{start_consume_wait, ConsumeStarted}; use amqpr_api::basic::deliver::{rec...
code_fim
hard
{ "lang": "rust", "repo": "AtsukiTak/amqpr", "path": "/src/unsync/local_channel/subscribe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: a3213105/occlum path: /src/libos/src/vm/vm_area.rs use std::ops::{Deref, DerefMut}; use super::vm_perms::VMPerms; use super::vm_range::VMRange; use super::*; #[derive(Clone, Debug, Default)] pub struct VMArea { range: VMRange, perms: VMPerms, writeback_file: Option<(FileRef, usize)...
code_fim
hard
{ "lang": "rust", "repo": "a3213105/occlum", "path": "/src/libos/src/vm/vm_area.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // If the updates to the VMA needs to write back to a file, then the // file offset must be adjusted according to the new start address. if let Some((_, offset)) = self.writeback_file.as_mut() { if old_start < new_start { *offset += new_start - old_start...
code_fim
hard
{ "lang": "rust", "repo": "a3213105/occlum", "path": "/src/libos/src/vm/vm_area.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>n exiting Battery Backup Mode."] #[inline(always)] pub fn bbmodest(&self) -> BBMODEST_R { BBMODEST_R::new(((self.bits >> 16) & 0x01) != 0) } } impl W { #[doc = "Bits 0:1 - USB UTMI Linestate Detect Wakeup Flag(write one to clear). One or both of these bits will be set when the USB ...
code_fim
hard
{ "lang": "rust", "repo": "jonathanfisher/max32650-rs", "path": "/src/pwrseq/lppwst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonathanfisher/max32650-rs path: /src/pwrseq/lppwst.rs #[doc = "Reader of register LPPWST"] pub type R = crate::R<u32, super::LPPWST>; #[doc = "Writer for register LPPWST"] pub type W = crate::W<u32, super::LPPWST>; #[doc = "Register LPPWST `reset()`'s with value 0"] impl crate::ResetValue for s...
code_fim
hard
{ "lang": "rust", "repo": "jonathanfisher/max32650-rs", "path": "/src/pwrseq/lppwst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeff-hughes/sqlite_clone path: /src/main.rs use eyre::Result; use std::cell::RefCell; // use std::collections::HashMap; use std::rc::Rc; use std::{env, process::exit}; // use sqlite_clone::btree::{Btree, Record}; // use sqlite_clone::datatypes::{DataType, Value, VarInt}; use sqlite_clone::pager...
code_fim
hard
{ "lang": "rust", "repo": "jeff-hughes/sqlite_clone", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // println!("Tables:"); // for key in tables.keys() { // println!(" - {}", key); // } // println!("Indexes:"); // for key in indexes.keys() { // println!(" - {}", key); // } // // navigate an index // let podcasts_index = indexes.get("sqlite_autoindex_podca...
code_fim
hard
{ "lang": "rust", "repo": "jeff-hughes/sqlite_clone", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let index = Record::new( // vec![DataType::String(index_str.len())], // vec![Value::String(index_str)], // ); // let res = podcasts_index.get_index(index); // println!("{:?}", res); // // pull corresponding row from table // if let Some(rec) = res { // l...
code_fim
hard
{ "lang": "rust", "repo": "jeff-hughes/sqlite_clone", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v1 = if i < l - 2 { 0.5 * (control_points[i + 2] - p0) } else if self.closed { if i >= l - 1 { // last to second point 0.5 * (control_points[1] - p0) } else { // second last to first point ...
code_fim
hard
{ "lang": "rust", "repo": "hadashiA/unigeo", "path": "/src/spline.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hadashiA/unigeo path: /src/spline.rs use crate::vec3::Vec3; use std::cell::RefCell; fn cubic_hermite(p0: Vec3, p1: Vec3, v0: Vec3, v1: Vec3, t: f32) -> Vec3 { let c0 = 2.0 * p0 + -2.0 * p1 + v0 + v1; let c1 = -3.0 * p0 + 3.0 * p1 + -2.0 * v0 - v1; let c2 = v0; let c3 = p0; ...
code_fim
hard
{ "lang": "rust", "repo": "hadashiA/unigeo", "path": "/src/spline.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where Self: Sized, F: FnMut(B, Self::Item) -> B, { #[inline] fn ok<B, T>(mut f: impl FnMut(B, T) -> B) -> impl FnMut(B, T) -> Result<B, !> { move |acc, x| Ok(f(acc, x)) } self.try_rfold(accum, ok(f)).unwrap() } /// Searches for ...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libcore/iter/traits/double_ended.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libcore/iter/traits/double_ended.rs use crate::iter::LoopState; use crate::ops::Try; /// An iterator able to yield elements from both ends. /// /// Something that implements `DoubleEndedIterator` has one extra capability /// over something that implements [`Ite...
code_fim
hard
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libcore/iter/traits/double_ended.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EmbarkStudios/physx-rs path: /physx-sys/pxbind/tests/functions.rs struct Functions { cpp: String, rust: String, } fn gen_functions(which: &str) -> anyhow::Result<Functions> { let (ast, _) = pxbind::get_parsed_ast(format!("tests/data/functions/{which}"))?; let mut consumer = pxb...
code_fim
hard
{ "lang": "rust", "repo": "EmbarkStudios/physx-rs", "path": "/physx-sys/pxbind/tests/functions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Verifies we can collect free functions #[test] fn plain_functions() { let mo = gen_functions("functions.h").unwrap(); insta::assert_snapshot!(mo.cpp); insta::assert_snapshot!(mo.rust); }<|fim_prefix|>// repo: EmbarkStudios/physx-rs path: /physx-sys/pxbind/tests/functions.rs struct Functi...
code_fim
hard
{ "lang": "rust", "repo": "EmbarkStudios/physx-rs", "path": "/physx-sys/pxbind/tests/functions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }