text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>pub type AvgBalMap = HashMap<String, Balances>; impl AverageBalance { pub fn new(file_path: &str) -> Self { let mut avg_bal: AvgBalMap = HashMap::new(); let reader = read_file(file_path); for (line_num, lines) in reader.lines().enumerate().skip(1) { let line = extra...
code_fim
medium
{ "lang": "rust", "repo": "tarunjais28/FunctionalCoding", "path": "/src/stamp_ftp/reader/avg_bal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarunjais28/FunctionalCoding path: /src/stamp_ftp/reader/avg_bal.rs use super::*; #[derive(Debug, PartialEq)] pub struct Balances { pub bal: f64, pub rate: f64, } <|fim_suffix|>pub type AvgBalMap = HashMap<String, Balances>; impl AverageBalance { pub fn new(file_path: &str) -> Self...
code_fim
medium
{ "lang": "rust", "repo": "tarunjais28/FunctionalCoding", "path": "/src/stamp_ftp/reader/avg_bal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryan1729/rote path: /libs/platform_layer/libs/editor_thread/src/editor_thread.rs use std::sync::mpsc::{channel, Sender, Receiver}; use std::thread::JoinHandle; use macros::u; use platform_types::{BufferName, Cmd, EditorAPI, Input, LoadBufferViewsResult, View}; use wimp_types::{BufferInfo, Buffe...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/rote", "path": "/libs/platform_layer/libs/editor_thread/src/editor_thread.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match result.and_then(|b| std::fs::write(&path, b.data.chars) .map_err(|e| e.to_string()) ) { Ok(_) => { let _hope_that_gets_there = proxy...
code_fim
hard
{ "lang": "rust", "repo": "Ryan1729/rote", "path": "/libs/platform_layer/libs/editor_thread/src/editor_thread.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Set a new key for the one or both of the initiator-egress and responder-egress symmetric ciphers. /// /// # Errors /// /// Will result in `Error::State` if not in transport mode. #[must_use] pub fn rekey_manually(&mut self, initiator: Option<&[u8]>, responder: Option<&[u8]>...
code_fim
hard
{ "lang": "rust", "repo": "kcchu/snow", "path": "/src/session.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> /// Transition the session into transport mode. This can only be done once the handshake /// has finished. /// /// Consumes the previous state, and returns the new transport state object, thereby freeing /// any material only used during the handshake phase. /// /// # Errors ...
code_fim
hard
{ "lang": "rust", "repo": "kcchu/snow", "path": "/src/session.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kcchu/snow path: /src/session.rs ically perform handshaking implied by the Noise pattern string in the future. /// /// [`Session::read_message`]: struct.Session.html#method.read_message /// [`Session::write_message`]: struct.Session.html#method.write_message /// // TODO: check up on memory usa...
code_fim
hard
{ "lang": "rust", "repo": "kcchu/snow", "path": "/src/session.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nagisa/math.rs path: /src/asin.rs use core::f64; use core::f64::consts::FRAC_PI_2; use utils::{AsBits, Bits}; use copysign::copysign; use utils::Float; fn r(i: f64) -> f64 { const P0: f64 = 1.66666666666666657415E-01; const P1: f64 = -3.25565818622400915405E-01; const P2: f64 = 2....
code_fim
hard
{ "lang": "rust", "repo": "nagisa/math.rs", "path": "/src/asin.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if !i.is_finite() || i > 1.0 { f64::NAN } else if i == 0.0 { i } else if i.abs() == 1.0 { copysign(FRAC_PI_2, i) } else if i.abs() < 0.5 { if i.as_bits().get_exponent() < -26 { return i; } i + i * r(i * i) } else { let...
code_fim
hard
{ "lang": "rust", "repo": "nagisa/math.rs", "path": "/src/asin.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Request for ConfigureRequest { const CATEGORY: Category = Category(0x13); fn to_bytes(&self, buffer: &mut [u8], offset: usize) -> Result<usize> { // TODO: Allow configuration buffer[offset] = 0; Ok(1) } } pub struct ConfigureResponse(pub(crate) Status); impl Res...
code_fim
medium
{ "lang": "rust", "repo": "therealprof/probe-rs", "path": "/probe/daplink/src/commands/swd/configure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(ConfigureResponse(Status::from_byte(buffer[offset])?)) } }<|fim_prefix|>// repo: therealprof/probe-rs path: /probe/daplink/src/commands/swd/configure.rs use crate::commands::{ Response, Category, Request, Result, Status, }; pub struct ConfigureRequest; impl Request fo...
code_fim
medium
{ "lang": "rust", "repo": "therealprof/probe-rs", "path": "/probe/daplink/src/commands/swd/configure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therealprof/probe-rs path: /probe/daplink/src/commands/swd/configure.rs use crate::commands::{ Response, Category, Request, Result, Status, }; pub struct ConfigureRequest; impl Request for ConfigureRequest { const CATEGORY: Category = Category(0x13); fn to_bytes(&s...
code_fim
medium
{ "lang": "rust", "repo": "therealprof/probe-rs", "path": "/probe/daplink/src/commands/swd/configure.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut handles = vec![]; for i in 0..50 { let mut bot = IntProgram::new(input, vec![]); bot.inputs.push(i); let mut send = send.clone(); let rec = rec.remove(0); let mut idle_count = 0; let handle = std::thread::spawn(move || loop { le...
code_fim
hard
{ "lang": "rust", "repo": "mich101mich/aoc-2019", "path": "/src/days/day_23.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mich101mich/aoc-2019 path: /src/days/day_23.rs use crate::utils::*; use std::sync::{ atomic::{AtomicU8, Ordering::SeqCst}, mpsc, Arc, }; #[allow(unused)] pub fn run() { #[allow(unused_variables)] let input = include_str!("../input/23.txt"); let mut rec = vec![]; let mu...
code_fim
hard
{ "lang": "rust", "repo": "mich101mich/aoc-2019", "path": "/src/days/day_23.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: papertigers/nladm path: /src/config.rs use failure::Error; use serde::Deserialize; use std::env; use std::net::Ipv4Addr; use std::path::PathBuf; #[derive(Debug, Deserialize)] pub struct Configuration { pub server: Ipv4Addr, pub port: u16, pub token: String, } fn get_config() -> Opt...
code_fim
hard
{ "lang": "rust", "repo": "papertigers/nladm", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn configure_token(config: Option<&Configuration>) -> Result<String, Error> { if let Ok(token) = env::var("NANOLEAF_TOKEN") { return Ok(token.parse()?); } if let Some(config) = config { return Ok(config.token.clone()); } Err(failure::err_msg( "server token ...
code_fim
hard
{ "lang": "rust", "repo": "papertigers/nladm", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn uv_read(&mut self, buf: &mut [u8]) -> UvResult<uint> { let _m = self.fire_homing_missile(); self.stream.read(buf) } pub fn uv_write(&mut self, buf: &[u8]) -> UvResult<()> { let _m = self.fire_homing_missile(); self.stream.write(buf) } pub fn set...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/librustuv/src/tty.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: servo/green-rs path: /librustuv/src/tty.rs // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apac...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/librustuv/src/tty.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl Reader for Tty { fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { self.uv_read(buf).map_err(|e| e.to_io_error()) } } impl Writer for Tty { fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { self.uv_write(buf).map_err(|e| e.to_io_error()) } } impl Drop...
code_fim
hard
{ "lang": "rust", "repo": "servo/green-rs", "path": "/librustuv/src/tty.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/redis-async-rs path: /src/client/connect.rs /* * Copyright 2017-2018 Ben Ashford * * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license * <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your * opt...
code_fim
medium
{ "lang": "rust", "repo": "Atul9/redis-async-rs", "path": "/src/client/connect.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub type RespConnection = Framed<TcpStream, resp::RespCodec>; /// Connect to a Redis server and return a Future that resolves to a /// `RespConnection` for reading and writing asynchronously. /// /// Each `RespConnection` implements both `Sink` and `Stream` and read and /// writes `RESP` objects. /// ///...
code_fim
medium
{ "lang": "rust", "repo": "Atul9/redis-async-rs", "path": "/src/client/connect.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use tokio_tcp::TcpStream; use resp; pub type RespConnection = Framed<TcpStream, resp::RespCodec>; /// Connect to a Redis server and return a Future that resolves to a /// `RespConnection` for reading and writing asynchronously. /// /// Each `RespConnection` implements both `Sink` and `Stream` and read ...
code_fim
medium
{ "lang": "rust", "repo": "Atul9/redis-async-rs", "path": "/src/client/connect.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ame = "fact_pred"] pub pred: String, #[column_name = "fact_val"] pub value: String, }<|fim_prefix|>// repo: BlueSpaceCanary/rustbucket path: /src/models.rs use super::schema::*; #[derive(Queryable)] pub struct Factoid { pub id: i32, pub key: S<|fim_middle|>tring, pub pred: String...
code_fim
medium
{ "lang": "rust", "repo": "BlueSpaceCanary/rustbucket", "path": "/src/models.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BlueSpaceCanary/rustbucket path: /src/models.rs use super::schema::*; #[derive(Queryable)] pub struct Factoid { pub id: i32, pub key: S<|fim_suffix|>in"] pub struct NewFactoid { #[column_name = "fact_key"] pub key: String, #[column_name = "fact_pred"] pub pred: String, ...
code_fim
medium
{ "lang": "rust", "repo": "BlueSpaceCanary/rustbucket", "path": "/src/models.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hindenbug/rtstc path: /src/parser.rs use std::slice::Iter; #[derive(Debug, PartialEq)] pub enum Node { Program { body: Vec<Node> }, CallExpression { name: String, params: Vec<Node> }, StringLiteral { value: String }, NumberLiteral { value: String }, } fn walk( token: &::tok...
code_fim
hard
{ "lang": "rust", "repo": "hindenbug/rtstc", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( parse(&tokens), Ok(Node::Program { body: vec![ Node::CallExpression { name: "add".to_string(), params: vec![ Node::NumberLiteral { ...
code_fim
hard
{ "lang": "rust", "repo": "hindenbug/rtstc", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let mut poll1 = Box::pin(channel.receive()); let mut poll2 = Box::pin(channel.receive()); let mut poll3 = Box::pin(channel.receive()); let mut poll4 = Box::pin(channel.receive()); let mut ...
code_fim
hard
{ "lang": "rust", "repo": "Matthias247/futures-intrusive", "path": "/tests/mpmc_channel.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Matthias247/futures-intrusive path: /tests/mpmc_channel.rs drop_counter, } } fn id(&self) -> usize { let guard = self.inner.lock().unwrap(); guard.id } fn strong_count(&self) -> usize { std::sync::Arc::strong_count(&self.inner) } } impl Dro...
code_fim
hard
{ "lang": "rust", "repo": "Matthias247/futures-intrusive", "path": "/tests/mpmc_channel.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Matthias247/futures-intrusive path: /tests/mpmc_channel.rs assert!(send_fut4.as_mut().poll(cx).is_pending()); assert!(send_fut5.as_mut().poll(cx).is_pending()); let recv_fut6 = channel.receive(); let recv_fut7 = channel.receive(); ...
code_fim
hard
{ "lang": "rust", "repo": "Matthias247/futures-intrusive", "path": "/tests/mpmc_channel.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windlessStorm/AdventOfCode2019 path: /src/day5.rs use std::fs::File; use std::io::prelude::Read; use crate::day2::computer; pub fn day5() { let fname = "D:\\aoc2019\\src\\inputs\\day5.txt"; // let fname = "D:\\aoc2019\\src\\inputs\\test.txt"; let mut f = File::open(fname).expect("U...
code_fim
hard
{ "lang": "rust", "repo": "windlessStorm/AdventOfCode2019", "path": "/src/day5.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Part 2 input_mut = input.to_vec(); stdin_buf.push(5); ip = 0; rbase = 0; let (exitcode, out) = computer(&mut input_mut, &mut stdin_buf, &mut Vec::new(), &mut ip, &mut rbase); if exitcode != 1{ panic!("Exit code: {} !! Something went wrong!!", exitcode); } l...
code_fim
hard
{ "lang": "rust", "repo": "windlessStorm/AdventOfCode2019", "path": "/src/day5.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut lower: HashMap<String, u32> = HashMap::new(); let mut upper: HashSet<String> = HashSet::new(); let mut mapping: HashMap<String, Vec<String>> = HashMap::new(); for x in input.into_iter() { let l: Vec<_> = x[0].split(|c| c == '(' || c == ')').collect(); let u: Vec<_>...
code_fim
hard
{ "lang": "rust", "repo": "lazear/adventofcode2017", "path": "/aoc7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v: Vec<String> = u.into_iter().map(|s| { let s: String = s.into(); upper.insert(s.clone()); s }).collect(); mapping.insert(base, v); } let keys: HashSet<String> = lower.keys().cloned().collect(); let base: Vec<String> = keys.diffe...
code_fim
hard
{ "lang": "rust", "repo": "lazear/adventofcode2017", "path": "/aoc7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lazear/adventofcode2017 path: /aoc7/src/main.rs use std::io::{BufRead,BufReader}; use std::fs::File; use std::collections::{HashSet, HashMap}; fn tree(base: &str, roots: &HashMap<String, Vec<String>>, weights: &HashMap<String, u32>) -> u32 { let mut ret: u32 = 0; if let Some(root) = wei...
code_fim
hard
{ "lang": "rust", "repo": "lazear/adventofcode2017", "path": "/aoc7/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mingun/serde-gff path: /src/ser/value.rs //! Содержит реализацию типажа `Serialize` для сериализации типа `Value` use serde::ser::{Serialize, SerializeMap, Serializer}; use crate::Label; use crate::value::Value; <|fim_suffix|>impl Serialize for Value { #[inline] fn serialize<S>(&self, ser...
code_fim
medium
{ "lang": "rust", "repo": "Mingun/serde-gff", "path": "/src/ser/value.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Serialize for Value { #[inline] fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { use self::Value::*; match *self { Byte(val) => serializer.serialize_u8(val), Char(val) => serializer.serialize_i8(val), Word(val) ...
code_fim
medium
{ "lang": "rust", "repo": "Mingun/serde-gff", "path": "/src/ser/value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomc1998/rs-proc-gen-experiment path: /src/renderer/frame_sets.rs //! A collection of consts that represent animations in sprite sheets. // See test.yaml asset file for human walk animation loading pub const FS_HUMAN_WALK_DOWN : u<|fim_suffix|>_HUMAN_ATTACK_DOWN : usize = 8; pub const FS_HU...
code_fim
hard
{ "lang": "rust", "repo": "tomc1998/rs-proc-gen-experiment", "path": "/src/renderer/frame_sets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>DOWN : usize = 4; pub const FS_HUMAN_IDLE_UP : usize = 5; pub const FS_HUMAN_IDLE_RIGHT : usize = 6; pub const FS_HUMAN_IDLE_LEFT : usize = 7; pub const FS_HUMAN_ATTACK_DOWN : usize = 8; pub const FS_HUMAN_ATTACK_UP : usize = 9; pub const FS_HUMAN_ATTACK_RIGHT : usize = 10; pub const FS_H...
code_fim
medium
{ "lang": "rust", "repo": "tomc1998/rs-proc-gen-experiment", "path": "/src/renderer/frame_sets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ocstl/advent-of-code-2016 path: /src/bin/day8.rs const INPUT_PATH: &str = "inputs/day8.txt"; #[derive(Debug, Clone, Copy)] enum Instruction { Rect(usize, usize), RotateColumn(usize, usize), RotateRow(usize, usize), } impl From<&str> for Instruction { fn from(input: &str) -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "ocstl/advent-of-code-2016", "path": "/src/bin/day8.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl std::iter::FromIterator<Instruction> for LittleScreen { fn from_iter<I: IntoIterator<Item = Instruction>>(iter: I) -> Self { let mut screen = LittleScreen::new(); for instruction in iter { screen.apply_instruction(instruction); } screen } } impl s...
code_fim
hard
{ "lang": "rust", "repo": "ocstl/advent-of-code-2016", "path": "/src/bin/day8.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn lock<'a, A: Arch>(&'a self, kernel: Pin<&'a Kernel<A>>) -> PrinterGuard<'a, A> { PrinterGuard { kernel, _guard: Some(self.0.lock()), } } pub fn without_lock<'a, A: Arch>(&'a self, kernel: Pin<&'a Kernel<A>>) -> PrinterGuard<'a, A> { Print...
code_fim
hard
{ "lang": "rust", "repo": "Gabriel4256/rv6-benchmark-backup", "path": "/kernel-rs/src/console.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gabriel4256/rv6-benchmark-backup path: /kernel-rs/src/console.rs //! Console input and output, to the uart. Reads are line at a time. //! //! Implements special input characters: //! * newline -- end of line //! * control-h -- backspace //! * control-u -- kill line //! * control-d -- end of file...
code_fim
hard
{ "lang": "rust", "repo": "Gabriel4256/rv6-benchmark-backup", "path": "/kernel-rs/src/console.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // end-of-file if cin == ctrl('D') { if n < target { // Save ^D for next time, to make sure // caller gets a 0-byte result. guard.r = guard.r.wrapping_sub(1) } break; ...
code_fim
hard
{ "lang": "rust", "repo": "Gabriel4256/rv6-benchmark-backup", "path": "/kernel-rs/src/console.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MessageExchange for Background { fn pull(&mut self) -> u32 { let mut count = self.exchange.pull(); for message in self.exchange.get_messages().iter() { match message { ChannelMessage::Render(context) => { let base = context.layout()....
code_fim
hard
{ "lang": "rust", "repo": "BruceBrown/rust-minesweeper", "path": "/src/sprites/background.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BruceBrown/rust-minesweeper path: /src/sprites/background.rs use crate::sprites::Rect; use crate::sprites::{ChannelMessage, ChannelWiring, Exchange, MessageExchange}; use crate::sprites::{Error, Renderer, RendererContext, Sprite}; // Background sprite is pretty simple pub struct Background { ...
code_fim
hard
{ "lang": "rust", "repo": "BruceBrown/rust-minesweeper", "path": "/src/sprites/background.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let base = context.layout().options.level(); let name = format!("bg_{}", base); let image = context.load(&name)?; let w = context.layout().width(); let h = context.layout().height(); let rect = Rect::new(0, 0, w, h); context.render_image(&image, None...
code_fim
hard
{ "lang": "rust", "repo": "BruceBrown/rust-minesweeper", "path": "/src/sprites/background.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let json_string = "[]".to_string(); let json = JsonValue::from_string(json_string).unwrap(); let empty_arr: Vec<JsonValue> = vec!(); match json { JsonValue::JsonArray(empty_arr) => {}, // ok _ => panic!("Expected JsonValue::JsonArray([])") } } #[test] fn arr_a...
code_fim
hard
{ "lang": "rust", "repo": "augustt198/json-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> display_wrapper(self, f) } } fn display_wrapper(json: &JsonValue, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { json.fmt(f) } impl JsonValue { pub fn from_string(s: String) -> Result<JsonValue, JsonError> { let mut lexer = Lexer::new(s); let mut parser = try...
code_fim
hard
{ "lang": "rust", "repo": "augustt198/json-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: augustt198/json-rs path: /src/lib.rs #![feature(core, collections)] use std::fmt; use std::collections::HashMap; use std::str::FromStr; use std::fmt::Debug; // scanning // TODO add line/column tracking #[derive(Debug)] pub struct JsonError { pub msg: String } impl JsonError { fn new(...
code_fim
hard
{ "lang": "rust", "repo": "augustt198/json-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { demo: false, fractal_clock: false, settings: false, inspection: false, memory: false, resize: false, color_test: false, } } fn checkboxes(&mut self, ui: &mut Ui) { let Self { ...
code_fim
hard
{ "lang": "rust", "repo": "slyedoc/egui", "path": "/egui/src/demos/demo_windows.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> settings: false, inspection: false, memory: false, resize: false, color_test: false, } } fn checkboxes(&mut self, ui: &mut Ui) { let Self { demo, fractal_clock, settings, i...
code_fim
hard
{ "lang": "rust", "repo": "slyedoc/egui", "path": "/egui/src/demos/demo_windows.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slyedoc/egui path: /egui/src/demos/demo_windows.rs use crate::{ app, demos::{self, Demo}, CtxRef, Resize, ScrollArea, Ui, Window, }; // ---------------------------------------------------------------------------- /// Link to show a specific part of the demo app. #[derive(Copy, Clon...
code_fim
hard
{ "lang": "rust", "repo": "slyedoc/egui", "path": "/egui/src/demos/demo_windows.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(intersect) = intersect_opt { match intersect.object { &Object::Light(ref l) => { // Paint the light with its diffuse color pixel = l.light_material().diffuse_intensity; }, &Object::Surface(ref s) => { ...
code_fim
hard
{ "lang": "rust", "repo": "Robzz/RustRaytracer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pixel = color; } } } } } } } else { pixel = scene.background(); } pixel } fn correct_gamma(p: &Rgb<f64>) -> Rgb<f64> { const A: f64 = 0.0...
code_fim
hard
{ "lang": "rust", "repo": "Robzz/RustRaytracer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Robzz/RustRaytracer path: /src/main.rs #![feature(plugin)] #![plugin(docopt_macros)] extern crate docopt; extern crate image; extern crate nalgebra; extern crate num_traits; extern crate rand; extern crate rustc_serialize; extern crate rust_raytracer; use image::*; use num_traits::*; use nalge...
code_fim
hard
{ "lang": "rust", "repo": "Robzz/RustRaytracer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anandijain/sipoxide path: /src/lines.rs extern crate csv; extern crate serde; extern crate serde_derive; extern crate serde_json; use std::fmt; use crate::utils; #[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] #[serde(rename_all = "camelCase")] s...
code_fim
hard
{ "lang": "rust", "repo": "anandijain/sipoxide", "path": "/src/lines.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yiransheng/simple-reading-list path: /src/jsonml.rs pub fn append_element<F>(mut self, tag: &'static str, f: F) -> Self where F: FnOnce(JsonMLBuilder<'a>) -> JsonML<'a>, { let builder = JsonMLBuilder::new(); let children = f(builder).elements; let ele...
code_fim
hard
{ "lang": "rust", "repo": "yiransheng/simple-reading-list", "path": "/src/jsonml.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let code = self.text()?; self.expects_close()?; Ok(Element::Tree( "pre", None, vec![Element::Tree("code", None, vec![code])], )) } fn basic_tag(&mut self, open_tag: &'static str) -> IResult<Element<'a>> { self.advance()?...
code_fim
hard
{ "lang": "rust", "repo": "yiransheng/simple-reading-list", "path": "/src/jsonml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yiransheng/simple-reading-list path: /src/jsonml.rs erde_derive::*; use crate::macros::*; #[derive(Debug)] pub struct JsonML<'a> { elements: Vec<Element<'a>>, } pub struct JsonMLBuilder<'a> { elements: Vec<Element<'a>>, } impl<'a> JsonMLBuilder<'a> { pub fn new() -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "yiransheng/simple-reading-list", "path": "/src/jsonml.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kiennguyenchi/waswolf path: /src/rounds/state.rs use std::{ collections::{BTreeMap, BTreeSet, HashMap}, fmt::Debug, }; use serenity::{ client::Context, model::{ channel::{Message, PermissionOverwriteType}, guild::Member, id::{ChannelId, GuildId, MessageId...
code_fim
hard
{ "lang": "rust", "repo": "kiennguyenchi/waswolf", "path": "/src/rounds/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl RoundState<Ongoing> { pub async fn is_dead(&self, ctx: &Context, user: &Member) -> bool { let dead_role = match self.dead_role(ctx).await { Ok(d) => d, Err(_) => { return false; } }; user.roles.iter().any(|r_id| *r_id ==...
code_fim
hard
{ "lang": "rust", "repo": "kiennguyenchi/waswolf", "path": "/src/rounds/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn handle_response_with_empty_values() { let distinct_op = Distinct::empty(); let response = doc! { "values" : [], "ok" : 1 }; let expected_values: Vec<Bson> = Vec::new(); let actual_values = handle_response_test(&distinct_op, response).unwrap(); assert_eq!(...
code_fim
hard
{ "lang": "rust", "repo": "mongodb/mongo-rust-driver", "path": "/src/operation/distinct/test.rs", "mode": "spm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_suffix|> let expected_values: Vec<Bson> = Vec::new(); let actual_values = handle_response_test(&distinct_op, response).unwrap(); assert_eq!(actual_values, expected_values); } #[test] fn handle_response_no_values() { let distinct_op = Distinct::empty(); let response = doc! { "ok" : 1 ...
code_fim
hard
{ "lang": "rust", "repo": "mongodb/mongo-rust-driver", "path": "/src/operation/distinct/test.rs", "mode": "spm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mongodb/mongo-rust-driver path: /src/operation/distinct/test.rs use std::time::Duration; use crate::{ bson::{doc, Bson}, cmap::StreamDescription, coll::{options::DistinctOptions, Namespace}, error::ErrorKind, operation::{ test::{self, handle_response_test}, D...
code_fim
hard
{ "lang": "rust", "repo": "mongodb/mongo-rust-driver", "path": "/src/operation/distinct/test.rs", "mode": "psm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoodie/dvb-rs path: /src/lib.rs //! An unofficial crate to query publicly accessible API methods for Dresden's public transport system. //! //! Currently the endpoints are supported: //! //! ## Station //! `http://widgets.vvo-online.de/abfahrtsmonitor/Haltestelle.do` //! <|fim_suffix|>// pub mo...
code_fim
easy
{ "lang": "rust", "repo": "hoodie/dvb-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod find; pub mod monitor; pub mod trip; pub use crate::common::Mot; pub use crate::error::Result; pub use crate::time::DvbTime;<|fim_prefix|>// repo: hoodie/dvb-rs path: /src/lib.rs //! An unofficial crate to query publicly accessible API methods for Dresden's public transport system. //! //! Curre...
code_fim
easy
{ "lang": "rust", "repo": "hoodie/dvb-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for value in GC { assert!(validate_name_and_value("General_Category", value)); assert!(validate_name_and_value("gc", value)); } assert!(!validate_name_and_value("General_Category", "junk")); assert!(!validate_name_and_value("gc", "junk")); fo...
code_fim
hard
{ "lang": "rust", "repo": "rusty-ecma/res-regex", "path": "/src/unicode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rusty-ecma/res-regex path: /src/unicode.rs use crate::unicode_tables::{general_category::GC, script_values::SCRIPT, GC_AND_BP}; /// Validate a `LoneUnicodePropertyNameOrValue` /// is a valid name or value /// /// ex: /// ```js /// let re = /\p{White_Space}\p{Alphabetic}/; /// ``` /// /// This f...
code_fim
medium
{ "lang": "rust", "repo": "rusty-ecma/res-regex", "path": "/src/unicode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/port2/iocr8/mod.rs PC9W::VALUE18 => 25, PC9W::VALUE19 => 26, PC9W::VALUE20 => 27, PC9W::VALUE21 => 28, PC9W::VALUE22 => 29, PC9W::VALUE23 => 30, PC9W::VALUE24 => 31, } }...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/port2/iocr8/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/port2/iocr8/mod.rs [doc = "Input - No internal pull device, Pn_OUTx = input value"] #[inline] pub fn value4(self) -> &'a mut W { self.variant(PC9W::VALUE4) } #[doc = "Input inverted - No internal pull device active"] #[inline] pub fn...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/port2/iocr8/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> = "Checks if the value of the field is `VALUE22`"] #[inline] pub fn is_value22(&self) -> bool { *self == PC10R::VALUE22 } #[doc = "Checks if the value of the field is `VALUE23`"] #[inline] pub fn is_value23(&self) -> bool { *self == PC10R::VALUE23 } #[doc =...
code_fim
hard
{ "lang": "rust", "repo": "m9s/xmc1000", "path": "/xmc1000/src/port2/iocr8/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rnitta/wasm-brainfuck-interpreter path: /src/wasm/src/interpreter.rs #[derive(Debug, PartialEq, Copy, Clone)] enum Token { Ptrinc, Ptrdec, Valinc, Valdec, Output, Input, Loopb, Loope, } impl Token { pub fn from_char(c: &char) -> Option<Token> { match ...
code_fim
hard
{ "lang": "rust", "repo": "rnitta/wasm-brainfuck-interpreter", "path": "/src/wasm/src/interpreter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(left) = &tree.left { if let Some(token) = left.token { match token { // どうせpanicするのでbuf.len()の判定をしない Token::Ptrinc => { *ptr = ptr.wrapping_add(1); } // ラップしてもどうせ落ちるけど Token::Ptrdec => { *ptr = ptr.wrapping_sub(1); } ...
code_fim
hard
{ "lang": "rust", "repo": "rnitta/wasm-brainfuck-interpreter", "path": "/src/wasm/src/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let websocket_uri = w.url.clone(); let web_db = web::Data::new(Mutex::new(db)); utils::watch_api_docs_change(web_db.clone()); let server = server::ChatServer::default(); let server = server.start(); println!("Starting service on http://{}:{}", conf.host, conf.port); HttpServe...
code_fim
hard
{ "lang": "rust", "repo": "xifat/panda-api", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xifat/panda-api path: /src/main.rs use actix_web::{middleware, web, App, HttpServer, http}; use actix_files::Files; use dotenv::dotenv; use std::sync::Mutex; mod db; mod api; mod utils; mod websocket; mod server; mod mock; use structopt::StructOpt; use actix::Actor; #[derive(StructOpt, Deb...
code_fim
hard
{ "lang": "rust", "repo": "xifat/panda-api", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let server = server::ChatServer::default(); let server = server.start(); println!("Starting service on http://{}:{}", conf.host, conf.port); HttpServer::new(move || { App::new() .data(server.clone()) .app_data(web_db.clone()) .wrap(middleware::Lo...
code_fim
hard
{ "lang": "rust", "repo": "xifat/panda-api", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_runtime/src/otp/erlang/erase_0/test.rs mod with_entries; use liblumen_alloc::erts::term::prelude::Term; <|fim_suffix|>#[test] fn without_entries_returns_empty_list() { with_process(|process| { assert_eq!(native(process), Ok(Term::NIL)); }); }<|fim_mi...
code_fim
medium
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/lumen_runtime/src/otp/erlang/erase_0/test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with_process(|process| { assert_eq!(native(process), Ok(Term::NIL)); }); }<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_runtime/src/otp/erlang/erase_0/test.rs mod with_entries; use liblumen_alloc::erts::term::prelude::Term; use crate::otp::erlang::erase_0::native; use crate::schedu...
code_fim
easy
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/lumen_runtime/src/otp/erlang/erase_0/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cel = (fahr - 32.0) * (5.0/9.0); println!("The converted temp in celsius is: {}", cel); }<|fim_prefix|>// repo: tashoecraft/rustbook-examples path: /fahrToCel/src/main.rs use std::io; fn main() { let mut fahr_str = String::new(); io::stdin().read_line(&mut fahr_str) .expect("...
code_fim
medium
{ "lang": "rust", "repo": "tashoecraft/rustbook-examples", "path": "/fahrToCel/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tashoecraft/rustbook-examples path: /fahrToCel/src/main.rs use std::io; fn main() { let mut fahr_str = String::new(); io::stdin().read_line(&mut fahr_str) .expect("Failed to read number"); <|fim_suffix|> let cel = (fahr - 32.0) * (5.0/9.0); println!("The converted temp i...
code_fim
medium
{ "lang": "rust", "repo": "tashoecraft/rustbook-examples", "path": "/fahrToCel/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gleam-lang/gleam path: /compiler-core/src/erlang/tests/records.rs use crate::assert_erl; use crate::erlang::*; use crate::type_; #[test] fn basic() { insta::assert_snapshot!(record_definition( "PetCat", &[ ("name", type_::tuple(vec![])), ("is_cute", t...
code_fim
hard
{ "lang": "rust", "repo": "gleam-lang/gleam", "path": "/compiler-core/src/erlang/tests/records.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let triple = Triple(1,2,3) let Triple(b: the_b, ..) = triple the_b } "# ); } #[test] fn record_spread2() { // Test binding to a record field with the spread operator with both a labelled argument and a positional argument assert_erl!( r#" type Triple { Triple(a: Int, b: Int, c...
code_fim
hard
{ "lang": "rust", "repo": "gleam-lang/gleam", "path": "/compiler-core/src/erlang/tests/records.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> validator_id: &Keypair, new_vote_account_id: Pubkey, last_id: Hash, num_tokens: u64, ) -> Self { Transaction::system_create( validator_id, new_vote_account_id, last_id, num_tokens, vote_program::get_max...
code_fim
hard
{ "lang": "rust", "repo": "sambley/solana", "path": "/src/vote_transaction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sambley/solana path: /src/vote_transaction.rs //! The `vote_transaction` module provides functionality for creating vote transactions. #[cfg(test)] use bank::Bank; use bincode::deserialize; #[cfg(test)] use result::Result; use signature::Keypair; #[cfg(test)] use signature::KeypairUtil; use sol...
code_fim
hard
{ "lang": "rust", "repo": "sambley/solana", "path": "/src/vote_transaction.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] pub fn create_vote_account( node_keypair: &Keypair, bank: &Bank, num_tokens: u64, last_id: Hash, ) -> Result<Keypair> { let new_vote_account = Keypair::new(); // Create the new vote account let tx = Transaction::vote_account_new(node_keypair, new_vote_acco...
code_fim
hard
{ "lang": "rust", "repo": "sambley/solana", "path": "/src/vote_transaction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattlknight/rust-win32-bindgen path: /src/process/features.rs use std::collections::{BTreeMap, HashMap}; use itertools::Itertools; use ExpConfig; use clang::{ self, RcIndexExt, }; use features::{Features, scan_features}; use util; use super::{Cache, TuCache}; /** Calculate the feature ...
code_fim
hard
{ "lang": "rust", "repo": "mattlknight/rust-win32-bindgen", "path": "/src/process/features.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> debug!("get_token_lines({:?}, _)", file.file_name()); let path = file.file_name(); // Architecture shouldn't matter since we just want the tokens. let tu = tu_cache.parse_translation_unit(&path, &ExpConfig::DUMMY_CFG).unwrap(); // Get the set of line numbers which *contain* a line co...
code_fim
hard
{ "lang": "rust", "repo": "mattlknight/rust-win32-bindgen", "path": "/src/process/features.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn make_ident(&mut self, name: &'ctx str) -> Ident { use std::collections::hash_map::Entry; let next_ix = self.name_to_id.len(); match self.name_to_id.entry(name) { Entry::Occupied(occupied) => *occupied.get(), Entry::Vacant(vacant) => { ...
code_fim
hard
{ "lang": "rust", "repo": "98devin/friday", "path": "/src/id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 98devin/friday path: /src/id.rs use derive_more::{From, Into}; use crate::storage::*; use std::collections::HashMap; #[repr(transparent)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, From, Into)] pub struct Ident(usize); #[derive(Debug, Clone)] pub struct NameTable<'ctx> { name_to_i...
code_fim
medium
{ "lang": "rust", "repo": "98devin/friday", "path": "/src/id.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the URL encoded string representation of this Body. pub fn urlencode(&self) -> String { utf8_percent_encode(&self.to_string(), CONTROLS).to_string() } }<|fim_prefix|>// repo: gliderkite/akkorokamui path: /src/api/body.rs use percent_encoding::{utf8_percent_encode, CONTROLS...
code_fim
hard
{ "lang": "rust", "repo": "gliderkite/akkorokamui", "path": "/src/api/body.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gliderkite/akkorokamui path: /src/api/body.rs use percent_encoding::{utf8_percent_encode, CONTROLS}; use serde::Serialize; use std::{collections::HashMap, fmt}; /// The body of a POST request. #[derive(Debug, Serialize)] pub struct Body { nonce: u64, otp: Option<String>, params: Has...
code_fim
hard
{ "lang": "rust", "repo": "gliderkite/akkorokamui", "path": "/src/api/body.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let txns_filled_failed = UIntCounterVec::new( Opts::new( "starcoin_txns_filled_failed", "txns filled failed".to_string(), ) .namespace("starcoin"), &["type"], )?; let broadcast_txns_count = ...
code_fim
hard
{ "lang": "rust", "repo": "xfhxfh1212/starcoin", "path": "/block-relayer/src/metrics.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl BlockRelayerMetrics { pub fn register() -> Result<Self, PrometheusError> { let txns_filled_from_network = register_int_gauge!(Opts::new( "txns_filled_from_network", "Count of block filled transactions from network" ) .namespace("starcoin"))?; ...
code_fim
hard
{ "lang": "rust", "repo": "xfhxfh1212/starcoin", "path": "/block-relayer/src/metrics.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xfhxfh1212/starcoin path: /block-relayer/src/metrics.rs use once_cell::sync::Lazy; use starcoin_metrics::{ default_registry, register_histogram, register_int_gauge, register_uint_gauge, Histogram, IntGauge, Opts, PrometheusError, UIntCounterVec, UIntGauge, }; pub static BLOCK_RELAYER_ME...
code_fim
hard
{ "lang": "rust", "repo": "xfhxfh1212/starcoin", "path": "/block-relayer/src/metrics.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>CREATE INDEX IF NOT EXISTS index_steam_leaderboard_placement ON steam_leaderboard(level_id, placement); CREATE INDEX IF NOT EXISTS index_players_display_name ON players(cached_display_name); CREATE INDEX IF NOT EXISTS index_players_evaluation_sum ON players(evaluation_sum); CREATE INDEX IF NOT EXISTS...
code_fim
hard
{ "lang": "rust", "repo": "Seeker14491/Distance-Leaderboard", "path": "/src/evaluator/src/db_create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Seeker14491/Distance-Leaderboard path: /src/evaluator/src/db_create.rs pub fn get_statements() -> Vec<&'static str> { [ r#" CREATE TABLE IF NOT EXISTS players ( steam_id TEXT NOT NULL PRIMARY KEY, score_count INTEGER NOT NULL DEFAULT 0, evaluation_sum INTEGER NOT NULL DEFAULT 0, eva...
code_fim
hard
{ "lang": "rust", "repo": "Seeker14491/Distance-Leaderboard", "path": "/src/evaluator/src/db_create.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>CREATE TRIGGER IF NOT EXISTS player_evaluation_update AFTER UPDATE ON players WHEN OLD.evaluation_sum <> NEW.evaluation_sum BEGIN UPDATE players SET evaluation = (NEW.evaluation_sum/MAX(NEW.score_count, 100)) WHERE steam_id = NEW.steam_id; END; CREATE TRIGGER IF NOT EXISTS level_insert ...
code_fim
hard
{ "lang": "rust", "repo": "Seeker14491/Distance-Leaderboard", "path": "/src/evaluator/src/db_create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn Java_org_nativescript_canvas_TNSCanvasRenderingContext2D_nativeSetStrokeColorWithString( env: JNIEnv, _: JClass, context: jlong, color: JString, ) { paint_style_set_color_with_string(env, context, false, color); } #[no_mangle] pub extern "C" fn Java_org_...
code_fim
hard
{ "lang": "rust", "repo": "fredlim/canvas", "path": "/packages/canvas/src-native/canvas-native/canvas-core/src/android/paint.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredlim/canvas path: /packages/canvas/src-native/canvas-native/canvas-core/src/android/paint.rs use std::str::FromStr; use css_color_parser::{Color, ColorParseError}; use jni::JNIEnv; use jni::objects::{JClass, JString}; use jni::sys::{jlong, jstring}; use log::{debug, info}; use crate::common...
code_fim
hard
{ "lang": "rust", "repo": "fredlim/canvas", "path": "/packages/canvas/src-native/canvas-native/canvas-core/src/android/paint.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rdesarz/rust-http-server path: /src/thread/pool.rs use std::sync::{mpsc, Arc, Mutex}; use std::thread; enum Message { NewJob(Job), Terminate, } type Job = Box<dyn FnOnce() + Send + 'static>; /// Worker executes Job struct Worker { /// Id of the worker id: usize, /// Thread...
code_fim
hard
{ "lang": "rust", "repo": "rdesarz/rust-http-server", "path": "/src/thread/pool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }