text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: nixpulvis/tiger path: /tiger-syntax/src/ast/operation.rs #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum Operation { Plus, Minus, Times, Divide, Eq, Neq, Lt, Le, Gt, Ge, } #[cfg(test)] mod tests { use tiger; use tok::Lexer; use ast::Ope...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/tiger", "path": "/tiger-syntax/src/ast/operation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> test!("-", O::Minus); } #[test] fn test_times() { test!("*", O::Times); } #[test] fn test_divide() { test!("/", O::Divide); } #[test] fn test_eq() { test!("=", O::Eq); } #[test] fn test_neq() { test!("<>", O::Neq); ...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/tiger", "path": "/tiger-syntax/src/ast/operation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> SWR_DITHER_NS => Dither::None, SWR_DITHER_NS_LIPSHITZ => Dither::NoiseShapingLipshitz, SWR_DITHER_NS_F_WEIGHTED => Dither::NoiseShapingFWeighted, SWR_DITHER_NS_MODIFIED_E_WEIGHTED => Dither::NoiseShapingModifiedEWeighted, SWR_DITHER_NS_IMPROVED_E...
code_fim
hard
{ "lang": "rust", "repo": "zmwangx/rust-ffmpeg", "path": "/src/software/resampling/dither.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> match value { Dither::None => SWR_DITHER_NONE, Dither::Rectangular => SWR_DITHER_RECTANGULAR, Dither::Triangular => SWR_DITHER_TRIANGULAR, Dither::TriangularHighPass => SWR_DITHER_TRIANGULAR_HIGHPASS, Dither::NoiseShapingLipshitz => SWR_...
code_fim
hard
{ "lang": "rust", "repo": "zmwangx/rust-ffmpeg", "path": "/src/software/resampling/dither.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zmwangx/rust-ffmpeg path: /src/software/resampling/dither.rs use ffi::SwrDitherType::*; use ffi::*; #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Dither { None, Rectangular, Triangular, TriangularHighPass, NoiseShapingLipshitz, NoiseShapingFWeighted, NoiseSh...
code_fim
hard
{ "lang": "rust", "repo": "zmwangx/rust-ffmpeg", "path": "/src/software/resampling/dither.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> Ok(updated_to_do) } pub fn delete_to_do(&self, id: String) -> Result<ToDo, diesel::result::Error> { let to_do = self.find_to_do(id.clone())?; diesel::delete(dsl::to_dos.find(id)).execute(&self.db_conn)?; Ok(to_do) } }<|fim_prefix|>// repo: morgsmccauley/full-s...
code_fim
hard
{ "lang": "rust", "repo": "morgsmccauley/full-stack-todo", "path": "/server/src/database/actions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: morgsmccauley/full-stack-todo path: /server/src/database/actions.rs use crate::database::pool::DbPoolConnection; use crate::database::schema::to_dos::dsl; use crate::models::ToDo; use diesel::prelude::*; use uuid::Uuid; pub struct Actions { db_conn: DbPoolConnection, } impl Actions { p...
code_fim
medium
{ "lang": "rust", "repo": "morgsmccauley/full-stack-todo", "path": "/server/src/database/actions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> diesel::update(dsl::to_dos.find(id)) .set(&updated_to_do) .execute(&self.db_conn)?; Ok(updated_to_do) } pub fn delete_to_do(&self, id: String) -> Result<ToDo, diesel::result::Error> { let to_do = self.find_to_do(id.clone())?; diesel::delete...
code_fim
hard
{ "lang": "rust", "repo": "morgsmccauley/full-stack-todo", "path": "/server/src/database/actions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sax1johno/wasmer path: /tests/emtests/test_strtold.rs #[test] #[ignore] fn test_test_strtold() { assert_emscripten_output!( "../emscripten_resources/emtests/test_s<|fim_suffix|> "../emscripten_resources/emtests/test_strtold.out" ); }<|fim_middle|>trtold.wasm", "test_strt...
code_fim
medium
{ "lang": "rust", "repo": "sax1johno/wasmer", "path": "/tests/emtests/test_strtold.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "../emscripten_resources/emtests/test_strtold.out" ); }<|fim_prefix|>// repo: sax1johno/wasmer path: /tests/emtests/test_strtold.rs #[test] #[ignore] fn test_test_strtold() { assert_emscri<|fim_middle|>pten_output!( "../emscripten_resources/emtests/test_strtold.wasm", "test_strt...
code_fim
medium
{ "lang": "rust", "repo": "sax1johno/wasmer", "path": "/tests/emtests/test_strtold.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if c == b'\\' { len -= 1; str_ += 1; } str_ += 1; } vend = str_; if len != 0 { len -= 1; str_ += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "afrase/lib-ruby-parser", "path": "/src/lexer/parse_magic_comment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> len -= 1; str_ += 1; } vend = str_; } if indicator { while len > 0 && (self.char_at(str_) == b';' || self.char_at(str_).is_space()) { len -= 1; str_ += 1;...
code_fim
hard
{ "lang": "rust", "repo": "afrase/lib-ruby-parser", "path": "/src/lexer/parse_magic_comment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: afrase/lib-ruby-parser path: /src/lexer/parse_magic_comment.rs use std::convert::TryInto; use crate::source::{MagicComment, MagicCommentKind}; use crate::DiagnosticMessage; use crate::Lexer; const MAGIC_COMMENTS: &[(&str, MagicCommentKind)] = &[ ("coding", MagicCommentKind::Encoding), ...
code_fim
hard
{ "lang": "rust", "repo": "afrase/lib-ruby-parser", "path": "/src/lexer/parse_magic_comment.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( vec![vec![7, 5, 11, 2], vec![10, 6, 9, 1], vec![4, 8, 3, 15]], Solution::sort_the_students( vec![vec![10, 6, 9, 1], vec![7, 5, 11, 2], vec![4, 8, 3, 15]], 2 ) ); assert_eq!( vec![vec![5, 6], vec![3, 4]], Solution::sor...
code_fim
medium
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/sort_the_students_by_their_kth_score.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( vec![vec![5, 6], vec![3, 4]], Solution::sort_the_students(vec![vec![3, 4], vec![5, 6]], 0) ); }<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/sort_the_students_by_their_kth_score.rs // https://leetcode.com/problems/sort-the-students-by-their-kth-scor...
code_fim
hard
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/sort_the_students_by_their_kth_score.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/sort_the_students_by_their_kth_score.rs // https://leetcode.com/problems/sort-the-students-by-their-kth-score/ struct Solution; impl Solution { pub fn sort_the_students(score: Vec<Vec<i32>>, k: i32) -> Vec<Vec<i32>> { let mut score_to_inde...
code_fim
hard
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/sort_the_students_by_their_kth_score.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wezm/dslite2svd path: /crates/tm4c129x/src/eeprom/pp/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::PP { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get() } } } #...
code_fim
hard
{ "lang": "rust", "repo": "wezm/dslite2svd", "path": "/crates/tm4c129x/src/eeprom/pp/mod.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>] #[inline] pub fn is_3k(&self) -> bool { *self == SIZER::_3K } #[doc = "Checks if the value of the field is `_4K`"] #[inline] pub fn is_4k(&self) -> bool { *self == SIZER::_4K } #[doc = "Checks if the value of the field is `_5K`"] #[inline] pub fn i...
code_fim
hard
{ "lang": "rust", "repo": "wezm/dslite2svd", "path": "/crates/tm4c129x/src/eeprom/pp/mod.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pawel82S/vernam-otp path: /src/otp_importer/text_file_hex.rs use super::OTPImporter; use std::{fs, io, path::Path}; pub struct TextFileHexImporter { data: Vec<u8>, } impl TextFileHexImporter { pub fn new(file: &Path) -> Result<Self, io::Error> { let contents = fs::read_to_strin...
code_fim
hard
{ "lang": "rust", "repo": "Pawel82S/vernam-otp", "path": "/src/otp_importer/text_file_hex.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> hex_text .to_uppercase() .chars() // I have to reverse order of characters in hex string so last will get lowest index in // enumerate because this index is used as a power for base 16 from LSB to MSB. .rev() .enumerate() ...
code_fim
hard
{ "lang": "rust", "repo": "Pawel82S/vernam-otp", "path": "/src/otp_importer/text_file_hex.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cundd/twostep path: /src/sequence.rs use ufmt::{derive::uDebug, uDebug, uDisplay, uWrite, Formatter}; use crate::dac_byte::DacByte; #[derive(Copy, Clone, uDebug)] pub struct Sequence { length: usize, s1: Option<DacByte>, s2: Option<DacByte>, s3: Option<DacByte>, s4: Option<...
code_fim
hard
{ "lang": "rust", "repo": "cundd/twostep", "path": "/src/sequence.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut serial: arduino_uno::Serial<arduino_uno::hal::port::mode::Floating> = unsafe { core::mem::MaybeUninit::uninit().assume_init() }; ufmt::uwriteln!(&mut serial, "Step {} out of bounds!\r", step).void_unwrap(); panic!() ...
code_fim
hard
{ "lang": "rust", "repo": "cundd/twostep", "path": "/src/sequence.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sqlite_pool_ = sqlite_pool.clone(); let login_file_ = login_file.clone(); std::thread::spawn(move || { let rt = tokio::runtime::Runtime::new().unwrap(); debug!("Starting Gotify receiver thread"); rt.block_on(gotify_receiver::run(sqlite_pool_, &*DBUS_CONNECTION.inner...
code_fim
hard
{ "lang": "rust", "repo": "UnifiedPush/gotify-dbus-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lazy_static! { static ref DBUS_CONNECTION: zbus::Connection = zbus::Connection::new_session().unwrap(); } fn main() -> Result<(), Error> { env_logger::init(); info!("Starting UnifiedPush Gotify receiver"); let project_dirs = ProjectDirs::from("fi", "vurpo", "UnifiedPushGotify") ....
code_fim
medium
{ "lang": "rust", "repo": "UnifiedPush/gotify-dbus-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: UnifiedPush/gotify-dbus-rust path: /src/main.rs #![feature(proc_macro_hygiene, decl_macro)] use std::error::Error as StdError; use std::sync::Arc; use std::fs::File; use std::path::PathBuf; use lazy_static::lazy_static; use directories_next::ProjectDirs; use r2d2_sqlite::SqliteConnectionManager...
code_fim
medium
{ "lang": "rust", "repo": "UnifiedPush/gotify-dbus-rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SpinResearch/rustysecrets-node path: /native/src/dss.rs extern crate base64; #[macro_use] extern crate neon; extern crate rusty_secrets; use rusty_secrets::dss::ss1::{self, Reproducibility}; use neon::vm::{Call, JsResult}; use neon::js::{JsArray, JsInteger, JsObject, JsString, Object}; fn spl...
code_fim
hard
{ "lang": "rust", "repo": "SpinResearch/rustysecrets-node", "path": "/native/src/dss.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> for (i, share_obj) in shares_js.into_iter().enumerate() { result.set(i as u32, share_obj)?; } Ok(result) } register_module!(m, { m.export("splitSecret", split_secret) });<|fim_prefix|>// repo: SpinResearch/rustysecrets-node path: /native/src/dss.rs extern crate base64; #[macro_use] ...
code_fim
medium
{ "lang": "rust", "repo": "SpinResearch/rustysecrets-node", "path": "/native/src/dss.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let condition = true; let number = if condition { 100 } else { 101 }; // if表达式的返回值作为变量数据 println!("{}", number); // let string = if condition { "hello" } else { 101 }; // if表达式返回值必须为相同类型 }<|fim_prefix|>// repo: yoyoliyang/rust_learn path: /src/if.rs fn main() { // if , else if, else ...
code_fim
hard
{ "lang": "rust", "repo": "yoyoliyang/rust_learn", "path": "/src/if.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yoyoliyang/rust_learn path: /src/if.rs fn main() { // if , else if, else // if 给定的必须是一个布尔值bool // if 是一个表达式,所以可以在let中使用 let x: i64 = 20; if x > 30 { println!("number is less than 30"); } if x == 45 { println!("ok"); } else { println!("{}"...
code_fim
hard
{ "lang": "rust", "repo": "yoyoliyang/rust_learn", "path": "/src/if.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub left: Option<usize>, pub right: Option<usize>, pub parent: Option<usize>, }<|fim_prefix|>// repo: dannowilby/rust-huffman-tree path: /src/model.rs use serde::{ Deserialize, Serialize }; #[derive(Serialize, Deserialize, Debug)] pub struct Huffman { pub nodes: Vec<Node>, pub head_node: usiz...
code_fim
medium
{ "lang": "rust", "repo": "dannowilby/rust-huffman-tree", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub frequency: u32, pub letter: String, pub left: Option<usize>, pub right: Option<usize>, pub parent: Option<usize>, }<|fim_prefix|>// repo: dannowilby/rust-huffman-tree path: /src/model.rs use serde::{ Deserialize, Serialize }; #[derive(Serialize, Deserialize, Debug)] pub struct Huffman { ...
code_fim
medium
{ "lang": "rust", "repo": "dannowilby/rust-huffman-tree", "path": "/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dannowilby/rust-huffman-tree path: /src/model.rs use serde::{ Deserialize, Serialize }; #[derive(Serialize, Deserialize, Debug)] pub struct Huffman { pub nodes: Vec<Node>, pub head_node: usize, } <|fim_suffix|> pub left: Option<usize>, pub right: Option<usize>, pub parent: Option<us...
code_fim
medium
{ "lang": "rust", "repo": "dannowilby/rust-huffman-tree", "path": "/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut in_text = String::new(); match io::stdin().read_line(&mut in_text) { Ok(_) => {if find_closes(in_text){println!("true");} else{println!("false");}}, Err(e) => {println!("Error reading input {}", e); process::exit(1);} } }<|fim_prefix|>// repo: JonasBe...
code_fim
hard
{ "lang": "rust", "repo": "JonasBerx/2017Challenges", "path": "/challenge_10/rust/deg4uss3r/challenge_10/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JonasBerx/2017Challenges path: /challenge_10/rust/deg4uss3r/challenge_10/src/main.rs use std::io; use std::process; fn find_closes(in_text: String) -> bool { let mut stack_collector = Vec::new(); <|fim_suffix|> match io::stdin().read_line(&mut in_text) { Ok(_) => {if find_cl...
code_fim
hard
{ "lang": "rust", "repo": "JonasBerx/2017Challenges", "path": "/challenge_10/rust/deg4uss3r/challenge_10/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blu-dev/acmd-porter path: /src/processing.rs use crate::utils; pub fn find_first(text: String, to_find: &[char]) -> Option<(usize, char)> { let mut chars = text.chars(); let mut count = 0; let mut quote = crate::utils::Quote::new(); loop { let ch = chars.next(); ...
code_fim
hard
{ "lang": "rust", "repo": "blu-dev/acmd-porter", "path": "/src/processing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let found = find_first(cur_str.clone(), &search); if found.is_none() { break; } let (loc, ch) = found.unwrap(); output.extend_from_slice(cur_str.chars().take(loc + 1).collect::<String>().as_bytes()); cur_str = cur_str.chars().skip(loc + 1).collec...
code_fim
hard
{ "lang": "rust", "repo": "blu-dev/acmd-porter", "path": "/src/processing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn handle_lua_void(block: String) -> String { let mut cur_str = block.clone(); let mut output = Vec::new(); loop { if let Some(offset) = cur_str.find("*LUA_VOID") { output.extend_from_slice(cur_str.chars().take(offset).collect::<String>().as_bytes()); cur_st...
code_fim
hard
{ "lang": "rust", "repo": "blu-dev/acmd-porter", "path": "/src/processing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xea/squiddy path: /squiddy-server/src/main.rs #[cfg(unix)] extern crate termion; extern crate bytes; #[macro_use] extern crate futures; extern crate tokio; <|fim_suffix|>fn main() { let state = State::new(); let arc = Arc::new(RwLock::new(state)); let config = ServerConfig::from_arg...
code_fim
medium
{ "lang": "rust", "repo": "xea/squiddy", "path": "/squiddy-server/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn start_terminal(state: Arc<RwLock<State>>) { let mut stdout = Terminal::stdout(); let mut terminal = Terminal::new(&mut stdout, state); terminal.start(); }<|fim_prefix|>// repo: xea/squiddy path: /squiddy-server/src/main.rs #[cfg(unix)] extern crate termion; extern crate bytes; #[macro_us...
code_fim
hard
{ "lang": "rust", "repo": "xea/squiddy", "path": "/squiddy-server/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 1Antz1/underscore path: /underscore_semant/src/resolver.rs use super::InferResult; use env::Env; use std::collections::HashSet; use syntax::ast::{Function, Program, Struct, TyAlias}; use util::{emitter::Reporter, pos::Spanned, symbol::Symbol}; #[derive(Debug, Default)] pub struct Resolver { ...
code_fim
hard
{ "lang": "rust", "repo": "1Antz1/underscore", "path": "/underscore_semant/src/resolver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn resolve_structs( &mut self, struct_def: &Spanned<Struct>, reporter: &mut Reporter, env: &Env, ) -> InferResult<()> { if !self.values.insert(struct_def.value.name.value.name.value) { let msg = format!( "`{} ` is defined twice", ...
code_fim
hard
{ "lang": "rust", "repo": "1Antz1/underscore", "path": "/underscore_semant/src/resolver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn handle(&self) -> Self::Handle { OSMesaContextHandle(self.context) } fn make_current(&self) -> Result<(), &'static str> { unsafe { if !self.is_current() && osmesa_sys::OSMesaMakeCurrent(self.context, sel...
code_fim
hard
{ "lang": "rust", "repo": "paulrouget/rust-offscreen-rendering-context", "path": "/src/platform/with_osmesa/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> OSMesaContextHandle(self.context) } fn make_current(&self) -> Result<(), &'static str> { unsafe { if !self.is_current() && osmesa_sys::OSMesaMakeCurrent(self.context, self.buffer.as_ptr() as *const _ as *mut _...
code_fim
hard
{ "lang": "rust", "repo": "paulrouget/rust-offscreen-rendering-context", "path": "/src/platform/with_osmesa/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulrouget/rust-offscreen-rendering-context path: /src/platform/with_osmesa/mod.rs use std::ffi::CString; use std::os::raw::c_int; use std::ptr; use osmesa_sys; use gl_context::GLVersion; use gleam::gl; use platform::NativeGLContextMethods; const DUMMY_BUFFER_WIDTH: usize = 16; const DUMMY_BU...
code_fim
hard
{ "lang": "rust", "repo": "paulrouget/rust-offscreen-rendering-context", "path": "/src/platform/with_osmesa/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shandelier/Rust-Optimization-Methods path: /src/main.rs mod file_reader; mod print_utils; mod graph_generator; mod tabu_search; mod simulated_annealing; use std::io; use std::thread; fn main() { println!(); println!("Projektowanie efektywnych algorytmów - projekt 2"); println!("Pro...
code_fim
hard
{ "lang": "rust", "repo": "Shandelier/Rust-Optimization-Methods", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for data in datafiles { matrix = file_reader::read_any_file("data/".to_owned() + data.0, false); let mut children = vec![]; for _ in 0..10 { let mut x = matrix.clone(); let timeout ...
code_fim
hard
{ "lang": "rust", "repo": "Shandelier/Rust-Optimization-Methods", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input! { n: usize, xs: [usize; n], }; let ps = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]; let ans = rec(1, ps, &xs); println!("{}", ans); }<|fim_prefix|>// repo: hayashikun/atcoder path: /atcoder-rust/arc114/src/bin/a.rs #![allow(unused_imports)] u...
code_fim
hard
{ "lang": "rust", "repo": "hayashikun/atcoder", "path": "/atcoder-rust/arc114/src/bin/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hayashikun/atcoder path: /atcoder-rust/arc114/src/bin/a.rs #![allow(unused_imports)] use std::cmp::min; use std::collections::BTreeSet; use itertools::Itertools; use num::integer::gcd; use proconio::{fastout, input, marker::*}; fn check(p: usize, xs: &Vec<usize>) -> bool { let mut ok = tr...
code_fim
medium
{ "lang": "rust", "repo": "hayashikun/atcoder", "path": "/atcoder-rust/arc114/src/bin/a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[fastout] fn main() { input! { n: usize, xs: [usize; n], }; let ps = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]; let ans = rec(1, ps, &xs); println!("{}", ans); }<|fim_prefix|>// repo: hayashikun/atcoder path: /atcoder-rust/arc114/src/bin/a.rs #![al...
code_fim
hard
{ "lang": "rust", "repo": "hayashikun/atcoder", "path": "/atcoder-rust/arc114/src/bin/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl TestMakeWriter { fn new() -> (Self, Handle) { let write = Arc::new(Mutex::new(Some(Vec::<u8>::new()))); ( Self { write: write.clone(), }, Handle { write }, ) } } impl<'a> MakeWriter<'a> for TestMakeWriter { type...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum/src/test_helpers/tracing_helpers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/axum path: /axum/src/test_helpers/tracing_helpers.rs use std::{ future::Future, io, sync::{Arc, Mutex}, }; use serde::{de::DeserializeOwned, Deserialize}; use tracing_subscriber::prelude::*; use tracing_subscriber::{filter::Targets, fmt::MakeWriter}; #[derive(Deserialize, ...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum/src/test_helpers/tracing_helpers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() } pub fn file_descript...
code_fim
hard
{ "lang": "rust", "repo": "xd009642/tensorflow-protos-rs", "path": "/src/protos/xla_service.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xd009642/tensorflow-protos-rs path: /src/protos/xla_service.rs // This file is generated by rust-protobuf 2.17.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 #![allow(unknown_lints)] #![allow(clippy::all)] #![allow(unused_attributes)] #![rustfmt::skip] #![...
code_fim
hard
{ "lang": "rust", "repo": "xd009642/tensorflow-protos-rs", "path": "/src/protos/xla_service.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hinagis/abc197 path: /src/bin/b.rs use proconio::{input, marker::Chars}; fn main() { input! { h: usize, w: usize, x: usize, y: usize, s: [Chars; h] } <|fim_suffix|> let mut i = x; let mut j = y + 1; while j <= w && s[i - 1][j - 1] != '...
code_fim
medium
{ "lang": "rust", "repo": "hinagis/abc197", "path": "/src/bin/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = x; let mut j = y + 1; while j <= w && s[i - 1][j - 1] != '#' { c += 1; j += 1; } j = y - 1; while j >= 1 && s[i - 1][j - 1] != '#' { c += 1; j -= 1; } j = y; i = x + 1; while i <= h && s[i - 1][j - 1] != '#' { c +=...
code_fim
medium
{ "lang": "rust", "repo": "hinagis/abc197", "path": "/src/bin/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_entropy() { let first_result = RdRandRng {}.next_u32(); for _ in 0..50 { let result = RdRandRng {}.next_u32(); if result != first_result { return; } } panic!("Got the same u32 50 times in a row: {}"...
code_fim
medium
{ "lang": "rust", "repo": "cbeck88/rust-cargo-bug", "path": "/src/mcrand/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cbeck88/rust-cargo-bug path: /src/mcrand/src/lib.rs #![no_std] extern crate rand_core; /*** * On x86 and x86_64 architectures, we don't depend on rand, and use rdrandrng.rs * Otherwise, we do depend on rand, and use fallback.rs */ #[cfg(not(target_arch = "x86_64"))] extern crate rand; <|fi...
code_fim
medium
{ "lang": "rust", "repo": "cbeck88/rust-cargo-bug", "path": "/src/mcrand/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n4j/kata-containers path: /src/agent/rustjail/src/cgroups/mod.rs // Copyright (c) 2019,2020 Ant Financial // // SPDX-License-Identifier: Apache-2.0 // use anyhow::{anyhow, Result}; use oci::LinuxResources; use protocols::agent::CgroupStats; use cgroups::freezer::FreezerState; <|fim_suffix|>pu...
code_fim
medium
{ "lang": "rust", "repo": "n4j/kata-containers", "path": "/src/agent/rustjail/src/cgroups/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Err(anyhow!("not supported!".to_string())) } fn get_pids(&self) -> Result<Vec<i32>> { Err(anyhow!("not supported!")) } fn get_stats(&self) -> Result<CgroupStats> { Err(anyhow!("not supported!")) } fn freeze(&self, _state: FreezerState) -> Result<()> { ...
code_fim
medium
{ "lang": "rust", "repo": "n4j/kata-containers", "path": "/src/agent/rustjail/src/cgroups/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(false, or(false, false)); assert_eq!(true, or(true, false)); assert_eq!(true, or(false, true)); assert_eq!(true, or(true, true)); } #[test] fn xor_test() { assert_eq!(false, xor(false, false)); assert_eq!(true, xor(true, false)); ...
code_fim
hard
{ "lang": "rust", "repo": "mitoma/nand2tetris", "path": "/hack_computer/src/basic_gate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mitoma/nand2tetris path: /hack_computer/src/basic_gate.rs pub fn nand(a: bool, b: bool) -> bool { !(a && b) } pub fn not(a: bool) -> bool { nand(a, a) } pub fn and(a: bool, b: bool) -> bool { not(nand(a, b)) } pub fn or(a: bool, b: bool) -> bool { nand(not(a), not(b)) } pub f...
code_fim
hard
{ "lang": "rust", "repo": "mitoma/nand2tetris", "path": "/hack_computer/src/basic_gate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nzsc-incubator/nzscq_web path: /crate/src/render/pill.rs use super::Render; use crate::colors::{self, Rgba}; use crate::paint::Component; use crate::shapes::{ dequeue_circle::{self, CirclePosition}, Circle, Rect, }; use crate::side::Side; use crate::transform::Translate; pub struct Pill...
code_fim
hard
{ "lang": "rust", "repo": "nzsc-incubator/nzscq_web", "path": "/crate/src/render/pill.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn pill_with_zero_width_renders_empty_vec() { let pill = Pill { position: CirclePosition { side: Side::Left, column: 0, row: 0, }, width_in_columns: 0, height_in_rows: 1, ena...
code_fim
hard
{ "lang": "rust", "repo": "nzsc-incubator/nzscq_web", "path": "/crate/src/render/pill.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn pill_with_zero_width_renders_empty_vec() { let pill = Pill { position: CirclePosition { side: Side::Left, column: 0, row: 0, }, width_in_columns: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "nzsc-incubator/nzscq_web", "path": "/crate/src/render/pill.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RichoDemus/rusteroids path: /src/main.rs use quicksilver::blinds::event::MouseButton::Left; use quicksilver::geom::{Circle, Rectangle}; use quicksilver::graphics::VectorFont; use quicksilver::input::{Event, Key, ScrollDelta}; use quicksilver::{ geom::Vector, graphics::Color, run, Graphics, I...
code_fim
hard
{ "lang": "rust", "repo": "RichoDemus/rusteroids", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let ttf = VectorFont::from_slice(include_bytes!("BebasNeue-Regular.ttf")); let mut font = ttf.to_renderer(&gfx, 30.0)?; let mut running = true; let mut camera_y_axis; let mut camera_x_axis; let mut zoom_scale = 1.; while running { camera_y_axis = 0.; camera_x_a...
code_fim
hard
{ "lang": "rust", "repo": "RichoDemus/rusteroids", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // We use a while loop rather than an if so that we can try to catch up in the event of having a slow down. while update_timer.tick() { core.tick(dt, camera_x_axis, camera_y_axis); } // Unlike the update cycle drawing doesn't change our state // Because...
code_fim
hard
{ "lang": "rust", "repo": "RichoDemus/rusteroids", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>//pretty printing: https://zsiciarz.github.io/24daysofrust/book/vol1/day6.html fn encode_json(input: Deliveries) { let mut json = String::new(); { let mut encoder = Encoder::new_pretty(&mut json); input.encode(&mut encoder).expect("encoding error"); } create_json_file(jso...
code_fim
hard
{ "lang": "rust", "repo": "maniflames/time-frame-json-generator", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maniflames/time-frame-json-generator path: /src/main.rs extern crate rustc_serialize; extern crate rand; use std::fs::File; use std::io::prelude::*; use rustc_serialize::Encodable; use rustc_serialize::json::{self, Encoder}; use rand::Rng; mod utils; mod package; mod customer; mod driver; #[...
code_fim
hard
{ "lang": "rust", "repo": "maniflames/time-frame-json-generator", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Probabilities that each point comes from each Gaussian. println!("{:?}", post_probs.data()); }<|fim_prefix|>// repo: maxtnuk/My_workspace path: /rust/do_myself/test_machine/src/main.rs extern crate rusty_machine; use rusty_machine::linalg::Matrix; use rusty_machine::learning::gmm::{CovOption...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/My_workspace", "path": "/rust/do_myself/test_machine/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxtnuk/My_workspace path: /rust/do_myself/test_machine/src/main.rs extern crate rusty_machine; use rusty_machine::linalg::Matrix; use rusty_machine::learning::gmm::{CovOption, GaussianMixtureModel}; use rusty_machine::learning::UnSupModel; fn main() { let inputs = Matrix::new(4, 2, vec![1....
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/My_workspace", "path": "/rust/do_myself/test_machine/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x = 42; // `x` has type `i32`. let y = 1.0; // `y` has type `f64`. // i8 -> fixed-sized integer // i16 -> fixed-sized integer // i32 -> fixed-sized integer // i64 -> fixed-sized integer // u8 -> fixed-sized unsigned integer // u16 -> fixed-sized unsigned integer /...
code_fim
hard
{ "lang": "rust", "repo": "PumpkinSeed/adventure-of-rust", "path": "/primitive-types/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PumpkinSeed/adventure-of-rust path: /primitive-types/src/main.rs #![allow(unused_variables)] fn main() { char_ex() } // Example of boolean primitive type fn bool_ex() { let x = true; let y: bool = false; println!("{}", y); } <|fim_suffix|> // char isn't a single byte, but f...
code_fim
medium
{ "lang": "rust", "repo": "PumpkinSeed/adventure-of-rust", "path": "/primitive-types/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewGi/micro16 path: /src/risc_v_emu/decoder.rs use super::instructions::*; use super::super::microvm::bits; use std::convert::TryInto; pub struct RawInstructionLine<'a> { raw: &'a [u8], format: InstructionFormat, } pub enum DecoderError { InvalidOpcode, } pub struct Opcode { <|f...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGi/micro16", "path": "/src/risc_v_emu/decoder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Copy, Clone, Eq, PartialEq)] pub struct Funct3(u8); #[derive(Copy, Clone, Eq, PartialEq)] pub struct Funct7(u8); #[derive(Copy, Clone, Eq, PartialEq)] pub struct Funct37(Funct3, Funct7); #[derive(Copy, Clone)] pub enum Funct { Funct3(Funct3), Funct37(Funct37) } impl Funct { pub fn siz...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGi/micro16", "path": "/src/risc_v_emu/decoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub struct RType { opcode: Opcode, rd: WhichReg, rs1: WhichReg, rs2: WhichReg, funct: Funct37 } pub struct IType<UT: DataType> { opcode: Opcode, rd: WhichReg, rs1: WhichReg, imm: Immediate<UT>, funct: Funct3 } ...
code_fim
hard
{ "lang": "rust", "repo": "AndrewGi/micro16", "path": "/src/risc_v_emu/decoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TigerInYourDream/tikv path: /tests/benches/misc/storage/incremental_get.rs // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use std::sync::Arc; use engine_rocks::RocksSnapshot; use kvproto::kvrpcpb::{Context, IsolationLevel}; use test::{black_box, Bencher}; use test_storage::...
code_fim
hard
{ "lang": "rust", "repo": "TigerInYourDream/tikv", "path": "/tests/benches/misc/storage/incremental_get.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let snapshot = engine.snapshot(Default::default()).unwrap(); let store = SnapshotStore::new( snapshot, 10.into(), IsolationLevel::Si, true, Default::default(), Default::default(), false, ); // Keys are given in order, and are far awa...
code_fim
hard
{ "lang": "rust", "repo": "TigerInYourDream/tikv", "path": "/tests/benches/misc/storage/incremental_get.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Keys are given in order, and are far away from each other to simulate a // normal table lookup scenario. let mut get_keys = Vec::new(); for i in (0..30000).step_by(30) { get_keys.push(Key::from_raw(&table::encode_row_key(5, i))); } (store, get_keys) } #[bench] fn bench_...
code_fim
hard
{ "lang": "rust", "repo": "TigerInYourDream/tikv", "path": "/tests/benches/misc/storage/incremental_get.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CounterToPrometheus<'myself, 'registry> { pdh: PDH, query: PdhQuery, registry: &'registry Registry, _marker: std::marker::PhantomData<&'myself PdhQuery>, } impl<'myself, 'registry> CounterToPrometheus<'myself, 'registry> { pub fn try_new(registry: &'registry Registry) -> an...
code_fim
hard
{ "lang": "rust", "repo": "zaphar/win-utils", "path": "/win-prom-node-exporter/src/binding.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaphar/win-utils path: /win-prom-node-exporter/src/binding.rs // Copyright 2020 Jeremy Wall // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.ap...
code_fim
hard
{ "lang": "rust", "repo": "zaphar/win-utils", "path": "/win-prom-node-exporter/src/binding.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut router = Router::new(); let cars_api = CarsApi { channel: ctx.node_channel().clone(), blockchain: ctx.blockchain().clone() }; cars_api.wire(&mut router); let owners_api = OwnersApi { channel: ctx.node_channel().clone(), ...
code_fim
hard
{ "lang": "rust", "repo": "divortep/car-story-rust-exonum", "path": "/car-story-service/src/service.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divortep/car-story-rust-exonum path: /car-story-service/src/service.rs use consts::{CARS_SERVICE_ID, CARS_SERVICE_NAME, TX_PRODUCE_CAR_ID, TX_CHANGE_CAR_OWNER_ID, TX_REGISTER_OWNER_ID}; use iron::Handler; use router::Router; use exonum::messages::FromRaw; use exonum::api::Api; use exonum::blockc...
code_fim
hard
{ "lang": "rust", "repo": "divortep/car-story-rust-exonum", "path": "/car-story-service/src/service.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udoprog/rust-advent-of-code-2017 path: /src/day03.rs use failure::Error; use std::ops::{Generator, GeneratorState}; use std::collections::HashMap; use self::GeneratorState::*; /// Walk the memory layout. /// /// Note 1: Returns the `never` type, which permits Rust to realize that this function...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/rust-advent-of-code-2017", "path": "/src/day03.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run(pos: u64) -> Result<i64, Error> { let mut index = 1; let mut walk = memory_walker(); loop { // Note: this is safe since the generator never returns. See above. let Yielded((x, y)) = walk.resume(); if index == pos { return Ok(i64::abs(x) + i64::a...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/rust-advent-of-code-2017", "path": "/src/day03.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // left for _ in 1..side { y -= 1; yield (x, y); } // bottom for _ in 0..side { x += 1; yield (x, y); } size += 1; } } } pub fn run_with_larger...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/rust-advent-of-code-2017", "path": "/src/day03.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn extra_semicolon() -> Result<(), ()> { /* TODO(taiki-e): help message still wrong help: try using a variant of the expected enum | 29 | Ok(Ok(());) | 29 | Err(Ok(());) | */ Ok(()); } fn main() {}<|fim_prefix|>// repo: glebpom/tok...
code_fim
hard
{ "lang": "rust", "repo": "glebpom/tokio", "path": "/tests-build/tests/fail/macros_type_mismatch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glebpom/tokio path: /tests-build/tests/fail/macros_type_mismatch.rs use tests_build::tokio; #[tokio::main] async fn missing_semicolon_or_return_type() { Ok(()) } <|fim_suffix|>#[tokio::main] async fn extra_semicolon() -> Result<(), ()> { /* TODO(taiki-e): help message still wrong h...
code_fim
hard
{ "lang": "rust", "repo": "glebpom/tokio", "path": "/tests-build/tests/fail/macros_type_mismatch.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monomadic/dd-core path: /examples/overdrive.rs extern crate dd_core; use dd_core::*; use dd_core::widgets::*; use dd_core::conrod; use dd_core::conrod::widget::*; use dd_core::conrod::text::{FontCollection}; use std::collections::HashMap; #[derive(Default)] struct TestPlugin {} impl BasePlugi...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/dd-core", "path": "/examples/overdrive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Knob::new() .set(widget_id(ids, "knob"), ui); // gain_slider if let Some(val) = Slider::new(config.params[0].value, 0.0, 1.0) .w_h(300.0, 30.0) .x_y(0.0, 50.0) .color(color::LIGHT_BLUE) .label("GAIN") .set(wid...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/dd-core", "path": "/examples/overdrive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dakom/awsm-web path: /crate/src/tick/mainloop.rs is visible. /// /// * interpolation_percentage /// /// The cumulative amount of time that hasn't been simulated yet, divided /// by the amount of time that will be simulated the next time update() /// runs. Useful for interpolating frames. ...
code_fim
hard
{ "lang": "rust", "repo": "dakom/awsm-web", "path": "/crate/src/tick/mainloop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Run any updates that are not dependent on time in the simulation. See // `MainLoop.setBegin()` for additional details on how to use this. (self.begin)(timestamp, self.frame_delta); // Update the estimate of the frame rate, `fps`. Approxim...
code_fim
hard
{ "lang": "rust", "repo": "dakom/awsm-web", "path": "/crate/src/tick/mainloop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dakom/awsm-web path: /crate/src/tick/mainloop.rs o simulate each time update() /// runs. See `MainLoop.setSimulationTimestep()` for details. pub simulation_timestep: f64, /// A factor that affects how heavily to weight more recent seconds' /// performance when calculating the av...
code_fim
hard
{ "lang": "rust", "repo": "dakom/awsm-web", "path": "/crate/src/tick/mainloop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input_bytes = input_string.into_bytes(); let build_hasher = WarehouseBuildHasher::default(); let mut hasher = build_hasher.build_hasher(); hasher.write(&input_bytes); println!("{}", hasher.finish()); Ok(()) } #[cfg(test)] mod tests { // Note this useful idiom: importing...
code_fim
hard
{ "lang": "rust", "repo": "paulevans/advent_2018", "path": "/src/bin/day_02a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulevans/advent_2018 path: /src/bin/day_02a.rs //use std::error::Error; //use std::collections::HashSet; //use std::collections::hash_map::DefaultHasher; //use std::collections::HashMap; use std::hash::{BuildHasher, BuildHasherDefault, Hasher}; //use std::io::{self, BufRead, Read}; use std::io:...
code_fim
hard
{ "lang": "rust", "repo": "paulevans/advent_2018", "path": "/src/bin/day_02a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for byte in bytes { match byte { &N | &R => { // For Debug only to output csv for count in &self.seen { print!("{},", count); } // Iterate over everything looking fo...
code_fim
hard
{ "lang": "rust", "repo": "paulevans/advent_2018", "path": "/src/bin/day_02a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d-fischer/twirl path: /src/api/api_call.rs use http::uri::{Scheme, Uri}; use hyper::Method; use url::Url; use std::{ borrow::Cow, error::Error, fmt::Display }; use crate::util::Result; #[derive(Clone)] pub enum TwitchApiCallType { Kraken, Helix, Auth, Custom, } #[d...
code_fim
hard
{ "lang": "rust", "repo": "d-fischer/twirl", "path": "/src/api/api_call.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn full_url(&self) -> Url { let builder = Uri::builder() .scheme(Scheme::HTTPS) .authority("api.twitch.tv"); let uri = match self.call_type { TwitchApiCallType::Kraken => { let path = format!("/kraken/{}", self.url.trim_start_mat...
code_fim
hard
{ "lang": "rust", "repo": "d-fischer/twirl", "path": "/src/api/api_call.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(text: &str) -> Result<Self, Self::Error> { text.chars() .enumerate() .map(|(i, c)| c.try_into().map_err(|_| i)) .collect::<Result<_, _>>() .map(Sequence) } }<|fim_prefix|>// repo: AndrewKvalheim/rust-exercises path: /rna-transcri...
code_fim
hard
{ "lang": "rust", "repo": "AndrewKvalheim/rust-exercises", "path": "/rna-transcription/src/sequence.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: TryFrom<char>> Sequence<T> { pub fn new(text: &str) -> Result<Self, usize> { text.try_into() } } impl<T: TryFrom<char>> TryFrom<&str> for Sequence<T> { type Error = usize; fn try_from(text: &str) -> Result<Self, Self::Error> { text.chars() .enumerate()...
code_fim
medium
{ "lang": "rust", "repo": "AndrewKvalheim/rust-exercises", "path": "/rna-transcription/src/sequence.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }