text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: joshuawarner32/rsdiff path: /reduce/src/lib.rs extern crate rand; use rand::Rng; pub fn reduce_step<R: Rng, F: Fn(&[u8]) -> bool>(rng: &mut R, data: &[u8], f: F, limit: usize) -> Option<Vec<u8>> { if data.len() == 0 { return None; } let mut trial0 = Vec::with_capacity(dat...
code_fim
hard
{ "lang": "rust", "repo": "joshuawarner32/rsdiff", "path": "/reduce/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_reduce() { assert_eq!( reduce( &mut thread_rng(), b"this is a test", |data| { data.iter().any(|b| {*b == b'a' as u8}) }, 20), b"a"); } #[test] fn test_reduce_each() { ...
code_fim
hard
{ "lang": "rust", "repo": "joshuawarner32/rsdiff", "path": "/reduce/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> trial0 } pub fn reduce_each<R: Rng, T: PartialEq, F: Fn(&[Vec<u8>]) -> T>(rng: &mut R, data: &[Vec<u8>], f: F, limit: usize) -> Vec<Vec<u8>> { let reference = f(data); let mut trial0 = data.iter().map(|e|{e.clone()}).collect::<Vec<_>>(); loop { let mut updated = 0; for i...
code_fim
hard
{ "lang": "rust", "repo": "joshuawarner32/rsdiff", "path": "/reduce/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b.iter(|| { for i in 100..110 { test_from_file(&format!("testdata/{:02}.a", i), Version::V2); } }); } #[bench] fn large_tests_2(b: &mut Bencher) { b.iter(|| { for i in 110..120 { test_from_file(&format!("testdata/{:02}.a", i), Version::V2); ...
code_fim
hard
{ "lang": "rust", "repo": "saglam/big-rust-preschool", "path": "/bench.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saglam/big-rust-preschool path: /bench.rs #![feature(test)] extern crate test; use atoi::atoi; use molecules; use std::fs::File; use std::io::{BufRead, BufReader}; use test::Bencher; fn test_from_file(answer_file: &str, version: Version) { let question_file = &answer_file[..answer_file.le...
code_fim
hard
{ "lang": "rust", "repo": "saglam/big-rust-preschool", "path": "/bench.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[bench] fn small_tests_1(b: &mut Bencher) { b.iter(|| { for i in 1..100 { test_from_file(&format!("testdata/{:02}.a", i), Version::V1); } }); } #[bench] fn medium_tests_1(b: &mut Bencher) { b.iter(|| { for i in 100..110 { test_from_file(&format...
code_fim
hard
{ "lang": "rust", "repo": "saglam/big-rust-preschool", "path": "/bench.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pnkfelix/rust path: /library/alloc/tests/thin_box.rs use core::mem::size_of; use std::boxed::ThinBox; #[test] fn want_niche_optimization() { fn uses_niche<T: ?Sized>() -> bool { <|fim_suffix|>#[test] fn want_thin() { fn is_thin<T: ?Sized>() -> bool { size_of::<*const ()>() == si...
code_fim
medium
{ "lang": "rust", "repo": "pnkfelix/rust", "path": "/library/alloc/tests/thin_box.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> size_of::<*const ()>() == size_of::<ThinBox<T>>() } trait Tr {} assert!(is_thin::<dyn Tr>()); assert!(is_thin::<[i32]>()); assert!(is_thin::<i32>()); }<|fim_prefix|>// repo: pnkfelix/rust path: /library/alloc/tests/thin_box.rs use core::mem::size_of; use std::boxed::ThinBox; ...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/rust", "path": "/library/alloc/tests/thin_box.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: he-la/rust_swig path: /macroslib/src/cpp/map_type.rs ); Ok(None) } fn foreign_class_foreign_name<'a>( sess: &'a ParseSess, conv_map: &TypesConvMap, foreign_class: &ForeignerClassInfo, foreign_class_span: Span, readonly_fptr: bool, ) -> PResult<'a, ForeignTypeInfo> { ...
code_fim
hard
{ "lang": "rust", "repo": "he-la/rust_swig", "path": "/macroslib/src/cpp/map_type.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#ifdef __cplusplus namespace {namespace_name} {{ using {vec_type} = RustForeignVec<{class}Ref, CRustForeignVec, {free_mem_func}>; }} }} #endif "##, free_mem_func = free_mem_func, namespace_name = cpp_cfg.namespace_name, vec_type = typename, ...
code_fim
hard
{ "lang": "rust", "repo": "he-la/rust_swig", "path": "/macroslib/src/cpp/map_type.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#ifdef __cplusplus extern "C" {{ #endif void {free_mem_func}(struct CRustForeignVec); #ifdef __cplusplus namespace {namespace_name} {{ using {vec_type} = RustForeignVec<{class}Ref, CRustForeignVec, {free_mem_func}>; }} }} #endif "##, free_mem_func = free_mem_func, namespac...
code_fim
hard
{ "lang": "rust", "repo": "he-la/rust_swig", "path": "/macroslib/src/cpp/map_type.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let res = client.delete("unstored").run().await; assert_eq!(res.is_ok(), true); } rt.block_on(example()); } #[test] fn test_delete_item_with_condition() { let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/raiden-dynamo", "path": "/raiden/tests/all/delete.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_delete_item_with_condition() { let rt = tokio::runtime::Runtime::new().unwrap(); async fn example() { let client = DeleteTest0::client(Region::Custom { endpoint: "http://localhost:8000".into(), name: "ap-northeast-1".into(...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/raiden-dynamo", "path": "/raiden/tests/all/delete.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/raiden-dynamo path: /raiden/tests/all/delete.rs #[cfg(test)] mod tests { #[cfg(test)] use pretty_assertions::assert_eq; use raiden::*; #[derive(Raiden, Debug, Clone)] pub struct DeleteTest0 { #[raiden(partition_key)] id: String, name: String,...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/raiden-dynamo", "path": "/raiden/tests/all/delete.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maelstrom-rs/maelstrom path: /src/server/handlers/profile.rs use std::convert::{TryFrom, From}; use actix_web::{ http::StatusCode, web::{Data, Path}, Error, HttpRequest, HttpResponse}; use ruma_identifiers::UserId; use crate::{ models::profile as profile_model, db::Store, ...
code_fim
hard
{ "lang": "rust", "repo": "maelstrom-rs/maelstrom", "path": "/src/server/handlers/profile.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let expected_body = profile_model::DisplayNameResponse { displayname: String::from("testDisplayName"), }; let body: profile_model::DisplayNameResponse = serde_json::from_slice(&test::read_body(resp).await) .unwrap_or_else(|_| panic!("Couldn't deseri...
code_fim
medium
{ "lang": "rust", "repo": "maelstrom-rs/maelstrom", "path": "/src/server/handlers/profile.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn answer2() { let res: i32 = read_modules().map(fuel).sum(); println!("{}", res); } fn fuel(module_mass: i32) -> i32 { let mut mass = module_mass; let mut required_fuel = 0; while mass > 0 { mass = cmp::max(mass / 3 - 2, 0); required_fuel += mass; } requir...
code_fim
medium
{ "lang": "rust", "repo": "geekingfrog/advent-of-code-rust", "path": "/src/y2019/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geekingfrog/advent-of-code-rust path: /src/y2019/day01.rs use std::cmp; use std::fs::File; use std::io::BufRead; use std::io::BufReader; pub fn answer1() { let res: i32 = read_modules().map(|x| (x / 3) - 2).sum(); println!("{}", res); } pub fn answer2() { let res: i32 = read_module...
code_fim
hard
{ "lang": "rust", "repo": "geekingfrog/advent-of-code-rust", "path": "/src/y2019/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f = File::open("data/2019/day01.txt").unwrap(); let fd = BufReader::new(f); fd.lines() .map(|x| i32::from_str_radix(&x.unwrap(), 10).unwrap()) }<|fim_prefix|>// repo: geekingfrog/advent-of-code-rust path: /src/y2019/day01.rs use std::cmp; use std::fs::File; use std::io::BufRead; u...
code_fim
hard
{ "lang": "rust", "repo": "geekingfrog/advent-of-code-rust", "path": "/src/y2019/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scifi6546/gameboy_emulator path: /gameboy_core/src/gpu/lcd_control_flag.rs use bitflags::bitflags; bitflags! { pub struct LcdControlFlag : u8 { const BACKGROUND = 0b0000_0001; const SPRITES = 0b0000_0010; const SPRITES_SIZE = 0b0000_...
code_fim
medium
{ "lang": "rust", "repo": "scifi6546/gameboy_emulator", "path": "/gameboy_core/src/gpu/lcd_control_flag.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 0b0010_0000; const WINDOW_TILE_MAP = 0b0100_0000; const DISPLAY = 0b1000_0000; } }<|fim_prefix|>// repo: scifi6546/gameboy_emulator path: /gameboy_core/src/gpu/lcd_control_flag.rs use bitflags::bitflags; bitflags! { pub struct LcdControlFlag : u8 { co...
code_fim
hard
{ "lang": "rust", "repo": "scifi6546/gameboy_emulator", "path": "/gameboy_core/src/gpu/lcd_control_flag.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>KGROUND_TILE_MAP = 0b0000_1000; const BACKGROUND_TILE_SET = 0b0001_0000; const WINDOW = 0b0010_0000; const WINDOW_TILE_MAP = 0b0100_0000; const DISPLAY = 0b1000_0000; } }<|fim_prefix|>// repo: scifi6546/gameboy_emulator path: /gam...
code_fim
medium
{ "lang": "rust", "repo": "scifi6546/gameboy_emulator", "path": "/gameboy_core/src/gpu/lcd_control_flag.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let b = s.as_bytes(); let n = b.len(); if n == 0 { return '\0'; } b[n - 1] as char }<|fim_prefix|>// repo: qeedquan/challenges path: /codegolf/print-last-inputted-byte.rs /* Challenge You have one string of input bytes, output the last byte in it. <|fim_middle|>Rules Your su...
code_fim
hard
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/codegolf/print-last-inputted-byte.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qeedquan/challenges path: /codegolf/print-last-inputted-byte.rs /* Challenge You have one string of input bytes, output the last byte in it. Rules Your submission may be a program or function outputting the last byte in the input which is either a string, stdin or command-line arguments, and ...
code_fim
medium
{ "lang": "rust", "repo": "qeedquan/challenges", "path": "/codegolf/print-last-inputted-byte.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn ssh_forward_string(config: &Config) -> String { format!("ssh -NCR {remoteport}:localhost:{localport} {ssh}", remoteport=config.remoteport.unwrap(), localport=config.localport, ssh=config.ssh) } fn server_create_site(config: &Config) -> Result<bool, Box<Error>>{ let cmd = format!("ssh {ssh} \"/usr/...
code_fim
hard
{ "lang": "rust", "repo": "piceaTech/rust-zunder", "path": "/client/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piceaTech/rust-zunder path: /client/src/main.rs use std::process::exit; use std::error::Error; use std::env; use std::process::Command; // use std::fs::File; // use std::io::prelude::*; use std::io::SeekFrom; use std::fs::OpenOptions; use std::io::prelude::*; use serde::{Deserialize, Seri...
code_fim
hard
{ "lang": "rust", "repo": "piceaTech/rust-zunder", "path": "/client/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SymmetricChaos/project_euler_rust path: /src/worked_problems/euler_62.rs // Problem: Find the smallest cube for which exactly five permutations of its digits are cubes. /* Iterating through permutations of cubes is not feasible in this case. However we don't need to do that. Instead we can hash ...
code_fim
hard
{ "lang": "rust", "repo": "SymmetricChaos/project_euler_rust", "path": "/src/worked_problems/euler_62.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn euler62() -> u64 { // Start with five because the cube must have at least three digits let mut n = 5; let mut known_cubes: HashMap<String,Vec<u64>> = HashMap::new(); loop { let cube = n*n*n; let mut digits = int_to_digits(cube,10); digits.sort(); let ...
code_fim
hard
{ "lang": "rust", "repo": "SymmetricChaos/project_euler_rust", "path": "/src/worked_problems/euler_62.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn linked_dialog( &self, call_id: &str, server_tag: &str, client_tag: &str, ) -> Option<&Dialog> { self.dialog(call_id, server_tag, client_tag) .and_then(|d| self.dialog_by_id(d.linked_dialog)) } pub fn take_incomplete_dialog( ...
code_fim
hard
{ "lang": "rust", "repo": "KalitaAlexey/sip_server", "path": "/src/components/dialogs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KalitaAlexey/sip_server path: /src/components/dialogs.rs #[derive(Debug)] pub struct DialogInfo { call_id: String, server_tag: String, client_tag: String, } impl DialogInfo { pub fn new(call_id: String, server_tag: String, client_tag: String) -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "KalitaAlexey/sip_server", "path": "/src/components/dialogs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn take_incomplete_dialog( &mut self, call_id: &str, server_tag: &str, ) -> Option<IncompleteDialog> { if let Some(index) = self .incomplete_dialogs .iter() .position(|d| d.call_id == call_id && d.server_tag == server_tag) ...
code_fim
hard
{ "lang": "rust", "repo": "KalitaAlexey/sip_server", "path": "/src/components/dialogs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = web_rt.block_on(start_servers(mock_server_context, admin_server_context)); web_rt.shutdown_timeout(Duration::from_secs(1)); // Can't shutdown loading_rt as shutdown_timeout need to move value and we can't anymore since we are sharing via Arc this Runtime ... // loading_rt.shut...
code_fim
hard
{ "lang": "rust", "repo": "dcuenot/dhall-mock", "path": "/src/bin/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcuenot/dhall-mock path: /src/bin/main.rs extern crate dhall_mock; use anyhow::{anyhow, Context, Error}; use log::{info, warn}; use signal_hook::iterator::Signals; use std::sync::{Arc, RwLock}; use std::time::Duration; use dhall_mock::mock::service::{add_configuration, SharedState, State}; us...
code_fim
hard
{ "lang": "rust", "repo": "dcuenot/dhall-mock", "path": "/src/bin/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(&mut self) { unsafe { ALive2DModel_update(self.get_ptr()) } } pub fn draw(&mut self) { unsafe { ALive2DModel_draw(self.get_ptr()) } } pub fn getCanvasWidth(&self) -> c_float { unsafe { ALive2DModel_getCanvasWidth(self.get_ptr()) } } pub ...
code_fim
hard
{ "lang": "rust", "repo": "azyobuzin/rust-live2dd3d11", "path": "/live2dd3d11-sys/src/a_live2d_model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn setParamFloat(&mut self, paramID: &CStr, value: c_float) { self.setParamFloatWithWeight(paramID, value, 1.0) } pub fn update(&mut self) { unsafe { ALive2DModel_update(self.get_ptr()) } } pub fn draw(&mut self) { unsafe { ALive2DModel_draw(self.get_ptr()...
code_fim
hard
{ "lang": "rust", "repo": "azyobuzin/rust-live2dd3d11", "path": "/live2dd3d11-sys/src/a_live2d_model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azyobuzin/rust-live2dd3d11 path: /live2dd3d11-sys/src/a_live2d_model.rs use super::*; use std::ffi::CStr; use winapi::{c_char, c_float}; extern { fn ALive2DModel_getParamFloat(p: LDObjectPtr, paramID: *const c_char) -> c_float; fn ALive2DModel_setParamFloat(p: LDObjectPtr, paramID: *co...
code_fim
medium
{ "lang": "rust", "repo": "azyobuzin/rust-live2dd3d11", "path": "/live2dd3d11-sys/src/a_live2d_model.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(complete_binary_tree(6) == Node(1, ~Node(2, ~Node(4, ~Empty, ~Empty), ~Node(5, ~Empty, ~Empty)), ~Node(3, ~Node(6, ~Empty, ~Empty), ~Em...
code_fim
hard
{ "lang": "rust", "repo": "rjosephwright/99-Problems-Rust", "path": "/61-70/p63.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rjosephwright/99-Problems-Rust path: /61-70/p63.rs #[deriving(Eq)] enum BinaryTree<T> { Node(T, ~BinaryTree<T>, ~BinaryTree<T>), Empty } <|fim_suffix|> if start > n { Empty } else if 2*start + 1 > n { Node(start, ~aux(2*start, n), ...
code_fim
hard
{ "lang": "rust", "repo": "rjosephwright/99-Problems-Rust", "path": "/61-70/p63.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>impl A { #[async_stream(item = i32)] pub async fn take_self(self) { yield self.0 } #[async_stream(item = i32)] pub async fn take_boxed_self(self: Box<Self>) { yield self.0 } } #[test] fn test() { // https://github.com/alexcrichton/futures-await/issues/45 #...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/futures-async-stream", "path": "/tests/async_stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/futures-async-stream path: /tests/async_stream.rs #![warn(rust_2018_idioms)] #![feature(async_await, generators, stmt_expr_attributes, proc_macro_hygiene)] use futures::{executor::block_on, future, stream}; use futures_async_stream::{async_stream, async_stream_block, for_await}; #[asyn...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/futures-async-stream", "path": "/tests/async_stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmzint/carousel path: /src/render/client/instance.rs use crate::asset::{AssetId, Strong}; use crate::render::canvas::RawInstance; use crate::render::client::{CanvasLayer, LayerSpawner, RenderDefaults}; use crate::render::mesh::Mesh; use crate::render::message::{InstanceEvent, InstanceEventKind};...
code_fim
hard
{ "lang": "rust", "repo": "tmzint/carousel", "path": "/src/render/client/instance.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn deref(&self) -> &Self::Target { &self.raw } } impl Clone for Instance { #[inline] fn clone(&self) -> Self { let id = Uuid::new_v4(); if !self.hidden { self.sender.send(InstanceEvent { id, layer: self.lay...
code_fim
hard
{ "lang": "rust", "repo": "tmzint/carousel", "path": "/src/render/client/instance.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn open_log(&self) -> Result<File, io::Error> { use chrono::UTC; // I was going to write a test for this unwrap call, but, honestly, I figure everyone // and their dog knows that this particular format specifier is fine... let path = self.log_path.as_ref().ok_or_else(|...
code_fim
hard
{ "lang": "rust", "repo": "archer884/watcher", "path": "/src/watcher/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: archer884/watcher path: /src/watcher/mod.rs mod commands; mod responder; use command::Command; use config::{Config, User, Server}; use eirsee::message::OutgoingMessage; use greetings::Greeting; use notifications::{NotificationService, Sms}; use std::cell::Cell; use std::collections::HashSet; us...
code_fim
hard
{ "lang": "rust", "repo": "archer884/watcher", "path": "/src/watcher/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kazinad/game_of_life path: /src/cellgrid/cellgrid_slice_iterator.rs use super::*; impl CellGridSlice<'_> { pub fn iter(&self) -> CellGridSliceIterator { CellGridSliceIterator { indexer: Indexer::new(self.indexer.width, self.indexer.height, self.indexer.offset), ...
code_fim
medium
{ "lang": "rust", "repo": "kazinad/game_of_life", "path": "/src/cellgrid/cellgrid_slice_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let c = self.current; self.current += 1; if c < self.len { return Some(self.indexer.pos(c)); } None } }<|fim_prefix|>// repo: kazinad/game_of_life path: /src/cellgrid/cellgrid_slice_iterator.rs use super::*; impl CellGridSlice<'_> { pub fn iter...
code_fim
medium
{ "lang": "rust", "repo": "kazinad/game_of_life", "path": "/src/cellgrid/cellgrid_slice_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Iterator for CellGridSliceIterator { type Item = (usize, usize); fn next(&mut self) -> Option<Self::Item> { let c = self.current; self.current += 1; if c < self.len { return Some(self.indexer.pos(c)); } None } }<|fim_prefix|>// repo: ka...
code_fim
medium
{ "lang": "rust", "repo": "kazinad/game_of_life", "path": "/src/cellgrid/cellgrid_slice_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// # OpenExtendedMiningChannel.Success (Server -> Client) /// Sent as a response for opening an extended channel. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OpenExtendedMiningChannelSuccess<'decoder> { /// Client-specified request ID from OpenStandardMiningChannel message, /// so ...
code_fim
hard
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/subprotocols/mining/src/open_channel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: incker/stratum path: /protocols/v2/subprotocols/mining/src/open_channel.rs #[cfg(not(feature = "with_serde"))] use alloc::vec::Vec; #[cfg(not(feature = "with_serde"))] use binary_sv2::binary_codec_sv2; use binary_sv2::{Deserialize, Serialize, Str0255, Str032, B032, U256}; /// # OpenStandardMini...
code_fim
hard
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/subprotocols/mining/src/open_channel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> env_logger::init(); let path = std::env::args().nth(1).unwrap(); let file = File::<Vec<u8>>::open(&path).unwrap(); let view = PdfView::new(file); show(view, Config { zoom: true, pan: true }); }<|fim_prefix|>// repo: brmmm3/pdf path: /view/src/bin/pdf_view.rs use pdf_view::PdfView; use...
code_fim
easy
{ "lang": "rust", "repo": "brmmm3/pdf", "path": "/view/src/bin/pdf_view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brmmm3/pdf path: /view/src/bin/pdf_view.rs use pdf_view::PdfView; use pdf::file::File; use pathfinder_view::{show, Config}; <|fim_suffix|> env_logger::init(); let path = std::env::args().nth(1).unwrap(); let file = File::<Vec<u8>>::open(&path).unwrap(); let view = PdfView::new(fi...
code_fim
easy
{ "lang": "rust", "repo": "brmmm3/pdf", "path": "/view/src/bin/pdf_view.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarveyHunt/mysql_async path: /src/io/futures/write_packet.rs // Copyright (c) 2016 Anatoly Ikorsky // // 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 ...
code_fim
hard
{ "lang": "rust", "repo": "HarveyHunt/mysql_async", "path": "/src/io/futures/write_packet.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Future for WritePacket { type Output = Result<Stream>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { if self.data.is_some() { ready!(Pin::new(self.stream.as_mut().unwrap().codec.as_mut().unwrap()).poll_ready(cx))?; } if l...
code_fim
hard
{ "lang": "rust", "repo": "HarveyHunt/mysql_async", "path": "/src/io/futures/write_packet.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ErrorCode { pub fn query_error() -> i64 { -32003 } pub fn tx_auth_error() -> i64 { -32006 } pub fn time_out_error() -> i64 { -32099 } }<|fim_prefix|>// repo: luqz/cita-common path: /error/src/error.rs // Copyright Cryptape Technologies LLC. // // Lic...
code_fim
medium
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/error/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luqz/cita-common path: /error/src/error.rs // Copyright Cryptape Technologies LLC. // // 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.apache.org/lice...
code_fim
medium
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/error/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn tx_auth_error() -> i64 { -32006 } pub fn time_out_error() -> i64 { -32099 } }<|fim_prefix|>// repo: luqz/cita-common path: /error/src/error.rs // Copyright Cryptape Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may n...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/error/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benbrunton/pusoy_dos_server path: /project/src/controller/game.rs use tera::{Tera, Context, Result as TeraResult}; use std::panic::RefUnwindSafe; use helpers::{PathExtractor, QueryStringExtractor}; use config::Config; use data_access::game::Game as GameData; use model::game::Game as GameModel; ...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/pusoy_dos_server", "path": "/project/src/controller/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn determine_state(&self, user:u64, game: &Option<GameModel>, users: &Vec<UserModel>) -> GameState { match *game { Some(ref game) => { info!("game creator: {}", game.creator_id); info!("current user {}", user); if game.starte...
code_fim
hard
{ "lang": "rust", "repo": "benbrunton/pusoy_dos_server", "path": "/project/src/controller/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! print { ($($arg:tt)*) => ($crate::io::vga::print::_print(format_args!($($arg)*))); } #[macro_export] macro_rules! println { () => ($crate::print!("\n")); ($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*))); }<|fim_prefix|>// repo: Peter-JanGootzen/nif...
code_fim
medium
{ "lang": "rust", "repo": "Peter-JanGootzen/niffler", "path": "/src/io/vga/print.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Peter-JanGootzen/niffler path: /src/io/vga/print.rs use x86_64::instructions::interrupts::without_interrupts; use core::fmt; use core::fmt::Write; use crate::io::vga::writer::VGA_WRITER; <|fim_suffix|>#[macro_export] macro_rules! print { ($($arg:tt)*) => ($crate::io::vga::print::_print(form...
code_fim
medium
{ "lang": "rust", "repo": "Peter-JanGootzen/niffler", "path": "/src/io/vga/print.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ret = unsafe { Esys_GetTestResult( self.mut_context(), self.optional_session_1(), self.optional_session_2(), self.optional_session_3(), &mut out_data, &mut out_rc, ) ...
code_fim
hard
{ "lang": "rust", "repo": "ueno/rust-tss-esapi", "path": "/tss-esapi/src/context/tpm_commands/testing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if ret.is_success() { let out_data = unsafe { MBox::from_raw(out_data) }; let out_data = MaxBuffer::try_from(*out_data)?; let out_rc = Error::from_tss_rc(out_rc); let out_rc = if out_rc.is_success() { Ok(()) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "ueno/rust-tss-esapi", "path": "/tss-esapi/src/context/tpm_commands/testing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ueno/rust-tss-esapi path: /tss-esapi/src/context/tpm_commands/testing.rs // Copyright 2021 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 use crate::{ structures::MaxBuffer, tss2_esys::{Esys_GetTestResult, Esys_SelfTest}, Context, Error, Result, }; use log...
code_fim
hard
{ "lang": "rust", "repo": "ueno/rust-tss-esapi", "path": "/tss-esapi/src/context/tpm_commands/testing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Set other headers specific to the user agent. request.headers.set_header("Accept-Encoding", "gzip, deflate"); match &connection_use { ConnectionUse::SingleResource => { request.headers.set_header("Connection", "Close"); ...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/HttpClient", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// This holds information to provide to a higher-level protocol in the case /// where an HTTP connection is upgraded after a response. pub struct ConnectionUpgrade { /// This holds the underlying transport layer connection, which becomes the /// caller's responsibility. pub connection: Box<dy...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/HttpClient", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhymu8354/HttpClient path: /src/lib.rs /! to higher-level protocols such as [`WebSockets`], as long as the user takes //! care of including any required headers and/or body for the request. //! //! # Examples //! //! ```no_run //! # extern crate futures; //! # extern crate rhymessage; //! # exte...
code_fim
hard
{ "lang": "rust", "repo": "rhymu8354/HttpClient", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Statement #[derive(Clone, Debug)] pub enum Stmt { Expr(Expr), ReturnExpr(Box<Expr>), ReturnVoid, Break, Continue, Block(Vec<Stmt>), If { test_expr: Expr, then_stmt: Box<Stmt>, else_stmt: Option<Box<Stmt>>, }, While { test_expr: E...
code_fim
hard
{ "lang": "rust", "repo": "maximecb/uvm", "path": "/ncc/src/ast.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> ReturnExpr(Box<Expr>), ReturnVoid, Break, Continue, Block(Vec<Stmt>), If { test_expr: Expr, then_stmt: Box<Stmt>, else_stmt: Option<Box<Stmt>>, }, While { test_expr: Expr, body_stmt: Box<Stmt>, }, DoWhile { body_s...
code_fim
hard
{ "lang": "rust", "repo": "maximecb/uvm", "path": "/ncc/src/ast.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maximecb/uvm path: /ncc/src/ast.rs use std::rc::Rc; use std::cell::RefCell; use std::fmt; // TODO: we may want a const type #[derive(Clone, Debug)] pub enum Type { Void, UInt(usize), Int(usize), Float(usize), Pointer(Box<Type>), Array { elem_type: Box<Type>, ...
code_fim
hard
{ "lang": "rust", "repo": "maximecb/uvm", "path": "/ncc/src/ast.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mthom/scryer-prolog path: /src/machine/gc.rs ll_loc; } else { debug_assert!(self.heap[h].get_tag() == HeapCellValueTag::CStr); self.next = self.heap[h].get_value(); self.heap[h].set_value...
code_fim
hard
{ "lang": "rust", "repo": "mthom/scryer-prolog", "path": "/src/machine/gc.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for cell in &mut wam.machine_st.heap { cell.set_mark_bit(false); cell.set_forwarding_bit(false); } // push some unrelated nonsense cells to the heap and check that they // are unmarked after the marker has finished at 0. wam.machine_st.heap....
code_fim
hard
{ "lang": "rust", "repo": "mthom/scryer-prolog", "path": "/src/machine/gc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(wam.machine_st.heap.len(), 1); all_cells_marked_and_unforwarded(&wam.machine_st.heap); wam.machine_st.heap.clear(); wam.machine_st.heap.push(str_loc_as_cell!(1)); wam.machine_st.heap.push(atom_as_cell!(atom!("g"), 2)); wam.machine_st.heap.push(...
code_fim
hard
{ "lang": "rust", "repo": "mthom/scryer-prolog", "path": "/src/machine/gc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dave136/learning_rust path: /9_errors/src/main.rs /* -------------------- Error Handling -------------------- */ /* El compromiso de Rust con la confiabilidad se extiende al manejo de errores. Los errores son una realidad en el software, por lo que Rust tiene una serie de característica...
code_fim
hard
{ "lang": "rust", "repo": "Dave136/learning_rust", "path": "/9_errors/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> La mayoría de los idiomas no distinguen entre estos dos tipos de errores y manejan ambos de la misma manera, utilizando mecanismos como las excepciones. Rust no tiene excepciones. En cambio, tiene el tipo "Result<T, E>" para errores recuperables y el macro "panic!" que detiene la ejecución c...
code_fim
hard
{ "lang": "rust", "repo": "Dave136/learning_rust", "path": "/9_errors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 1HPorange/rays path: /src/vec.rs use std::ops::*; // TODO: Rename this module to "vec" because this thing is in it #[derive(Debug, Copy, Clone)] pub struct Vec2 { pub u: f64, pub v: f64 } #[derive(Debug, Copy, Clone)] pub struct Vec3 { pub x: f64, pub y: f64, pub z: f64 } ...
code_fim
hard
{ "lang": "rust", "repo": "1HPorange/rays", "path": "/src/vec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn rotate_z(self, deg: f64) -> Self { let rad = deg.to_radians(); let x = self.x * rad.cos() - self.y * rad.sin(); let y = self.x * rad.sin() + self.y * rad.cos(); let z = self.z; Self { x, y, z } ...
code_fim
hard
{ "lang": "rust", "repo": "1HPorange/rays", "path": "/src/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { x, y, z } } pub fn reflect(self, normal: Vec3Norm) -> Self { let reflected = self - normal * self.dot(normal) * 2.0; Self { x: reflected.x, y: reflected.y, z: reflec...
code_fim
hard
{ "lang": "rust", "repo": "1HPorange/rays", "path": "/src/vec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ules! debug { ($($args:expr),*$(,)*) => ( ) } // */<|fim_prefix|>// repo: strega-nil/z80 path: /src/macros.rs // NOTE(ubsan): figure out how to do this with features /* macro_rules! debug { ($($args:expr),*$(,)*) =><|fim_middle|> ( println!($($args),*); ) } // */ // /* macro_r
code_fim
easy
{ "lang": "rust", "repo": "strega-nil/z80", "path": "/src/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: strega-nil/z80 path: /src/macros.rs // NOTE(ubsan): figure out how to do this with feature<|fim_suffix|> ( println!($($args),*); ) } // */ // /* macro_rules! debug { ($($args:expr),*$(,)*) => ( ) } // */<|fim_middle|>s /* macro_rules! debug { ($($args:expr),*$(,)*) =>
code_fim
easy
{ "lang": "rust", "repo": "strega-nil/z80", "path": "/src/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: intramuros/exercism-rust path: /bowling/src/lib.rs #[derive(Debug, PartialEq)] pub enum Error { NotEnoughPinsLeft, GameComplete, } #[derive(Debug, PartialEq)] pub enum FrameType { Strike, Spare, Open, } use FrameType::*; pub struct BowlingGame { game_is_done: bool, ...
code_fim
hard
{ "lang": "rust", "repo": "intramuros/exercism-rust", "path": "/bowling/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn score(&self) -> Option<u16> { if !self.game_is_done { return None; } let mut score = 0; let mut index = 0; for frame in self.frames.iter() { if frame == &Strike { score += self.scores[index] + self.scores[index + 1]...
code_fim
hard
{ "lang": "rust", "repo": "intramuros/exercism-rust", "path": "/bowling/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> interval_set::demo(); }<|fim_prefix|>// repo: GregoryTravis/rust path: /src/main.rs mod interval_set; mod mergesort; mod war; <|fim_middle|>fn main() { if false { mergesort::demo(); } if false { war::demo(); }
code_fim
medium
{ "lang": "rust", "repo": "GregoryTravis/rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GregoryTravis/rust path: /src/main.rs mod interval_set; mod mergesort; mod war; fn main() { if false { mergesort::demo(); } <|fim_suffix|> interval_set::demo(); }<|fim_middle|> if false { war::demo(); }
code_fim
easy
{ "lang": "rust", "repo": "GregoryTravis/rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if false { war::demo(); } interval_set::demo(); }<|fim_prefix|>// repo: GregoryTravis/rust path: /src/main.rs mod interval_set; mod mergesort; mod war; fn main() { <|fim_middle|> if false { mergesort::demo(); }
code_fim
easy
{ "lang": "rust", "repo": "GregoryTravis/rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (&mut f1).await; (&mut f2).await; }<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tokio/tests/macros_pin.rs async fn one() {} async fn two() {} <|fim_middle|>#[tokio::test] async fn multi_pin() { tokio::pin! { let f1 = one(); let f2 = two(); ...
code_fim
medium
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tokio/tests/macros_pin.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oshunter/fuchsia path: /third_party/rust_crates/vendor/tokio/tests/macros_pin.rs async fn one() {} async fn two() {} <|fim_suffix|> (&mut f1).await; (&mut f2).await; }<|fim_middle|>#[tokio::test] async fn multi_pin() { tokio::pin! { let f1 = one(); let f2 = two(); ...
code_fim
medium
{ "lang": "rust", "repo": "oshunter/fuchsia", "path": "/third_party/rust_crates/vendor/tokio/tests/macros_pin.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", format!("{}{}", end, start)); (end - start + 1) as i32 } } #[cfg(test)] mod tests { use super::*; #[test] fn tests() { Solution::find_unsorted_subarray(vec![2, 6, 4, 8, 10, 9, 15]); } }<|fim_prefix|>// repo: zhangyuang/leetcode path: /hot100/easy/find_unsorted_sub...
code_fim
medium
{ "lang": "rust", "repo": "zhangyuang/leetcode", "path": "/hot100/easy/find_unsorted_subarray/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangyuang/leetcode path: /hot100/easy/find_unsorted_subarray/src/lib.rs struct Solution {} impl Solution { pub fn find_unsorted_subarray(nums: Vec<i32>) -> i32 { // 时间复杂度O(n) if nums.len() == 1 { return 0; } let mut c_max = nums[0]; // 记录当前选取的数组范围内的最大值 let mut c_min...
code_fim
medium
{ "lang": "rust", "repo": "zhangyuang/leetcode", "path": "/hot100/easy/find_unsorted_subarray/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrensegura/projects path: /rust/dragoninja/index/src/main.rs extern crate lib_andre; use lib_andre::io::print_file; use std::error::Error; <|fim_suffix|> try_main().unwrap(); } fn try_main() -> Result<(), Box<Error>>{ println!("Content-type: text/html; charset=iso-8859-1\n"); //...
code_fim
easy
{ "lang": "rust", "repo": "andrensegura/projects", "path": "/rust/dragoninja/index/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//{ usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } //binary_operation_impl! { (u64,u8) (u64,u16) (u64,u32) (u64,u64) } pub fn load_len_dict(len_dict: &mut LenDictionary) { //dict.insert(s, columnadd_onwedcolumnvecu64_vecu64);7 binary_operation_load! {len_dict; u64 u32 u16...
code_fim
hard
{ "lang": "rust", "repo": "nbliznashki/radix", "path": "/src/expressions/len.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbliznashki/radix path: /src/expressions/len.rs use crate::Signature; use std::collections::HashMap; use paste::paste; pub type LenOperation = fn(&ColumnWrapper) -> Result<usize, ErrorDesc>; pub type LenDictionary = HashMap<Signature, LenOperation>; use crate::*; #[allow(dead_code)] const ...
code_fim
hard
{ "lang": "rust", "repo": "nbliznashki/radix", "path": "/src/expressions/len.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>u64 u32 u16 u8 bool usize } //{ usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } //binary_operation_impl! { (u64,u8) (u64,u16) (u64,u32) (u64,u64) } pub fn load_len_dict(len_dict: &mut LenDictionary) { //dict.insert(s, columnadd_onwedcolumnvecu64_vecu64);7 binary_operation_load! {...
code_fim
hard
{ "lang": "rust", "repo": "nbliznashki/radix", "path": "/src/expressions/len.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust path: /Chapter 4/strtype1.rs // strtype1.rs -- using the rust String struct use std::io; use std::io::prelude::*; use std::ptr; use std::str; use std::string::String; fn main() -> io::Result<()> { let mut stdout: io::Stdout = io::std...
code_fim
medium
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 4/strtype1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut charr1: [u8; 20] = <[u8; 20]>::default(); // create an empty array let mut charr2: [u8; 20] = <[u8; 20]>::default(); // create an empty array unsafe { ptr::copy_nonoverlapping("jaguar".as_ptr(), (&mut charr2).as_mut_ptr(), 6) }; // initialized array let mut str1: String = String::...
code_fim
medium
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 4/strtype1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devonhollowood/adventofcode path: /2021/src/day11.rs use std::collections::HashSet; use anyhow::{anyhow, Result}; use nalgebra::DMatrix; pub fn parse(input: &str) -> Result<DMatrix<u8>> { let nrows = input.lines().filter(|l| !l.is_empty()).count(); if nrows == 0 { return Err(an...
code_fim
hard
{ "lang": "rust", "repo": "devonhollowood/adventofcode", "path": "/2021/src/day11.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> const INPUT: &str = r" 5483143223 2745854711 5264556173 6141336146 6357385478 4167524645 2176841721 6882881134 4846848554 5283751526"; #[test] fn test_part1() { let parsed = parse(INPUT).unwrap(); assert_eq!(part1(&parsed), 1656); } #[test] fn test_part2() { ...
code_fim
hard
{ "lang": "rust", "repo": "devonhollowood/adventofcode", "path": "/2021/src/day11.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saghm/mongo-rust-driver path: /src/cursor/common.rs use std::{ collections::VecDeque, pin::Pin, task::{Context, Poll}, time::Duration, }; use derivative::Derivative; use futures::{Future, Stream}; use crate::{ bson::Document, error::{ErrorKind, Result}, options::Str...
code_fim
hard
{ "lang": "rust", "repo": "saghm/mongo-rust-driver", "path": "/src/cursor/common.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The type of future created by this provider when running a getMore. type GetMoreFuture: Future<Output = Self::GetMoreResult> + Unpin; /// Get the future being evaluated, if there is one. fn executing_future(&mut self) -> Option<&mut Self::GetMoreFuture>; /// Clear out any state r...
code_fim
hard
{ "lang": "rust", "repo": "saghm/mongo-rust-driver", "path": "/src/cursor/common.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the future being evaluated, if there is one. fn executing_future(&mut self) -> Option<&mut Self::GetMoreFuture>; /// Clear out any state remaining from previous getMore executions. fn clear_execution(&mut self, result: Self::GetMoreResult); /// Start executing a new getMore i...
code_fim
hard
{ "lang": "rust", "repo": "saghm/mongo-rust-driver", "path": "/src/cursor/common.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adumbidiot/quarky path: /lib/twitter-scraper/src/model/get_user_tweets.rs use super::{ ResultField, UserField, }; pub type GetUserTweetsResponse = UserField<ResultField<UserResult>>; #[derive(Debug, serde::Deserialize)] pub struct UserResult { pub timeline_v2: TimelineV2, } #[deri...
code_fim
hard
{ "lang": "rust", "repo": "adumbidiot/quarky", "path": "/lib/twitter-scraper/src/model/get_user_tweets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }