text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: cytoo/cont path: /src/errors.rs use colored::Colorize; use std::path::Path; <|fim_suffix|>impl<'t> Errors<'t> { pub fn throw(err: Errors) { match err { Errors::FileNotFound(path) => { println!("{} `{}`", "no such file or directory".red(), path.display()) ...
code_fim
medium
{ "lang": "rust", "repo": "cytoo/cont", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'t> Errors<'t> { pub fn throw(err: Errors) { match err { Errors::FileNotFound(path) => { println!("{} `{}`", "no such file or directory".red(), path.display()) } } } }<|fim_prefix|>// repo: cytoo/cont path: /src/errors.rs use colored::C...
code_fim
medium
{ "lang": "rust", "repo": "cytoo/cont", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenziyi2018/py_sql path: /tests/bench_test.rs use py_sql::py_sql::PyRuntime; use py_sql::{RExprRuntime, StringConvert}; use rexpr::bencher::QPS; pub struct DriverType {} impl StringConvert for DriverType { fn convert(&self, index: usize) -> String { "?".to_string() } } //carg...
code_fim
hard
{ "lang": "rust", "repo": "chenziyi2018/py_sql", "path": "/tests/bench_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut serde_json::json!({"id":1,"order_by":["id","name"],"ids":[1,2,3],"name":"asdf","map":{"a":1},"create_time":"2020-23-23"}), &engine).unwrap(); println!("sql:{},arg:{:?}", sql, arg); let total = 10000; let now = std::time::Instant::now(); for _ in 0..tot...
code_fim
hard
{ "lang": "rust", "repo": "chenziyi2018/py_sql", "path": "/tests/bench_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clojure-rs/ClojureRS path: /src/error_message.rs use crate::type_tag::TypeTag; use crate::value::Value; use std::error::Error; use std::fmt; pub fn type_mismatch(expected: TypeTag, got: &Value) -> Value { Value::Condition(format!( "Type mismatch; Expected instance of {}, Recieved t...
code_fim
hard
{ "lang": "rust", "repo": "clojure-rs/ClojureRS", "path": "/src/error_message.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn index_out_of_bounds(ind: usize, count: usize) -> Value { Value::Condition(format!( "Index out of bounds: Index ({}), Length: ({})", ind, count )) } pub fn index_cannot_be_negative(ind: usize) -> Value { Value::Condition(format!("Index cannot be negative; Index ({})", in...
code_fim
hard
{ "lang": "rust", "repo": "clojure-rs/ClojureRS", "path": "/src/error_message.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// We currently don't have any type that represents an interface type name, so we pub struct Cast<'a>(pub &'a str); pub fn cast(expected: Cast, found: TypeTag) -> Value { Value::Condition(format!("Cannot cast {} to {}", found, expected.0)) } /// For one off errors pub fn custom(message: &str) -> Valu...
code_fim
hard
{ "lang": "rust", "repo": "clojure-rs/ClojureRS", "path": "/src/error_message.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aethertap/audio path: /audio-device/src/pulse/main_loop.rs use crate::pulse::Context; use pulse_sys as pulse; use std::ffi::CStr; use std::ptr; /// A Pulseaudio main loop. /// /// See [MainLoop::new]. pub struct MainLoop { handle: ptr::NonNull<pulse::pa_mainloop>, api: ptr::NonNull<puls...
code_fim
medium
{ "lang": "rust", "repo": "aethertap/audio", "path": "/audio-device/src/pulse/main_loop.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Context { handle: ptr::NonNull::new_unchecked(handle), callbacks: Vec::new(), } } } } impl Drop for MainLoop { fn drop(&mut self) { unsafe { pulse::pa_mainloop_free(self.handle.as_mut()); } } }<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "aethertap/audio", "path": "/audio-device/src/pulse/main_loop.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let app = Route::new().at("/:action", index).with(ServerSession::new( CookieConfig::default(), RedisStorage::new(ConnectionManager::new(client).await.unwrap()), )); let mut client = TestClient::default(); client.call(&app, 0).await; client.a...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/redis_storage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> client.call(&app, 0).await; client.assert_cookies(vec![]); client.call(&app, 1).await; client.call(&app, 2).await; client.call(&app, 7).await; client.call(&app, 6).await; client.call(&app, 3).await; client.call(&app, 4).await; client...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/redis_storage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happysalada/poem path: /poem/src/session/redis_storage.rs use std::{collections::BTreeMap, time::Duration}; use redis::{aio::ConnectionLike, AsyncCommands, Cmd}; use crate::{error::InternalServerError, session::session_storage::SessionStorage, Result}; /// A session storage using redis. #[cfg...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/redis_storage.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhyuditjain/aoc2020 path: /src/day4.rs use aoc_runner_derive::{aoc, aoc_generator}; use std::str::FromStr; #[aoc_generator(day4)] pub fn input_generator(input: &str) -> Vec<Passport> { input .split("\n\n") .map(|x| x.replace("\n", " ")) .map(|x| parse_passport(x.as_...
code_fim
hard
{ "lang": "rust", "repo": "abhyuditjain/aoc2020", "path": "/src/day4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_hcl_valid(&self) -> bool { if let Some(color) = &self.hcl { return regex::Regex::new("^#[0-9a-f]{6}$") .unwrap() .is_match(color.as_str()); } false } fn is_ecl_valid(&self) -> bool { if let Some(color) = &self.e...
code_fim
hard
{ "lang": "rust", "repo": "abhyuditjain/aoc2020", "path": "/src/day4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KuldeepSinh/lc3_vm path: /src/hardware/instructions/and.rs use super::sign_extend; use crate::hardware::register::condition_flag; use crate::hardware::register::Registers; <|fim_suffix|> if imm_flag == 1 { let imm5 = sign_extend(instr & 0x1F, 5); registers.update(dr, register...
code_fim
hard
{ "lang": "rust", "repo": "KuldeepSinh/lc3_vm", "path": "/src/hardware/instructions/and.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if imm_flag == 1 { let imm5 = sign_extend(instr & 0x1F, 5); registers.update(dr, registers.get(sr1) & imm5); } else { let sr2 = instr & 0x7; registers.update(dr, registers.get(sr1) & registers.get(sr2)); } condition_flag::update_r_cond_register(dr, registers...
code_fim
hard
{ "lang": "rust", "repo": "KuldeepSinh/lc3_vm", "path": "/src/hardware/instructions/and.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl<'a, T: CtoSafe> Place<T> for CtoVecPlaceBack<'a, T> { #[inline(always)] fn pointer(&mut self) -> *mut T { unsafe { self.vec.as_mut_ptr().offset(self.vec.len as isize) } } } impl<'a, T: CtoSafe> InPlace<T> for CtoVecPlaceBack<'a, T> { type Owner = &'a mut T; #[inline(always)] unsafe...
code_fim
hard
{ "lang": "rust", "repo": "lemonrock/nvml", "path": "/workspace/nvml/src/cto_pool/collections/CtoVecPlaceBack.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lemonrock/nvml path: /workspace/nvml/src/cto_pool/collections/CtoVecPlaceBack.rs // This file is part of nvml. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/nvml/master/COPYRIGHT. ...
code_fim
hard
{ "lang": "rust", "repo": "lemonrock/nvml", "path": "/workspace/nvml/src/cto_pool/collections/CtoVecPlaceBack.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zachdelano/sentinel path: /backend/src/db/models.rs use super::schema::camera; // use diesel::deserialize::{self, FromSql}; // use diesel::backend::Backend; // use diesel::sql_types::*; <|fim_suffix|>#[derive(Queryable, Serialize)] pub struct Camera { pub id: Option<i32>, pub name: Str...
code_fim
medium
{ "lang": "rust", "repo": "zachdelano/sentinel", "path": "/backend/src/db/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Queryable, Serialize)] pub struct Camera { pub id: Option<i32>, pub name: String, pub address: String, }<|fim_prefix|>// repo: zachdelano/sentinel path: /backend/src/db/models.rs use super::schema::camera; // use diesel::deserialize::{self, FromSql}; // use diesel::backend::Backend;...
code_fim
medium
{ "lang": "rust", "repo": "zachdelano/sentinel", "path": "/backend/src/db/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let vec = pub_key.from_hex(); if vec.is_err() { warn!("Failed reading public key for '{}' in line {} of peers file '{}'", peername, i, fname); continue; } match ecdh::PublicKey::from_vec(&vec.unwrap()) { Err(()) => warn!("Failed re...
code_fim
hard
{ "lang": "rust", "repo": "manuels/intercom", "path": "/src/parse_peers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manuels/intercom path: /src/parse_peers.rs #![allow(dead_code)] use std::fs::File; use std::io::Result; use std::io::{BufReader,BufRead}; use std::collections::HashMap; use rustc_serialize::hex::FromHex; use ecdh; <|fim_suffix|>pub fn parse_peers_file(fname: String) -> Result<HashMap<String,...
code_fim
medium
{ "lang": "rust", "repo": "manuels/intercom", "path": "/src/parse_peers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (i, line) in BufReader::new(file).lines().enumerate() { match line { Err(e) => return Err(e), Ok(line) => { let fields:Vec<&str> = line.split(" ").collect(); if fields.len() != 2 { warn!("Failed reading line {} of peers file '{}'", i, fname); continue; } let (peern...
code_fim
medium
{ "lang": "rust", "repo": "manuels/intercom", "path": "/src/parse_peers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let num = item as u32; let a_num = 'a' as u32; let a_num_cap = 'A' as u32; let offset = if item >= 'a' && item <= 'z' { a_num } else { a_num_cap - 26 }; return num - offset + 1; }<|fim_prefix|>// repo: alanmrvl/aoc path: /2022/03/part1/src/main.rs use std::co...
code_fim
hard
{ "lang": "rust", "repo": "alanmrvl/aoc", "path": "/2022/03/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alanmrvl/aoc path: /2022/03/part1/src/main.rs use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader, Lines}; use std::path::Path; fn main() { let path: &Path = Path::new("input"); let file: File = File::open(path).unwrap(); let lines: Lines<BufReader<Fil...
code_fim
medium
{ "lang": "rust", "repo": "alanmrvl/aoc", "path": "/2022/03/part1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KULeuven-COSIC/SCALE-MAMBA path: /WebAssembly/scale/src/io.rs // Copyright (c) 2021, COSIC-KU Leuven, Kasteelpark Arenberg 10, bus 2452, B-3001 Leuven-Heverlee, Belgium. // Copyright (c) 2021, Cosmian Tech SAS, 53-55 rue La Boétie, Paris, France. use super::*; <|fim_suffix|>#[inline(always)] p...
code_fim
hard
{ "lang": "rust", "repo": "KULeuven-COSIC/SCALE-MAMBA", "path": "/WebAssembly/scale/src/io.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/* This file contains all the IO class commands * * Input/Output for i64, SecretModp and ClearModp are * defined in their respective classes * */ #[inline(always)] pub fn open_channel(channel: i64) -> i64 { unsafe { __open_channel(channel) } } #[inline(always)] pub fn close_channel(channel: i64...
code_fim
medium
{ "lang": "rust", "repo": "KULeuven-COSIC/SCALE-MAMBA", "path": "/WebAssembly/scale/src/io.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvirkkunen/eager-const path: /serde-rust/src/lib.rs use serde::{ser, Serialize}; use std::fmt; #[derive(Debug)] pub struct Error(String); impl ser::Error for Error { fn custom<T: fmt::Display>(msg: T) -> Self { Error(msg.to_string()) } } impl fmt::Display for Error { fn fm...
code_fim
hard
{ "lang": "rust", "repo": "mvirkkunen/eager-const", "path": "/serde-rust/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple> { self.output += "("; Ok(self) } fn serialize_tuple_struct( self, name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleStruct> { self.output += name; s...
code_fim
hard
{ "lang": "rust", "repo": "mvirkkunen/eager-const", "path": "/serde-rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where T: ?Sized + Serialize, { value.serialize(&mut **self)?; self.output += ","; Ok(()) } fn end(self) -> Result<()> { self.output += ")"; Ok(()) } } impl<'a> ser::SerializeMap for &'a mut Serializer { type Ok = (); type Error ...
code_fim
hard
{ "lang": "rust", "repo": "mvirkkunen/eager-const", "path": "/serde-rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *y = *y + *z; *k = 24; println!("Mutable ptr: {}", *y); println!("Mutable ptr: {}", *k); println!("Immutable ptr: {}", *z); } println!("Origin value: {}", x); }<|fim_prefix|>// repo: vpetrigo/rust_book path: /unsafe/src/main.rs fn main() { let mut x = ...
code_fim
hard
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/unsafe/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vpetrigo/rust_book path: /unsafe/src/main.rs fn main() { let mut x = 10; let y = &mut x as *mut i32; let k = &mut x as *mut i32; let z = &x as *const i32; <|fim_suffix|> *y = *y + *z; *k = 24; println!("Mutable ptr: {}", *y); println!("Mutable ptr:...
code_fim
hard
{ "lang": "rust", "repo": "vpetrigo/rust_book", "path": "/unsafe/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { console::print_game(&game); console::print_messages(&mut messages); let input = console::read_line("command: "); match Command::parse(&input) { Ok(command) => { match command { Command::Deal => { ...
code_fim
hard
{ "lang": "rust", "repo": "renatovassao/solitaire-rs", "path": "/src/menu/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match Command::parse(&input) { Ok(command) => { match command { Command::Deal => { game.deal(); messages.push(String::from("Dealt cards.")); }, Command::Help => {...
code_fim
hard
{ "lang": "rust", "repo": "renatovassao/solitaire-rs", "path": "/src/menu/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: renatovassao/solitaire-rs path: /src/menu/mod.rs mod console; mod parser; use parser::{Command, MoveSpec}; use crate::game::{Game, DealSize}; pub fn start() { let mut deal_size: Option<DealSize> = None; while deal_size.is_none() { console::print_main_menu(); let input...
code_fim
hard
{ "lang": "rust", "repo": "renatovassao/solitaire-rs", "path": "/src/menu/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let c: i32 = match c.trim().parse() { Ok(num) => num, Err(_) => 0 }; // To computate the max of two numbers the cmp::max() function is used. // Since it only takes in 2 numbers at a time, first, we find the // max between a and b, and then compare that against c. ...
code_fim
hard
{ "lang": "rust", "repo": "silvia-odwyer/beginner-rust-examples", "path": "/Algorithmic/sort_three_ints/sort_three_ints.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // To computate the max of two numbers the cmp::max() function is used. // Since it only takes in 2 numbers at a time, first, we find the // max between a and b, and then compare that against c. let max = cmp::max(cmp::max(a, b), c); // The cmp package also provides a min() function w...
code_fim
medium
{ "lang": "rust", "repo": "silvia-odwyer/beginner-rust-examples", "path": "/Algorithmic/sort_three_ints/sort_three_ints.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silvia-odwyer/beginner-rust-examples path: /Algorithmic/sort_three_ints/sort_three_ints.rs use std::io; use std::cmp; fn main() { let mut a = String::new(); let mut b = String::new(); let mut c = String::new(); println!("Enter a value for a."); io::stdin().read_line(&mu...
code_fim
hard
{ "lang": "rust", "repo": "silvia-odwyer/beginner-rust-examples", "path": "/Algorithmic/sort_three_ints/sort_three_ints.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// This is our service handler. It receives a Request, routes on its /// path, and returns a Future of a Response. async fn dispatcher(req: Request<Body>) -> Result<Response<Body>, hyper::Error> { match req.method() { &Method::GET => { let client = Client::new(); let n...
code_fim
hard
{ "lang": "rust", "repo": "nappa85/arpav", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nappa85/arpav path: /src/main.rs // #![deny(warnings)] // #![deny(missing_docs)] //! # arpav //! //! Arpav client use std::env; use hyper::{Body, Client, Method, Request, Response, Server, StatusCode}; use hyper::client::connect::Connect; use hyper::service::{make_service_fn, service_fn}; use...
code_fim
hard
{ "lang": "rust", "repo": "nappa85/arpav", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> constr.exit_set(&ast.pos)?; Ok((constr, env)) } Node::With { resource, expr, .. } => { constr.new_set(true); constr.add( "with", &Expected::try_from(resource)?, &Expected::new(&resource.pos, &Ex...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/mamba", "path": "/src/check/constrain/generate/resources.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/mamba path: /src/check/constrain/generate/resources.rs use crate::check::constrain::constraint::builder::ConstrBuilder; use crate::check::constrain::constraint::expected::Expect::{ExpressionAny, Type}; use crate::check::constrain::constraint::expected::Expected; use crate::check::cons...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/mamba", "path": "/src/check/constrain/generate/resources.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> format!("{:02x}", result) } pub fn xor_hex_strings(hex1: &str, hex2: &str) -> String { let buf1 = hex_to_bytes(hex1); let buf2 = hex_to_bytes(hex2); let bytes = xor(&buf1[..], &buf2[..]); bytes_to_hex(&bytes) } pub fn repeating_key_xor(buf: &[u8], key: &[u8]) -> Vec<u8> { let m...
code_fim
hard
{ "lang": "rust", "repo": "DaraGboyega/cryptofriends-rust", "path": "/src/utils/bytes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DaraGboyega/cryptofriends-rust path: /src/utils/bytes.rs use base64::{decode, encode}; use itertools::Itertools; use rand::{OsRng, Rng, RngCore}; pub fn xor(buf1: &[u8], buf2: &[u8]) -> Vec<u8> { assert_eq!(buf1.len(), buf2.len()); let mut bytes: Vec<u8> = Vec::with_capacity(buf1.len())...
code_fim
hard
{ "lang": "rust", "repo": "DaraGboyega/cryptofriends-rust", "path": "/src/utils/bytes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> None } fn parse_input(st: &String) -> Vec<Vec<char>> { st .lines() .map(|l| l.chars().collect()) .collect() } fn main() { let mut contents = String::new(); File::open("../data/10.txt") .expect("File not found") .read_to_string(&mut contents) ...
code_fim
hard
{ "lang": "rust", "repo": "Flourish3/AdventOfCode", "path": "/2021/rust/src/day10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Flourish3/AdventOfCode path: /2021/rust/src/day10.rs //#![feature(test)] //extern crate test; use std::fs::File; use std::io::prelude::*; use std::collections::HashMap; fn print_error(found: char, expected: char) -> () { println!("Found {0}, exptected {1}", found, expected); } fn get_aut...
code_fim
hard
{ "lang": "rust", "repo": "Flourish3/AdventOfCode", "path": "/2021/rust/src/day10.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ror, PushTaskError, PushWrokerError, RunWorkerError, CookieGenerateError, }<|fim_prefix|>// repo: SKTT1Ryze/rust-pool path: /src/error.rs //! Error Handler for Rust Thread Pool /// E<|fim_middle|>rror Type pub enum Error { PoolCreationEr
code_fim
easy
{ "lang": "rust", "repo": "SKTT1Ryze/rust-pool", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> RunWorkerError, CookieGenerateError, }<|fim_prefix|>// repo: SKTT1Ryze/rust-pool path: /src/error.rs //! Error Handler for Rust Thread Pool /// Error Type pub enum Error { PoolCreationEr<|fim_middle|>ror, PushTaskError, PushWrokerError,
code_fim
easy
{ "lang": "rust", "repo": "SKTT1Ryze/rust-pool", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SKTT1Ryze/rust-pool path: /src/error.rs //! Error Handler for Rust Thread Pool /// Error Type pub enum Error { PoolCreationEr<|fim_suffix|> RunWorkerError, CookieGenerateError, }<|fim_middle|>ror, PushTaskError, PushWrokerError,
code_fim
easy
{ "lang": "rust", "repo": "SKTT1Ryze/rust-pool", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allan-simon/rust-xmpp-server-stream path: /src/xmpp/server_stream.rs extern crate xml; use server_handler::XmppServerHandler; use std::io::net::tcp::TcpStream; use std::io::BufferedStream; use read_str::ReadString; use xmpp_socket::Tcp; use ns; /// Represent a server side XMPP stream pub str...
code_fim
hard
{ "lang": "rust", "repo": "allan-simon/rust-xmpp-server-stream", "path": "/src/xmpp/server_stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // handle </stream:stream> from client Ok(xml::EndTag(xml::EndTag { name: ref name, ns: Some(ref ns), .. })) if name.as_slice() == "stream" && ns.as_slice() == ns::STREAMS => { println!("In: Stream ...
code_fim
hard
{ "lang": "rust", "repo": "allan-simon/rust-xmpp-server-stream", "path": "/src/xmpp/server_stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crutcha/tcptop path: /src/cli.rs use crate::table; use tui::layout::{Constraint, Layout, Direction, Rect}; use tui::style::{Color, Modifier, Style}; use tui::widgets::{Row, Table, Block, Borders, Chart, Dataset, Axis, GraphType, Text, Paragraph}; use tui::terminal::Frame; use tui::backend::Backe...
code_fim
hard
{ "lang": "rust", "repo": "crutcha/tcptop", "path": "/src/cli.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let detail_entry = &self.overview.sockets[self.overview.state.selected().unwrap()]; let detail_history = &self.overview.history.get(&detail_entry.inode).unwrap(); let chart_bounds_recv = determine_min_max_values(&detail_history.recv_bps); let chart_bounds_send = determine_m...
code_fim
hard
{ "lang": "rust", "repo": "crutcha/tcptop", "path": "/src/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dianamin/dilithium path: /src/packing.rs use ::params::{ L, K, N, Q, OMEGA, SEEDBYTES, CRHBYTES, POLETA_SIZE_PACKED, POLT0_SIZE_PACKED, POLT1_SIZE_PACKED, POLZ_SIZE_PACKED, PK_SIZE_PACKED, SK_SIZE_PACKED, SIG_SIZE_PACKED }; use ::poly::{ self, Poly }; use ::polyvec::{ PolyVecL, P...
code_fim
hard
{ "lang": "rust", "repo": "dianamin/dilithium", "path": "/src/packing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn unpack( sk: &[u8; SK_SIZE_PACKED], rho: &mut [u8; SEEDBYTES], key: &mut [u8; SEEDBYTES], tr: &mut [u8; CRHBYTES], s1: &mut PolyVecL, s2: &mut PolyVecK, t0: &mut PolyVecK ) { let (rho_bytes, key_bytes, tr_bytes, s1s_bytes, s2s_by...
code_fim
hard
{ "lang": "rust", "repo": "dianamin/dilithium", "path": "/src/packing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn pack(sign: &mut [u8; SIG_SIZE_PACKED], z: &PolyVecL, h: &PolyVecK,c: &Poly) { let (zs_bytes, h_bytes, c_bytes) = mut_array_refs!( sign, POLZ_SIZE_PACKED * L, OMEGA + K, N / 8 + 8 ); for i in...
code_fim
hard
{ "lang": "rust", "repo": "dianamin/dilithium", "path": "/src/packing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w4tson/advent-of-code-2018 path: /rust-solutions/src/day08/mod.rs use std::fmt::Display; use std::fmt::Formatter; use std::fmt::Error; pub mod parse; #[derive(Debug, Clone)] pub struct Node { children: Vec<Node>, metadata: Vec<i32> } impl Display for Node { fn fmt(&self, f: &mut F...
code_fim
hard
{ "lang": "rust", "repo": "w4tson/advent-of-code-2018", "path": "/rust-solutions/src/day08/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test() { let input = "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2"; let node : Node = input.parse().unwrap(); assert_that!(node.metadata_sum()).is_equal_to(138); assert_that!(node.value()).is_equal_to(66); } #[test] fn part1and2() { let inpu...
code_fim
hard
{ "lang": "rust", "repo": "w4tson/advent-of-code-2018", "path": "/rust-solutions/src/day08/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> note.pitch += 7; iface.write(&note)?; } }<|fim_prefix|>// repo: jpittis/libnote path: /midi/examples/fifths.rs use std::io; fn main() -> io::Result<()> { let mut ifa<|fim_middle|>ce = midi::open_file("/dev/midi1")?; let mut note = midi::Note::zero(); loop { iface.r...
code_fim
medium
{ "lang": "rust", "repo": "jpittis/libnote", "path": "/midi/examples/fifths.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jpittis/libnote path: /midi/examples/fifths.rs use std::io; fn main() -> io::Result<()> { let mut iface = midi::open_file("/dev/midi1")?; let mut note = midi<|fim_suffix|> note.pitch += 7; iface.write(&note)?; } }<|fim_middle|>::Note::zero(); loop { iface.r...
code_fim
medium
{ "lang": "rust", "repo": "jpittis/libnote", "path": "/midi/examples/fifths.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32f3/src/stm32f302/usb/daddr.rs #[doc = "Reader of register DADDR"] pub type R = crate::R<u32, super::DADDR>; #[doc = "Writer for register DADDR"] pub type W = crate::W<u32, super::DADDR>; #[doc = "Register DADDR `reset()`'s with value 0"] impl crate::R...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f302/usb/daddr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OAkyildiz/oscc-joystick-commander path: /oscc/firmware/brake/kia_soul_petrol/tests/property/src/tests.rs #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] include!(concat!(env!("O...
code_fim
hard
{ "lang": "rust", "repo": "OAkyildiz/oscc-joystick-commander", "path": "/oscc/firmware/brake/kia_soul_petrol/tests/property/src/tests.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> check_for_incoming_message(); TestResult::from_bool(g_brake_control_state.commanded_pedal_position == brake_command_msg.pedal_command as f32) } } #[test] fn check_accel_pos_validity() { QuickCheck::new() .tests(1000) .quickcheck(prop_...
code_fim
hard
{ "lang": "rust", "repo": "OAkyildiz/oscc-joystick-commander", "path": "/oscc/firmware/brake/kia_soul_petrol/tests/property/src/tests.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn check_process_enable_command() { QuickCheck::new() .tests(25) .quickcheck(prop_process_enable_command as fn(oscc_brake_enable_s) -> TestResult) } /// the brake firmware should set the control state as disabled /// upon reciept of a valid disable brake message telling it to ...
code_fim
hard
{ "lang": "rust", "repo": "OAkyildiz/oscc-joystick-commander", "path": "/oscc/firmware/brake/kia_soul_petrol/tests/property/src/tests.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: konradsz/adventofcode2019 path: /day10/src/main.rs use std::fs::File; use std::io::{self, prelude::*, BufReader}; #[derive(PartialEq)] enum Field { Empty, Asteroid, } #[derive(Debug, Copy, Clone, PartialEq)] struct Data { offset_x: i32, offset_y: i32, angle: f64, } fn calc...
code_fim
hard
{ "lang": "rust", "repo": "konradsz/adventofcode2019", "path": "/day10/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn part_1() -> io::Result<()> { let file = File::open("input")?; let reader = BufReader::new(file); let mut map = Vec::new(); for line in reader.lines() { let mut row = Vec::new(); for c in line.unwrap().chars() { match c { '.' => row.push(Fiel...
code_fim
hard
{ "lang": "rust", "repo": "konradsz/adventofcode2019", "path": "/day10/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/collection/src/recommendations.rs use std::collections::{HashMap, HashSet}; use std::future::Future; use futures::future::try_join_all; use itertools::Itertools; use segment::data_types::vectors::{NamedVector, VectorElementType, DEFAULT_VECTOR_NAME}; use segment::types:...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/src/recommendations.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for (collection_name, reference_vectors) in collections_names.into_iter().zip(all_reference_vectors) { for rec in reference_vectors { all_vectors_records_map.insert((collection_name, rec.id), rec); } } let mut searches = Vec::with_capacity(request_batch...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/src/recommendations.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let request_from_collection = request.lookup_from.as_ref().map(|x| &x.collection); for &point_id in &reference_vectors_ids { if !all_vectors_records_map.contains_key(&(request_from_collection, point_id)) { return Err(CollectionError::PointNotFound { ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/src/recommendations.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isabella232/basalt path: /src/policy/analysis/globals_scope.rs //! Analyze the lexical scopes for a module and generate a tree. //! //! Once the scope tree is built we can compute globals by doing a //! depth-first traversal and performing a union of all the locals //! for each scope into a set,...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/basalt", "path": "/src/policy/analysis/globals_scope.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if options.filter_keywords { for word in KEYWORDS { locals.insert(JsWord::from(word)); } } if options.filter_global_functions { for word in GLOBAL_FUNCTIONS { locals.insert(JsWord::from(word)); } ...
code_fim
hard
{ "lang": "rust", "repo": "isabella232/basalt", "path": "/src/policy/analysis/globals_scope.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: albfan/rust-tree-sitter-ast-viewer path: /build.rs extern crate cc; use std::env; use std::path::PathBuf; use std::fs; fn main() { let mut config = cc::Build::new(); let root_path: PathBuf = ["vendor", "tree-sitter"].iter().collect(); <|fim_suffix|> let paths = fs::read_dir("fi...
code_fim
hard
{ "lang": "rust", "repo": "albfan/rust-tree-sitter-ast-viewer", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for path in paths { let mut parser_dir: PathBuf = ["fixtures", path.unwrap().file_name().to_str().unwrap(), "src"].iter().collect(); if parser_dir.join("parser.c").exists() { config.file(parser_dir.join("parser.c")); } if parser_dir.join("scanner.c").exists()...
code_fim
hard
{ "lang": "rust", "repo": "albfan/rust-tree-sitter-ast-viewer", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.0.next().unwrap() } fn read<T: std::str::FromStr>(&mut self) -> T { self.get().parse().ok().unwrap() } } #[test] fn test_scanner() { let src = r"14 atcoder rust 1 1 2 3 4 5 "; let mut sc = Scanner::from_str(src); assert_eq!(sc.read::<usize>(), ...
code_fim
medium
{ "lang": "rust", "repo": "cunitac/ac-snippet", "path": "/src/scanner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_scanner() { let src = r"14 atcoder rust 1 1 2 3 4 5 "; let mut sc = Scanner::from_str(src); assert_eq!(sc.read::<usize>(), 14usize); assert_eq!(sc.read::<String>(), "atcoder"); assert_eq!(sc.get(), "rust"); assert_eq!((0..6).map(|_| sc.read::<u32>())...
code_fim
hard
{ "lang": "rust", "repo": "cunitac/ac-snippet", "path": "/src/scanner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cunitac/ac-snippet path: /src/scanner.rs #![allow(dead_code)] use cargo_snippet::snippet; #[snippet("Scanner")] struct Scanner<'a>(std::str::SplitWhitespace<'a>); #[snippet("Scanner")] impl<'a> Scanner<'a> { fn from_str(src: &str) -> Scanner { <|fim_suffix|> let src = r"14 atcoder ...
code_fim
hard
{ "lang": "rust", "repo": "cunitac/ac-snippet", "path": "/src/scanner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>&char) -> u32 { for i in 0..15 { if MAP[i] == *c { return i as u32; } } panic!("Not excepted char: {}", c) }<|fim_prefix|>// repo: fnknzzz/poker-solver path: /poker-solver/src/level.rs const MAP: [char; 15] = [ '3', '4', '5', '6', '7', '8', '9', <|fim_middle|>'T', 'J', 'Q', 'K', 'A'...
code_fim
medium
{ "lang": "rust", "repo": "fnknzzz/poker-solver", "path": "/poker-solver/src/level.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fnknzzz/poker-solver path: /poker-solver/src/level.rs const MAP: [char; 15] = [ '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', '2', 'B', 'C', ]; pub fn get_level(c: <|fim_suffix|>eturn i as u32; } } panic!("Not excepted char: {}", c) }<|fim_middle|>&char) -> u32 { for i...
code_fim
medium
{ "lang": "rust", "repo": "fnknzzz/poker-solver", "path": "/poker-solver/src/level.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let captures = local_lambda_helper.captures(); let arg_locations: Vec<_> = args.iter().map(|arg| arg.1).collect(); let ir_function = IrFunction { id: ir_lambda_id, arg_count: arg_locations.len() + captures.len(), arg_loc...
code_fim
hard
{ "lang": "rust", "repo": "jaffa4/siko-1", "path": "/crates/siko_name_resolver/src/expr_processor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaffa4/siko-1 path: /crates/siko_name_resolver/src/expr_processor.rs module, environment, ir_program, errors, lambda_helper, type_arg_resolver, loop_helper.clone(), ); ...
code_fim
hard
{ "lang": "rust", "repo": "jaffa4/siko-1", "path": "/crates/siko_name_resolver/src/expr_processor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ert_with(|| Vec::new()); let binding_ref = case_environment .get_ref(&binding.0) .expect("Binding not found in env"); if let NamedRef::ExprValue(_, pattern_id) = binding_...
code_fim
hard
{ "lang": "rust", "repo": "jaffa4/siko-1", "path": "/crates/siko_name_resolver/src/expr_processor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maximg/rust-thrift path: /src/protocol/binary_protocol/mod.rs use protocol; use protocol::{ MessageType, Protocol, Type }; use transport::Transport; use std::num::FromPrimitive; static BINARY_PROTOCOL_VERSION_1: u16 = 0x8001; #[deriving(Copy)] pub struct BinaryProtocol; impl BinaryProtocol {...
code_fim
hard
{ "lang": "rust", "repo": "maximg/rust-thrift", "path": "/src/protocol/binary_protocol/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn read_i16(&self, transport: &mut Transport) -> i16 { transport.read_be_i16().unwrap() } fn read_i32(&self, transport: &mut Transport) -> i32 { transport.read_be_i32().unwrap() } fn read_i64(&self, transport: &mut Transport) -> i64 { transport.read_be_i64().unwrap() } fn read...
code_fim
hard
{ "lang": "rust", "repo": "maximg/rust-thrift", "path": "/src/protocol/binary_protocol/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn read_field_begin(&self, transport: &mut Transport) -> (String, Type, i16) { let field_type = self.read_type(transport); let field_id = match field_type { protocol::Type::TStop => 0, _ => self.read_i16(transport), }; (String::from_str(""), field_type, field_id) } fn re...
code_fim
hard
{ "lang": "rust", "repo": "maximg/rust-thrift", "path": "/src/protocol/binary_protocol/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sieut/SueQL path: /src/exec/expr/tests.rs use bincode; use data_type::DataType; use super::Expr; use nom_sql; use tuple::TupleDesc; use test_utils::{setup, teardown}; use rel::Rel; #[test] fn test_col_helpers() { let mut db_state = setup("test_col_helpers"); let rel = Rel::new( ...
code_fim
hard
{ "lang": "rust", "repo": "sieut/SueQL", "path": "/src/exec/expr/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn test_query_output( query: &str, desc: Option<TupleDesc>, input: &Vec<u8>, expect_ty: DataType, expect_out: Vec<u8>, ) { let mut db_state = setup(query); let rel = Rel::new( query, desc.unwrap_or(TupleDesc::new(vec![DataType::Char], vec!["dummy"])), &m...
code_fim
hard
{ "lang": "rust", "repo": "sieut/SueQL", "path": "/src/exec/expr/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PENGUINLIONG/Writus path: /src/api/mod.rs pub mod index; pub use self::index::Index; #[cfg(test)] mod test_common; <|fim_suffix|>// Reexport APIs. pub use self::comment::CommentApi; pub use self::metadata::MetadataApi; pub use self::post::PostApi; pub use self::resource::ResourceApi;<|fim_mi...
code_fim
medium
{ "lang": "rust", "repo": "PENGUINLIONG/Writus", "path": "/src/api/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Reexport APIs. pub use self::comment::CommentApi; pub use self::metadata::MetadataApi; pub use self::post::PostApi; pub use self::resource::ResourceApi;<|fim_prefix|>// repo: PENGUINLIONG/Writus path: /src/api/mod.rs pub mod index; pub use self::index::Index; <|fim_middle|>#[cfg(test)] mod test_com...
code_fim
medium
{ "lang": "rust", "repo": "PENGUINLIONG/Writus", "path": "/src/api/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PENGUINLIONG/Writus path: /src/api/mod.rs pub mod index; pub use self::index::Index; <|fim_suffix|>// Reexport APIs. pub use self::comment::CommentApi; pub use self::metadata::MetadataApi; pub use self::post::PostApi; pub use self::resource::ResourceApi;<|fim_middle|>#[cfg(test)] mod test_com...
code_fim
medium
{ "lang": "rust", "repo": "PENGUINLIONG/Writus", "path": "/src/api/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern fn inc_num_ptr(num: &mut uint) -> uint { *num += 1; *num } #[no_mangle] pub extern fn inc_float_ptr(num: &mut f64) -> f64 { *num += 1.0; *num } #[no_mangle] pub extern fn get_pair() -> Pair { Pair { foo: 42, bar: 10, } } #[no_mangle] pub e...
code_fim
hard
{ "lang": "rust", "repo": "ealasu/SwiftRust", "path": "/Rust/objcrust.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ealasu/SwiftRust path: /Rust/objcrust.rs #![crate_type = "staticlib"] extern crate native; extern crate libc; extern crate collections; use std::collections::hashmap::HashMap; use libc::c_char; use std::comm::{channel, Sender}; use std::iter; use std::rt; use std::rt::unwind::try; use std::rt...
code_fim
hard
{ "lang": "rust", "repo": "ealasu/SwiftRust", "path": "/Rust/objcrust.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (tx, rx) = channel(); tx.send(200i); spawn(proc() { let t = rx.recv(); println!("Got {} from main thread", t); fail!() }); // Testing exception handling and reporting fail!(); } pub struct Pair { foo: uint, bar: uint, } pub struct Complex ...
code_fim
hard
{ "lang": "rust", "repo": "ealasu/SwiftRust", "path": "/Rust/objcrust.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for event in event_pump.poll_iter() { match event { Event::Quit{..} | Event::KeyDown{ keycode: Some(Keycode::Escape), .. } => { break 'main }, _ => {} } } i += 1; if...
code_fim
hard
{ "lang": "rust", "repo": "zhmu/rs-c64emu", "path": "/src/bin/c64-emu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhmu/rs-c64emu path: /src/bin/c64-emu.rs use std::process; extern crate sdl2; use sdl2::pixels; use sdl2::rect::Rect; use sdl2::pixels::Color; use sdl2::event::Event; use sdl2::keyboard::Keycode; //use sdl2::gfx::primitives::DrawRenderer; //extern crate c64; use ::c64::c64; fn load_roms(memo...
code_fim
hard
{ "lang": "rust", "repo": "zhmu/rs-c64emu", "path": "/src/bin/c64-emu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> i += 1; if i == 1000 { canvas.clear(); for y in 0..25 { for x in 0..40 { let n = memory.read_u8(0x400 + (y * 40 + x)); for j in 0..8 { let ch = memory.read_u8(0xd000 as u16 + (n as u16 *...
code_fim
hard
{ "lang": "rust", "repo": "zhmu/rs-c64emu", "path": "/src/bin/c64-emu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eomain/gbx path: /gb-ld/src/format.rs extern crate byteorder; use std::io; use std::io::Seek; use std::io::Write; use std::fmt; use std::fmt::Display; use byteorder::{LittleEndian, WriteBytesExt}; const CART_INFO_ADDR: u16 = 0x100; // opcode for nop instruction const NOP: u8 = 0x00; // opcod...
code_fim
hard
{ "lang": "rust", "repo": "eomain/gbx", "path": "/gb-ld/src/format.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use std::fs::File; use crate::format::*; #[test] fn cart_info() { let ctype = CartType::ROM; let variant = ConsoleVariant::Other; let start = 0x100; let info = CartInfo::new(ctype, variant, start); let cart = Cart::new...
code_fim
hard
{ "lang": "rust", "repo": "eomain/gbx", "path": "/gb-ld/src/format.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aleksander/xux path: /xux/src/proto/message_mapdata.rs use std::fmt; use crate::proto::serialization::*; use crate::Result; pub struct MapData { pub pktid: i32, pub off: u16, pub len: u16, pub buf: Vec<u8>, } impl MapData { pub const ID: u8 = 5; pub fn new (pktid: i32,...
code_fim
medium
{ "lang": "rust", "repo": "aleksander/xux", "path": "/xux/src/proto/message_mapdata.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Debug for MapData { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MAPDATA pktid:{} offset:{} len:{} buf:[..{}]", self.pktid, self.off, self.len, self.buf.len()) } }<|fim_prefix|>// repo: aleksander/xux path: /xux/src/proto/message_mapdata.rs use std::fmt; use...
code_fim
hard
{ "lang": "rust", "repo": "aleksander/xux", "path": "/xux/src/proto/message_mapdata.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CS410-510Rust-Password-Manager-CLI/CS510-password-manager- path: /src/generic/errors.rs // Contains Error Classes for use through the app #![allow(clippy::result_unit_err)] use thiserror::Error; #[derive(Error, Debug, PartialEq)] pub enum PasswordStoreError<'a> { #[error("{0}: Password Stor...
code_fim
hard
{ "lang": "rust", "repo": "CS410-510Rust-Password-Manager-CLI/CS510-password-manager-", "path": "/src/generic/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }