text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn is_glossy(&self) -> bool { self.glossiness > ::core::f64::EPSILON } fn glossiness(&self) -> f64 { self.glossiness } } impl Default for CookTorranceMaterial { fn default() -> CookTorranceMaterial { CookTorranceMaterial { k_a: 0.0, k_d...
code_fim
hard
{ "lang": "rust", "repo": "ericsink/rust-raytracer", "path": "/src/material/materials/cooktorrancematerial.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn glossiness(&self) -> f64 { self.glossiness } } impl Default for CookTorranceMaterial { fn default() -> CookTorranceMaterial { CookTorranceMaterial { k_a: 0.0, k_d: 1.0, k_s: 1.0, k_sg: 0.0, k_tg: 0.0, g...
code_fim
hard
{ "lang": "rust", "repo": "ericsink/rust-raytracer", "path": "/src/material/materials/cooktorrancematerial.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] use quickcheck::quickcheck; #[allow(dead_code)] mod tests { use super::*; fn prop_concat(list_1: Vec<i32>, list_2: Vec<i32>) -> bool { let mut linked_list_1 = LinkedList::linked_list_from(&list_1); let mut linked_list_2 = LinkedList::linked_list_from(&list_2); ...
code_fim
hard
{ "lang": "rust", "repo": "magfred-fobe/a-method-for-porting-software-using-formal-specifications", "path": "/reimplementation/rust_slist/singly_linked_list/src/singly_linked_list_unsafe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn iter(&self) -> Iter<T> { match &self.head { Some(node) => { Iter { current: Some(node) } }, None => Iter { current: None} } } } pub struct Iter<'a, T: LinkedListValue> { current: Option<&'a Node<T>> } impl<'a, T: LinkedLi...
code_fim
hard
{ "lang": "rust", "repo": "magfred-fobe/a-method-for-porting-software-using-formal-specifications", "path": "/reimplementation/rust_slist/singly_linked_list/src/singly_linked_list_unsafe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magfred-fobe/a-method-for-porting-software-using-formal-specifications path: /reimplementation/rust_slist/singly_linked_list/src/singly_linked_list_unsafe.rs use std::fmt::Debug; use std::error::Error; use std::fmt::Display; #[allow(dead_code)] impl<T> LinkedListValue for T where T: Debug {} ...
code_fim
hard
{ "lang": "rust", "repo": "magfred-fobe/a-method-for-porting-software-using-formal-specifications", "path": "/reimplementation/rust_slist/singly_linked_list/src/singly_linked_list_unsafe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DragonOfTheShadows/beagle-rs path: /build_mat.rs use std::fs::File; use std::io::{Write,Result}; use std::path::Path; use build_traits::{types,angle_types}; fn declare_mat(f: &mut File) -> Result<()> { let un_ops = ["Neg", "Not"]; let bin_ops = ["BitAnd", "BitOr", "BitXor", "Add", "Div...
code_fim
hard
{ "lang": "rust", "repo": "DragonOfTheShadows/beagle-rs", "path": "/build_mat.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Mat(<R as Dim<Vec<C, T>>>::from_iter(self.iter().zip(rhs.iter()).map(|(l, r)| {trait_name}::{method_name}(*l, *r)))) }} }} impl <'r, T: Scalar, U: Scalar, C: Dim<T>+Dim<U>, R: Dim<Vec<C, T>>+Dim<Vec<C, U>>> {trait_name}<&'r Mat<R, C, U>> for Mat<R, C, T> where T: {trait_name}<U, Output=T> {{ ...
code_fim
hard
{ "lang": "rust", "repo": "DragonOfTheShadows/beagle-rs", "path": "/build_mat.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xiuxiu62/shake-stack path: /src/stack.rs #[derive(Debug, Clone)] pub struct Stack<T> { inner: Vec<T>, } impl<T> Stack<T> { pub fn new() -> Self { Stack { inner: Vec::new() } } pub fn push(&mut self, i: T) { self.inner.push(i); } pub fn pop(&mut self) ->...
code_fim
medium
{ "lang": "rust", "repo": "xiuxiu62/shake-stack", "path": "/src/stack.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stack: Stack<i32> = Stack::new(); assert_eq!( (stack.is_empty(), stack.len(), stack.peek()), (true, 0, None) ); } }<|fim_prefix|>// repo: xiuxiu62/shake-stack path: /src/stack.rs #[derive(Debug, Clone)] pub struct Stack<T> { inner: Vec<T>, } im...
code_fim
hard
{ "lang": "rust", "repo": "xiuxiu62/shake-stack", "path": "/src/stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut stack = Stack::from(vec![1, 2, 3, 4, 5]); for i in 6..11 { stack.push(i); } stack.pop(); let test_case: Vec<i32> = (1..10).collect(); assert_eq!(stack.inner, test_case); } #[test] fn its_empty() { let stack: Stack<i3...
code_fim
hard
{ "lang": "rust", "repo": "xiuxiu62/shake-stack", "path": "/src/stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = adder.compute_par(); println!("result: {:?}", result); }<|fim_prefix|>// repo: harababurel/homework path: /sem5/pdp/bigsum/src/main.rs extern crate bigsum; extern crate rand; extern crate num; use bigsum::adder::Adder; use bigsum::bigint::BigUint; <|fim_middle|> fn main() { let...
code_fim
medium
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harababurel/homework path: /sem5/pdp/bigsum/src/main.rs extern crate bigsum; extern crate rand; extern crate num; use bigsum::adder::Adder; use bigsum::bigint::BigUint; <|fim_suffix|> let mut adder = Adder::new(); adder.push(BigUint::from(1234)); adder.push(BigUint::from(42)); a...
code_fim
easy
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { let mut adder = Adder::new(); adder.push(BigUint::from(1234)); adder.push(BigUint::from(42)); adder.push(BigUint::from(8)); adder.push(BigUint::from(995)); let result = adder.compute_par(); println!("result: {:?}", result); }<|fim_prefix|>// repo: harababurel/home...
code_fim
easy
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 根据每个字符, 创建charNode for cr in split(self.text, true, text_style.text.white_space.preserve_spaces()) { // 如果是单词的结束字符,释放掉当前节点后面的所有兄弟节点, 并将当前节点索引重置为当前节点的父节点的下一个兄弟节点 match cr { SplitResult::Word(c) => { let chars = &mut node_states[id].0.text; let cn = self.create_or_get(c, chars, ch...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_show", "path": "/gui/src/system/text_layout.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let r = self.font_sheet.measure( &self.tex_font.0, self.font_size as usize, self.sw as usize, self.text_style.font.weight, ch, ); CharNode { ch, size: (r.0, self.line_height), margin_start: self.char_margin, pos: (p_x, 0.0), base_width: r.1, ch_id_or_count: 0, } ...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_show", "path": "/gui/src/system/text_layout.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaiaWorld/pi_show path: /gui/src/system/text_layout.rs , TextStyle>; // fn listen(&mut self, event: &CreateEvent, _: Self::ReadData, text_styles: Self::WriteData) { // // node_states[event.id].0.set_vnode(true); // // 如果不存在TextStyle, 默认插入 // // if let None = text_styles.get(event.id) {...
code_fim
hard
{ "lang": "rust", "repo": "GaiaWorld/pi_show", "path": "/gui/src/system/text_layout.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonkgrimes/artichoke path: /artichoke-backend/src/extn/core/integer/mruby.rs use crate::extn::core::integer::trampoline; use crate::extn::core::integer::Integer; use crate::extn::prelude::*; pub fn init(interp: &mut Artichoke) -> InitializeResult<()> { if interp.is_class_defined::<Integer>(...
code_fim
hard
{ "lang": "rust", "repo": "jonkgrimes/artichoke", "path": "/artichoke-backend/src/extn/core/integer/mruby.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe extern "C" fn artichoke_integer_size( mrb: *mut sys::mrb_state, _slf: sys::mrb_value, ) -> sys::mrb_value { mrb_get_args!(mrb, none); let mut interp = unwrap_interpreter!(mrb); let guard = Guard::new(&mut interp); let result = trampoline::size(&guard); match result { ...
code_fim
hard
{ "lang": "rust", "repo": "jonkgrimes/artichoke", "path": "/artichoke-backend/src/extn/core/integer/mruby.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let transformation = match args.next() { Some(arg) => arg, None => return Err("Missing typocase transformation argument."), }; let string = match args.next() { Some(arg) => arg, None => return Err("Missing string to transform argument...
code_fim
hard
{ "lang": "rust", "repo": "mtovmassian/typocase_rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Config { pub fn new(mut args: std::env::Args) -> Result<Config, &'static str> { args.next(); let transformation = match args.next() { Some(arg) => arg, None => return Err("Missing typocase transformation argument."), }; let string = match a...
code_fim
medium
{ "lang": "rust", "repo": "mtovmassian/typocase_rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtovmassian/typocase_rs path: /src/lib.rs pub mod core; use crate::core::str_comps::StringCompounds; use crate::core::spec_chars::SpecChars; pub struct TypoCase { compounds: Vec<String> } impl TypoCase { pub fn new(_string: String) -> TypoCase { return TypoCase { ...
code_fim
hard
{ "lang": "rust", "repo": "mtovmassian/typocase_rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GoXLR-on-Linux/goxlr-utility path: /usb/src/goxlr.rs } debug!("Activating Vendor Interface..."); goxlr.read_control(0, 0, 0, 24)?; // Now activate audio.. debug!("Activating Audio..."); goxlr.write_class_control(1, 0x0100, 0x...
code_fim
hard
{ "lang": "rust", "repo": "GoXLR-on-Linux/goxlr-utility", "path": "/usb/src/goxlr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let date_slice = &result[24..]; let date_len = date_slice .iter() .position(|&c| c == 0) .unwrap_or(date_slice.len()) as usize; let manufacture_date = String::from_utf8_lossy(&date_slice[..date_len]).to_string(); Ok((serial_number, manuf...
code_fim
hard
{ "lang": "rust", "repo": "GoXLR-on-Linux/goxlr-utility", "path": "/usb/src/goxlr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GoXLR-on-Linux/goxlr-utility path: /usb/src/goxlr.rs mut handle: DeviceHandle<T>, device_descriptor: DeviceDescriptor, ) -> Result<Self, ConnectError> { let device = handle.device(); let timeout = Duration::from_secs(1); info!("Connected to possible ...
code_fim
hard
{ "lang": "rust", "repo": "GoXLR-on-Linux/goxlr-utility", "path": "/usb/src/goxlr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(stdout, "")?; writeln!(stdout, "{}:", wage.unit)?; } writeln!(stdout, "{}\t${:.2}", wage.prefix, wage.value)?; } Ok(()) }<|fim_prefix|>// repo: isgasho/wageman path: /src/main.rs mod args; mod wage; mod enumit; use std::env; use std::io::{self, Write}; use std::process; use crate...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wageman", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/wageman path: /src/main.rs mod args; mod wage; mod enumit; use std::env; use std::io::{self, Write}; use std::process; use crate::args::Command; use crate::wage::Wage; fn main() { /// Run wageman with `std::env::args_os`, outputting to stdout. /// Error detail may be outputted to s...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wageman", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: electricherd/audiobookfinder path: /native/adbflib/src/lib.rs //! The adbfbinlib is a LIB and a facade to many modules that interact with //! the audiobookfinder program. //! In this file all crates are name before the modules which use them. #![crate_name = "adbfbinlib"] #![crate_type = "lib"] ...
code_fim
hard
{ "lang": "rust", "repo": "electricherd/audiobookfinder", "path": "/native/adbflib/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// the library interface for returning number of audio files found pub async fn file_count_good(input_path: Vec<String>) -> Result<u32, AdbflibError> { Ok(forwarder::ffi_file_count_good(input_path)) } /// the library interface for returning own peer id pub fn get_own_peer() -> u64 { net::subs::p...
code_fim
medium
{ "lang": "rust", "repo": "electricherd/audiobookfinder", "path": "/native/adbflib/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: misebox/pugrs path: /src/main.rs extern crate lazy_static; extern crate regex; extern crate log; use log::debug; mod input; mod lex; mod parse; mod render; <|fim_suffix|> let args: Vec<String> = std::env::args().skip(1).collect(); // args if args.len() <= 0 { return; } ...
code_fim
medium
{ "lang": "rust", "repo": "misebox/pugrs", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut lexer = lex::Lexer::new(src); lexer.tokenize(); let tokens = lexer.get_tokens(); debug!("Getting tokens done!"); // for token in tokens { // eprintln!("{:?}, {}", token, lexer.token_source(token)); // } let mut parser = parse::Parser::new(tokens); let nodes ...
code_fim
hard
{ "lang": "rust", "repo": "misebox/pugrs", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>static EXPECT_TLS13_SERVER_HELLO_OR_RETRY: State = State { expect: Expectation { content_types: &[ContentType::Handshake], handshake_types: &[HandshakeType::ServerHello, HandshakeType::HelloRetryRequest], }, handle: handle_server_hello_or_retry, }; fn validate_encrypted_extens...
code_fim
hard
{ "lang": "rust", "repo": "kleopatra999/rustls", "path": "/src/client_hs.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kleopatra999/rustls path: /src/client_hs.rs let handshake_hash = sess.handshake_data.transcript.get_current_hash(); let write_key = key_schedule.derive(SecretKind::ClientHandshakeTrafficSecret, &handshake_hash); let read_key = key_schedule.derive(SecretKind::ServerHandshakeTrafficS...
code_fim
hard
{ "lang": "rust", "repo": "kleopatra999/rustls", "path": "/src/client_hs.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kleopatra999/rustls path: /src/client_hs.rs sionTicket).is_some() { info!("Server supports tickets"); sess.handshake_data.must_issue_new_ticket = true; } // See if we're successfully resuming. let mut abbreviated_handshake = false; if let Some(ref resuming) = ses...
code_fim
hard
{ "lang": "rust", "repo": "kleopatra999/rustls", "path": "/src/client_hs.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let expected_output = "\ 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz" .to_string(); assert_eq!(fizz_buzz(15), expected_output); } }<|fim_pre...
code_fim
hard
{ "lang": "rust", "repo": "mrcosta/repl", "path": "/src/main_read_requests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrcosta/repl path: /src/main_read_requests.rs use std::io; macro_rules! read_int( () => {{ let mut line = String::new(); io::stdin().read_line(&mut line).expect("Something went wrong when reading the input."); line.trim().parse::<usize>().expect("Something went wrong...
code_fim
hard
{ "lang": "rust", "repo": "mrcosta/repl", "path": "/src/main_read_requests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vedangj044/drogue-cloud path: /console-backend/src/api.rs use crate::auth::OpenIdClient; use actix_web::{web, HttpRequest}; use anyhow::Context; use drogue_cloud_service_api::endpoints::Endpoints; use serde_json::{json, Value}; use std::borrow::Cow; const SPEC: &str = include_str!("../api/index...
code_fim
medium
{ "lang": "rust", "repo": "vedangj044/drogue-cloud", "path": "/console-backend/src/api.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // server api["servers"] = json!([{ "url": url, "description": "Drogue Cloud API" }]); // SSO let url = client.client.config().authorization_endpoint.clone(); api["security"] = json!([{"Drogue Cloud SSO": []}]); api["components"]["securitySchemes"] = json!({ "Drogue Clo...
code_fim
hard
{ "lang": "rust", "repo": "vedangj044/drogue-cloud", "path": "/console-backend/src/api.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PrimeGoose/f1-api path: /src/nineteen/status.rs //! Decoder for car status packets sent by F1 2019 //! //! F1 2019 is the first game to differentiate between a physical tyre compound (e.g. C1) and a //! visual tyre compound (e.g. hard). This makes it packet format and decoder incompatible with /...
code_fim
hard
{ "lang": "rust", "repo": "PrimeGoose/f1-api", "path": "/src/nineteen/status.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use std::io::Cursor; use assert_approx_eq::assert_approx_eq; use bytes::{BufMut, BytesMut}; use crate::nineteen::status::{decode_statuses, PACKET_SIZE}; use crate::packet::status::{ DrsSetting, ErsDeployMode, FuelMix, PhysicalTyreCompound, TractionCon...
code_fim
hard
{ "lang": "rust", "repo": "PrimeGoose/f1-api", "path": "/src/nineteen/status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn decode_tyre_wear(cursor: &mut Cursor<&mut BytesMut>) -> CornerProperty<u8> { CornerProperty::new( cursor.get_u8(), cursor.get_u8(), cursor.get_u8(), cursor.get_u8(), ) } fn decode_physical_tyre_compound( cursor: &mut Cursor<&mut BytesMut>, ) -> Result<Physic...
code_fim
hard
{ "lang": "rust", "repo": "PrimeGoose/f1-api", "path": "/src/nineteen/status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sean-h/raytracer path: /src/noise/perlin.rs extern crate rand; extern crate tdmath; use self::rand::Rng; use tdmath::Vector3; use std::num::Wrapping; pub struct Perlin { ranvec: Vec<Vector3>, perm_x: Vec<usize>, perm_y: Vec<usize>, perm_z: Vec<usize>, } impl Perlin { pub f...
code_fim
hard
{ "lang": "rust", "repo": "sean-h/raytracer", "path": "/src/noise/perlin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = rand::thread_rng(); for i in (1..n).rev() { let target = (rng.gen::<f32>() * (i as f32 + 1.0)) as usize; let tmp = p[i]; p[i] = p[target]; p[target] = tmp; } } fn perlin_generate_perm() -> Vec<usize> { ...
code_fim
hard
{ "lang": "rust", "repo": "sean-h/raytracer", "path": "/src/noise/perlin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/libs/kata-sys-util/src/mount.rs safety of the `dst` to avoid possible file path based attacks. pub fn bind_remount<P: AsRef<Path>>(dst: P, readonly: bool) -> Result<()> { let dst = dst.as_ref(); if dst.is_empty() { return Err(Error::Nul...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/libs/kata-sys-util/src/mount.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(matches!( bind_remount(PathBuf::from(""), true), Err(Error::NullMountPointPath) )); assert!(matches!( bind_remount(PathBuf::from("../______doesn't____exist____nnn"), true), Err(Error::InvalidPath(_)) )); bind_...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/libs/kata-sys-util/src/mount.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/libs/kata-sys-util/src/mount.rs option line user,exec,dev,suid). // - nouser: Forbid an ordinary user to mount the filesystem. This is the default; it does not // imply any other options. // - users: Allow any user to mount and to unmount ...
code_fim
hard
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/libs/kata-sys-util/src/mount.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DenisVerkhoturov/computer-science path: /src/algorithms/sorting/quicksort.rs /// Quicksort pub fn sort<T: Ord + Clone>(list: &Vec<T>) -> Vec<T> { let mut sorted = list.clone(); quick_sort(&mut sorted, 0, list.len() - 1); return sorted; } <|fim_suffix|> if start >= end { return; }...
code_fim
medium
{ "lang": "rust", "repo": "DenisVerkhoturov/computer-science", "path": "/src/algorithms/sorting/quicksort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if start >= end { return; } let mut left = start; let mut right = end; let mut pivot = (start + end) / 2; while left < right { while left < pivot && list[left] <= list[pivot] { left += 1; } while right > pivot && list[right] >= list[pivot] { right -= 1; } if lef...
code_fim
medium
{ "lang": "rust", "repo": "DenisVerkhoturov/computer-science", "path": "/src/algorithms/sorting/quicksort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn initialize(cfg: Self::Cfg, loss: &mut Loss) -> Self { unimplemented!(); } fn reset(&mut self, loss: &mut Loss, rng: &mut Xorshiftplus128Rng) { //println!("DEBUG: allreduce sgd: rank: {} initializing param...", self.worker_rank); loss.init_param(&mut self.shared_rng); } fn begin_...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/neuralops_cuda", "path": "/src/opt/allreduce_sgd.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterhj/neuralops_cuda path: /src/opt/allreduce_sgd.rs use opt::sgd::*; use densearray::prelude::*; use devicemem_cuda::prelude::*; use devicemem_cuda::coll::*; use operator::prelude::*; use operator::opt::sgd::*; use rng::{RngState}; use rng::xorshift::*; use rand::{Rng, thread_rng}; use std:...
code_fim
hard
{ "lang": "rust", "repo": "peterhj/neuralops_cuda", "path": "/src/opt/allreduce_sgd.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(solution) = days::get_solution(day, lines) { println!("day{}: {}, {}", day, solution.0, solution.1); } else { bail!("Solution for day{} not found", day); } Ok(()) }<|fim_prefix|>// repo: johningve/adventofcode path: /2020/rust/src/main.rs use std::env; use std...
code_fim
medium
{ "lang": "rust", "repo": "johningve/adventofcode", "path": "/2020/rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johningve/adventofcode path: /2020/rust/src/main.rs use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::iter::Iterator; use anyhow::bail; use web::AocClient; #[macro_use] mod solver; mod days; mod util; mod web; fn main() -> anyhow::Result<()> { <|fim_suffix|> let file ...
code_fim
hard
{ "lang": "rust", "repo": "johningve/adventofcode", "path": "/2020/rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let file = File::open(path)?; let lines = io::BufReader::new(file).lines().map(Result::unwrap); if let Some(solution) = days::get_solution(day, lines) { println!("day{}: {}, {}", day, solution.0, solution.1); } else { bail!("Solution for day{} not found", day); } ...
code_fim
hard
{ "lang": "rust", "repo": "johningve/adventofcode", "path": "/2020/rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgrust01/json-surf path: /src/registry.rs Vec::<Term>::with_capacity(schema.mappings.len()); if field_names.is_empty() { return Ok(terms); }; for field_name in field_names { let term = self._build_term(schema, field_name, field_value)?; ...
code_fim
hard
{ "lang": "rust", "repo": "sgrust01/json-surf", "path": "/src/registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let name = random_string(None); let home = ".validate_as_rust_structs".to_string(); let index_path = format!("{}/{}", home, name); let path = Path::new(&index_path); assert!(!path.exists()); let title = "The Old Man and the Sea".to_string(); let bod...
code_fim
hard
{ "lang": "rust", "repo": "sgrust01/json-surf", "path": "/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgrust01/json-surf path: /src/registry.rs ize>(&mut self, name: &str, data: &T) -> Result<(), IndexError> { let data = serde_json::to_string(data)?; let writer = self.writers.get(name); if writer.is_none() { return Ok(()); }; let index = self....
code_fim
hard
{ "lang": "rust", "repo": "sgrust01/json-surf", "path": "/src/registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn initalise() -> Result<RobloxApi, &'static str> { match downloader::get_api_string() { Some(text) => Ok(parser::load_api(&text)), None => Err("failed to find a copy of the roblox api") } }<|fim_prefix|>// repo: AndrewMonteith/rgss path: /src/roblox/mod.rs mod downloader; mod...
code_fim
easy
{ "lang": "rust", "repo": "AndrewMonteith/rgss", "path": "/src/roblox/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewMonteith/rgss path: /src/roblox/mod.rs mod downloader; mod api; mod parser; <|fim_suffix|>pub fn initalise() -> Result<RobloxApi, &'static str> { match downloader::get_api_string() { Some(text) => Ok(parser::load_api(&text)), None => Err("failed to find a copy of the r...
code_fim
easy
{ "lang": "rust", "repo": "AndrewMonteith/rgss", "path": "/src/roblox/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iceboy926/incubator-mesatee path: /mesatee_core/src/rpc/sgx/ra.rs Err(Error::from(ErrorKind::MissingValue)); for header in respp.headers { match header.name { "Content-Length" => { let len_num = mayfail! { len_str =<< String::from_utf...
code_fim
hard
{ "lang": "rust", "repo": "iceboy926/incubator-mesatee", "path": "/mesatee_core/src/rpc/sgx/ra.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> os_rng.fill_bytes(&mut quote_nonce.rand); let mut qe_report = sgx_report_t::default(); const RET_QUOTE_BUF_LEN: u32 = 2048; let mut return_quote_buf: [u8; RET_QUOTE_BUF_LEN as usize] = [0; RET_QUOTE_BUF_LEN as usize]; let mut quote_len: u32 = 0; // (3) Generate the quote // Ar...
code_fim
hard
{ "lang": "rust", "repo": "iceboy926/incubator-mesatee", "path": "/mesatee_core/src/rpc/sgx/ra.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iceboy926/incubator-mesatee path: /mesatee_core/src/rpc/sgx/ra.rs " { fn ocall_sgx_init_quote( ret_val: *mut sgx_status_t, ret_ti: *mut sgx_target_info_t, ret_gid: *mut sgx_epid_group_id_t, ) -> sgx_status_t; fn ocall_get_ias_socket(ret_val: *mut sgx_status_t...
code_fim
hard
{ "lang": "rust", "repo": "iceboy926/incubator-mesatee", "path": "/mesatee_core/src/rpc/sgx/ra.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } #[inline] fn new_object(_: ScriptObject<Self>) -> Self { unimplemented!() } #[inline] fn as_bool(&self) -> Result<bool, &Self> { if let Self::Bool(b) = self { Ok(*b) } else { Err(self) } } #[inline] fn as_integer(&self) -> Result<isize, &Self> { if let Self...
code_fim
hard
{ "lang": "rust", "repo": "Demindiro/ballscript", "path": "/lib/src/variant/specialized/copy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Demindiro/ballscript path: /lib/src/variant/specialized/copy.rs // Copyright (C) 2021 David Hoppenbrouwers // // This file is licensed under the MIT license. See script/LICENSE for details. #[cfg(not(feature = "std"))] use crate::std_types::*; use crate::{CallError, CallResult, Environment, Rc...
code_fim
hard
{ "lang": "rust", "repo": "Demindiro/ballscript", "path": "/lib/src/variant/specialized/copy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eiz/winapi-rs-ex path: /src/um/d3d10.rs // 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 option. // All files in the project carrying such notice ...
code_fim
hard
{ "lang": "rust", "repo": "eiz/winapi-rs-ex", "path": "/src/um/d3d10.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} DEFINE_GUID! {IID_ID3D10SamplerState, 0x9b7e4c0c, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} DEFINE_GUID! {IID_ID3D10Asynchronous, 0x9b7e4c0d, 0x342c, 0x4106, 0xa1, 0x9f, 0x4f, 0x27, 0x04, 0xf6, 0x89, 0xf0} DEFINE_GUID! {IID_ID3D10Query, 0x9b...
code_fim
hard
{ "lang": "rust", "repo": "eiz/winapi-rs-ex", "path": "/src/um/d3d10.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !number.last().unwrap().is_ascii_digit() { return Err(self.error_at(ERROR_NUMBER_END_WITH_NON_NUMERIC, self.forward - 1)); } if !point && number.starts_with(&['0']) { return Err(self.error_at(ERROR_NUMBER_START_WITH_ZERO, self.index - 1)); } ...
code_fim
hard
{ "lang": "rust", "repo": "chikaku/simple_calculator_cmd", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chikaku/simple_calculator_cmd path: /src/lexer.rs use crate::token::{ArithOperator, Bracket, Token}; use core::result; use std::fmt::{Display, Formatter}; use std::option::Option::Some; #[derive(Default)] pub struct Lexer { index: usize, forward: usize, source: Vec<char>, } pub str...
code_fim
hard
{ "lang": "rust", "repo": "chikaku/simple_calculator_cmd", "path": "/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.index += 1; self.forward = self.index; self.get_char(self.index - 1) } fn current_char(&self) -> char { self.get_char(self.index - 1) .expect("current_char should call at valid index") } fn forward_char(&mut self) -> Option<char> { ...
code_fim
hard
{ "lang": "rust", "repo": "chikaku/simple_calculator_cmd", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GiantPlantsSociety/diamond path: /diamond-api/src/render_target/mod.rs pub mod ast; mod parser; pub use ast::*; pub use std::convert::TryFrom; pub use std::str::FromStr; #[cfg(test)] mod tests { use super::*; #[test] fn test_from_str() { let _ex: ast::Expression = "templat...
code_fim
hard
{ "lang": "rust", "repo": "GiantPlantsSociety/diamond", "path": "/diamond-api/src/render_target/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn pathword_to_regex() { assert_eq!( PathExpression::from_str("just_a_metric").unwrap().0[0] .to_regex_pattern() .unwrap(), "^(just_a_metric)$" ); assert_eq!( PathExpression::from_str("host*.cpu").u...
code_fim
hard
{ "lang": "rust", "repo": "GiantPlantsSociety/diamond", "path": "/diamond-api/src/render_target/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( PathExpression::from_str("just_a_metric").unwrap().0[0] .to_regex_pattern() .unwrap(), "^(just_a_metric)$" ); assert_eq!( PathExpression::from_str("host*.cpu").unwrap().0[0] .to_regex_pa...
code_fim
hard
{ "lang": "rust", "repo": "GiantPlantsSociety/diamond", "path": "/diamond-api/src/render_target/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gauteh/dars path: /dars-catalog/src/lib.rs use lazy_static::lazy_static; use rust_embed::RustEmbed; use std::sync::Arc; use tera::Tera; use warp::Filter; mod filters; mod handlers; #[derive(RustEmbed)] #[folder = "src/templates/"] struct Templates; /// Builds a catalog with root-url `url`. Th...
code_fim
hard
{ "lang": "rust", "repo": "gauteh/dars", "path": "/dars-catalog/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> catalog("http://localhost:8001".into(), TestCatalog::test()).unwrap(); } #[test] fn does_not_match_data_source() { let f = catalog("http://localhost:8001".into(), TestCatalog::test()).unwrap(); assert_eq!( block_on( warp::test::request() ...
code_fim
hard
{ "lang": "rust", "repo": "gauteh/dars", "path": "/dars-catalog/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn does_not_match_data_source() { let f = catalog("http://localhost:8001".into(), TestCatalog::test()).unwrap(); assert_eq!( block_on( warp::test::request() .method("GET") .path("/data/coads1.nc") ...
code_fim
hard
{ "lang": "rust", "repo": "gauteh/dars", "path": "/dars-catalog/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> NodeStorage { max_nodes, q_nodes, primitive_nodes, } } }<|fim_prefix|>// repo: phigley/taxi path: /src/maxq/nodestorage.rs use crate::world::World; use crate::maxq::maxnode::MaxNode; use crate::maxq::primitivenode::PrimitiveNode; use crate::maxq::q...
code_fim
hard
{ "lang": "rust", "repo": "phigley/taxi", "path": "/src/maxq/nodestorage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phigley/taxi path: /src/maxq/nodestorage.rs use crate::world::World; use crate::maxq::maxnode::MaxNode; use crate::maxq::primitivenode::PrimitiveNode; use crate::maxq::qnode::QNode; #[derive(Debug, Clone)] pub struct NodeStorage { pub max_nodes: Vec<MaxNode>, pub q_nodes: Vec<QNode>, ...
code_fim
hard
{ "lang": "rust", "repo": "phigley/taxi", "path": "/src/maxq/nodestorage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (FolderController) => { crate::controllers::FolderController }; (UserController) => { crate::controllers::UserController }; }<|fim_prefix|>// repo: duzhanyuan/rs_netdisk path: /src/di.rs macro_rules! resolve { (FileService) => { crate::services::file::implemen...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/rs_netdisk", "path": "/src/di.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/rs_netdisk path: /src/di.rs macro_rules! resolve { (FileService) => { crate::services::file::implementation::Service }; <|fim_suffix|> (UserController) => { crate::controllers::UserController }; }<|fim_middle|> (FolderService) => { crate::ser...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/rs_netdisk", "path": "/src/di.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/lumen path: /compiler/codegen/src/mlir/builder/ops/builders/map.rs use super::*; pub struct MapBuilder; impl MapBuilder { pub fn build<'f, 'o>( builder: &mut ScopedFunctionBuilder<'f, 'o>, ir_value: Option<ir::Value>, op: Map, ) -> Result<Option<Value>>...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/codegen/src/mlir/builder/ops/builders/map.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let map = builder.new_value(ir_value, map_ref, ValueDef::Result(0)); Ok(Some(map)) } } pub struct MapPutBuilder; impl MapPutBuilder { pub fn build<'f, 'o>( builder: &mut ScopedFunctionBuilder<'f, 'o>, mut op: MapPuts, ) -> Result<Option<Value>> { let a...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/codegen/src/mlir/builder/ops/builders/map.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srijs/rust-cfn path: /src/aws/codebuild.rs pAccess::next_value(&mut map)?; } "Webhook" => { webhook = ::serde::de::MapAccess::next_value(&mut map)?; } _...
code_fim
hard
{ "lang": "rust", "repo": "srijs/rust-cfn", "path": "/src/aws/codebuild.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: srijs/rust-cfn path: /src/aws/codebuild.rs elf::project::ProjectSourceVersion>> = None; let mut secondary_sources: Option<::ValueList<self::project::Source>> = None; let mut service_role: Option<::Value<String>> = None; let mut source: Option<::Val...
code_fim
hard
{ "lang": "rust", "repo": "srijs/rust-cfn", "path": "/src/aws/codebuild.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut map = ::serde::Serializer::serialize_map(s, None)?; if let Some(ref security_group_ids) = self.security_group_ids { ::serde::ser::SerializeMap::serialize_entry(&mut map, "SecurityGroupIds", security_group_ids)?; } if let Some(ref subn...
code_fim
hard
{ "lang": "rust", "repo": "srijs/rust-cfn", "path": "/src/aws/codebuild.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomas9911/openstack-client path: /src/structs.rs use std::collections::HashMap; use std::io::{Error, ErrorKind}; use utils::{convert_to_multiple, compare_different_cases, get_first_value_from_hashmap_with_vec}; use error::OpenstackError; #[derive(Debug, Serialize, Deserialize)] pub struct Re...
code_fim
hard
{ "lang": "rust", "repo": "thomas9911/openstack-client", "path": "/src/structs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for res in self.map.values_mut(){ if let ResourceTypeEnum::String(x) = res.resource_type.clone(){ if let Some(y) = resource_types.get(&x){ res.resource_type = y.clone(); } } } self.types = resource_types; ...
code_fim
hard
{ "lang": "rust", "repo": "thomas9911/openstack-client", "path": "/src/structs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let discriminant = hb * hb - a * c; if discriminant < 0.0 { None } else { for tc in &[ (-hb - discriminant.sqrt()) / a, (-hb + discriminant.sqrt()) / a, ] { if *tc <= t.end && *tc >= t.start { ...
code_fim
hard
{ "lang": "rust", "repo": "Joonardo/sade", "path": "/src/primitive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let t = f * Vec3::dot(edge2, q); if t_range.start <= t && t <= t_range.end { let (n1, n2, n3) = self.normals; Some(HitRecord::new( ray, t, n1 * (1. - u - v) + u * n2 + v * n3, Vec3::new(u, v, 0.), ...
code_fim
hard
{ "lang": "rust", "repo": "Joonardo/sade", "path": "/src/primitive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Joonardo/sade path: /src/primitive.rs use crate::math::{Mat4, Vec3, Vec4}; use crate::ray::Ray; use crate::aabb::AABB; use crate::material::Material; use crate::EPSILON; use std::ops::Range; use std::sync::Arc; #[derive(Clone)] pub struct HitRecord<'m> { t: f32, point: Vec3, normal...
code_fim
hard
{ "lang": "rust", "repo": "Joonardo/sade", "path": "/src/primitive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(archiver.stats.writes, 12); let data: Vec<u8> = vec![4, 0, 0, 0, 0, 0, 0, 0, 116, 101, 115, 116]; assert_eq!(*archiver.data(), data); // Clean up fs::remove_file(filename); } #[test] fn test_archiver_deserialize() { let filename = format!("{}-{}", ARCHIVER_TEST_FILE, ...
code_fim
hard
{ "lang": "rust", "repo": "ReflectiveIO/mirror", "path": "/tests/rays/utils/archiver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ReflectiveIO/mirror path: /tests/rays/utils/archiver.rs #![allow(unused_must_use)] use std::fs; use mirror::rays::utils::Archiver; use mirror::slg::State; const ARCHIVER_TEST_FILE: &str = "tests/rays/utils/test-archiver-state"; #[test] fn test_archiver_open() { let filename = format!("{}...
code_fim
hard
{ "lang": "rust", "repo": "ReflectiveIO/mirror", "path": "/tests/rays/utils/archiver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: masonblier/wine-som path: /src/main.rs extern crate clap; extern crate csv; extern crate ndarray; extern crate ndarray_csv; extern crate rusticsom; use clap::{App}; use csv::{ReaderBuilder}; use ndarray::prelude::*; use ndarray_csv::{Array2Reader}; use rusticsom::*; use std::collections::HashMa...
code_fim
hard
{ "lang": "rust", "repo": "masonblier/wine-som", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } // end Ok(()) } /// helper function to find the most common value of a vec fn mcv(numbers: &Vec<u32>) -> u32 { // counts values using a hashmap let mut map = HashMap::new(); for integer in numbers { let count = map.entry(integer).or_insert(0); *count += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "masonblier/wine-som", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meonal/competitive-rs path: /src/io.rs use std::io::Read; use std::str::FromStr; /// Input scanner /// /// # Examples /// /// ``` /// # use competitive::io::*; /// let mut sc = Scanner::new("1 3.14 Hello"); /// assert_eq!(sc.next::<i32>(), 1); /// assert_eq!(sc.next::<f64>(), 3.14); /// assert_...
code_fim
medium
{ "lang": "rust", "repo": "meonal/competitive-rs", "path": "/src/io.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.next()).collect() } } /// Read whole stdin content to string pub fn read_string() -> String { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s } /// Read one line fr...
code_fim
hard
{ "lang": "rust", "repo": "meonal/competitive-rs", "path": "/src/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Read one line from stdin to string pub fn read_line() -> String { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim_end().to_owned() }<|fim_prefix|>// repo: meonal/competitive-rs path: /src/io.rs use std::io::Read; use std::str::FromStr; /// Input scanner ///...
code_fim
medium
{ "lang": "rust", "repo": "meonal/competitive-rs", "path": "/src/io.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azazdeaz/good-bug path: /drivers/src/lib.rs mod wheels; pub use wheels::Wheels; <|fim_suffix|>mod cooling_fan; pub use cooling_fan::CoolingFan;<|fim_middle|>mod system_info; pub use system_info::SystemInfo; mod weeder; pub use weeder::Weeder;
code_fim
medium
{ "lang": "rust", "repo": "azazdeaz/good-bug", "path": "/drivers/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod cooling_fan; pub use cooling_fan::CoolingFan;<|fim_prefix|>// repo: azazdeaz/good-bug path: /drivers/src/lib.rs mod wheels; pub use wheels::Wheels; <|fim_middle|>mod system_info; pub use system_info::SystemInfo; mod weeder; pub use weeder::Weeder;
code_fim
medium
{ "lang": "rust", "repo": "azazdeaz/good-bug", "path": "/drivers/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let len = unpacker.unpack_array_header().unwrap(); assert_eq!(len, 2); assert_eq!(unpacker.unpack_u8().unwrap(), 1); assert_eq!(unpacker.unpack_u8().unwrap(), 2); let len = unpacker.unpack_map_header().unwrap(); assert_eq!(len, 1); assert_eq!(unpacker.unpack_u8().unwrap(), 1);...
code_fim
hard
{ "lang": "rust", "repo": "ganmacs/msgpack-rs", "path": "/msgpack-core/tests/unpacker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(unpacker.unpack_nil().unwrap(), None as Option<usize>); assert_eq!(unpacker.unpack_bool().unwrap(), false); assert_eq!(unpacker.unpack_u8().unwrap(), 1); assert_eq!(unpacker.unpack_i8().unwrap(), -1); let len = unpacker.unpack_array_header().unwrap(); assert_eq!(len, 2)...
code_fim
medium
{ "lang": "rust", "repo": "ganmacs/msgpack-rs", "path": "/msgpack-core/tests/unpacker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ganmacs/msgpack-rs path: /msgpack-core/tests/unpacker.rs use msgpack::{self, MessageUnpacker}; use std::io; #[test] fn unpacker() { let mut reader = io::Cursor::new(vec![ 0xc0, 0xc2, 0x01, 0xff, 0x92, 0x01, 0x02, 0x81, 0x01, 0xa1, 0x73, ]); <|fim_suffix|> let len = unpacker....
code_fim
hard
{ "lang": "rust", "repo": "ganmacs/msgpack-rs", "path": "/msgpack-core/tests/unpacker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut line = String::new(); let stdin = io::stdin(); for _ in 0..3 { let _ = stdin.lock().read_line(&mut line); let _ = tx.send(()); } }<|fim_prefix|>// repo: palmtoy/Exercise path: /Rust/thread_test/src/main.rs extern crate chrono; use chrono::offset::Local; use chrono:...
code_fim
hard
{ "lang": "rust", "repo": "palmtoy/Exercise", "path": "/Rust/thread_test/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }