text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: kjh618/rust-book-ch17-blog path: /src/post2.rs pub struct Post { content: String, } impl Post { pub fn new() -> DraftPost { DraftPost { content: String::new(), } } pub fn content(&self) -> &str { &self.content } } pub struct DraftPost { ...
code_fim
hard
{ "lang": "rust", "repo": "kjh618/rust-book-ch17-blog", "path": "/src/post2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ApproveResult { pub fn unwrap_not_enough(self) -> PendingReviewPost { if let ApproveResult::NotEnough(p) = self { p } else { panic!() } } pub fn unwrap_done(self) -> Post { if let ApproveResult::Done(p) = self { p ...
code_fim
hard
{ "lang": "rust", "repo": "kjh618/rust-book-ch17-blog", "path": "/src/post2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(right) = node.borrow().right.as_ref() { Solution::move_coins(Some(right.clone()), mov); let cval: i32 = right.borrow().val; if cval > 1 { *mov += cval - 1; val += cval - 1; } els...
code_fim
hard
{ "lang": "rust", "repo": "solomonwzs/leetcode", "path": "/rust/distribute_coins_in_binary_tree/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solomonwzs/leetcode path: /rust/distribute_coins_in_binary_tree/src/lib.rs extern crate tree_node; use std::cell::RefCell; use std::rc::Rc; use tree_node::TreeNode; pub struct Solution {} impl Solution { fn move_coins(root: Option<Rc<RefCell<TreeNode>>>, mov: &mut i32) { if let So...
code_fim
hard
{ "lang": "rust", "repo": "solomonwzs/leetcode", "path": "/rust/distribute_coins_in_binary_tree/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_work0() { let root = TreeNode::build_tree("1,0,0,null,3"); assert_eq!(Solution::distribute_coins(root), 4); } #[test] fn it_work1() { let root = TreeNode::build_tree("3,null,0,0,null,0,null,2"); assert_eq!(Solution::distribute_coins(root),...
code_fim
hard
{ "lang": "rust", "repo": "solomonwzs/leetcode", "path": "/rust/distribute_coins_in_binary_tree/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> state, )), ) .serve("[::1]:5901".parse()?) .await?; Ok(()) }<|fim_prefix|>// repo: dflemstr/shipthing path: /src/server.rs use crate::handler; use crate::proto; use crate::state; use futures::lock; use std::sync; pub async fn run(state: sync::Arc<lo...
code_fim
medium
{ "lang": "rust", "repo": "dflemstr/shipthing", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dflemstr/shipthing path: /src/server.rs use crate::handler; use crate::proto; use crate::state; use futures::lock; use std::sync; pub async fn run(state: <|fim_suffix|> .add_service( proto::shipthing::v1::player_api_server::PlayerApiServer::new(handler::Handler::new( ...
code_fim
medium
{ "lang": "rust", "repo": "dflemstr/shipthing", "path": "/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>const DEFAULT_DRIVER: BlockDriverType = BlockDriverType::Qemu; const ALL_DRIVERS: &[BlockDriverType] = &[BlockDriverType::Qemu]; pub async fn data_list( driver: Option<BlockDriverType>, details: SnapRestoreDetails, img_file: String, path: Vec<u8>, ) -> Result<Vec<ArchiveEntry>, Error> { ...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/bin/proxmox_file_restore/block_driver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[api( input: { properties: { "name": { type: String, description: "The name of the VM to stop.", }, }, }, )] /// Immediately stop/unmap a given image. Not typically necessary, as VMs will stop themselves /// after ...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/bin/proxmox_file_restore/block_driver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimox/proxmox-backup path: /src/bin/proxmox_file_restore/block_driver.rs //! Abstraction layer over different methods of accessing a block backup use anyhow::{bail, Error}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::collections::HashMap; use std::future::Future...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/bin/proxmox_file_restore/block_driver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let font = Vec::from(include_bytes!("../data/berlin-email.berlin-email.ttf") as &[u8]); let font = FontCollection::from_bytes(font) .unwrap() .into_font() .unwrap(); let font_shadow = Vec::from(include_bytes!("../data/berlin-email.berlin-email-schaddow.ttf") as...
code_fim
medium
{ "lang": "rust", "repo": "janquo/group_chart", "path": "/src/drawer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: janquo/group_chart path: /src/drawer.rs use std::path::PathBuf; pub fn collage(images: Vec<PathBuf>, albums: Vec<super::Album>, args: super::Args) { use image::GenericImage; let x = args.x; let y = args.y; let mut img = image::DynamicImage::new_rgba8(300 * x, 300 * y); fo...
code_fim
hard
{ "lang": "rust", "repo": "janquo/group_chart", "path": "/src/drawer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> img: &mut image::ImageBuffer<image::Rgba<u8>, std::vec::Vec<u8>>, author: &str, title: &str, ) { use rusttype::{FontCollection, Scale}; let font = Vec::from(include_bytes!("../data/berlin-email.berlin-email.ttf") as &[u8]); let font = FontCollection::from_bytes(font) .unwr...
code_fim
medium
{ "lang": "rust", "repo": "janquo/group_chart", "path": "/src/drawer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match *self { DatatrackerError::NotFound => write!(f, "Not found"), DatatrackerError::IoError(ref e) => e.fmt(f) } } } impl error::Error for DatatrackerError { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Da...
code_fim
hard
{ "lang": "rust", "repo": "csperkins/ietfdata-rs", "path": "/src/api/mod.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { match self.try_next() { Ok(None) => None, Ok(Some(x)) => Some(Ok(x)), Err(e) => Some(Err(e)) } } } // ===========================================================================================...
code_fim
hard
{ "lang": "rust", "repo": "csperkins/ietfdata-rs", "path": "/src/api/mod.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: csperkins/ietfdata-rs path: /src/api/mod.rs // Copyright (C) 2019 University of Glasgow // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retai...
code_fim
hard
{ "lang": "rust", "repo": "csperkins/ietfdata-rs", "path": "/src/api/mod.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Torkilso/open-ended-coevolution path: /src/config/mcc.rs use envconfig::Envconfig; #[derive(Envconfig)] pub struct Config { #[envconfig(from = "generations", default = "1000")] pub generations: usize, #[envconfig(from = "maze_population_capacity", default = "250")] pub maze_pop...
code_fim
hard
{ "lang": "rust", "repo": "Torkilso/open-ended-coevolution", "path": "/src/config/mcc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[envconfig(from = "default_maze_size", default = "10")] pub default_maze_size: usize, #[envconfig(from = "generations_between_save", default = "10")] pub generations_between_save: usize, #[envconfig(from = "varied_size_maze_default_borrow_amount", default = "2")] pub varied_size...
code_fim
hard
{ "lang": "rust", "repo": "Torkilso/open-ended-coevolution", "path": "/src/config/mcc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gabriel-araujjo/oauth2 path: /src/people/errors.rs use bcrypt::BcryptError; use diesel::result::{Error as DieselError, DatabaseErrorKind}; use std::convert::{From, Into}; use std::fmt; use rocket::http::Status; pub type PeopleResult<T> = Result<T, PeopleError>; #[derive(Debug)] pub enum People...
code_fim
hard
{ "lang": "rust", "repo": "gabriel-araujjo/oauth2", "path": "/src/people/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { PeopleError::NotFound => Status::NotFound, PeopleError::InvalidPassword => Status::new(400, "Invalid password (password has a \\0 character)"), PeopleError::DuplicateEmail => Status::new(400, "Duplicated email"), PeopleError::Authenticat...
code_fim
hard
{ "lang": "rust", "repo": "gabriel-araujjo/oauth2", "path": "/src/people/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Into<Status> for PeopleError { fn into(self) -> Status { match self { PeopleError::NotFound => Status::NotFound, PeopleError::InvalidPassword => Status::new(400, "Invalid password (password has a \\0 character)"), PeopleError::DuplicateEmail => Status::...
code_fim
hard
{ "lang": "rust", "repo": "gabriel-araujjo/oauth2", "path": "/src/people/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Response::with((status::Ok, "media"))) } Iron::new(vhosts).http("localhost:3000").unwrap(); }<|fim_prefix|>// repo: sbditto85/iron_vhosts path: /examples/basic.rs extern crate iron; extern crate iron_vhosts; use iron::prelude::*; use iron::status; use iron_vhosts::Vhosts; fn main ()...
code_fim
medium
{ "lang": "rust", "repo": "sbditto85/iron_vhosts", "path": "/examples/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbditto85/iron_vhosts path: /examples/basic.rs extern crate iron; extern crate iron_vhosts; use iron::prelude::*; use iron::status; use iron_vhosts::Vhosts; fn main () { <|fim_suffix|> Ok(Response::with((status::Ok, "localhost"))) } fn media_handler(_: &mut Request) -> IronResu...
code_fim
hard
{ "lang": "rust", "repo": "sbditto85/iron_vhosts", "path": "/examples/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /Leetcode/441. Arranging Coins/solution2.rs impl Solution { pub fn arrange_coins(mut n: i32) -> i32 { let mut left = 0 as i64; let mut right = n as i64; <|fim_suffix|> if curr == n as i64 { return mid as i32; ...
code_fim
hard
{ "lang": "rust", "repo": "EduardoSantos7/Algorithms4fun", "path": "/Leetcode/441. Arranging Coins/solution2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if curr == n as i64 { return mid as i32; } if (n as i64) < curr { right = mid - 1; } else { left = mid + 1 } } right as i32 } }<|fim_prefix|>// repo: EduardoSantos7/Algorithms4f...
code_fim
hard
{ "lang": "rust", "repo": "EduardoSantos7/Algorithms4fun", "path": "/Leetcode/441. Arranging Coins/solution2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: salmmanfred/esolangs path: /langs/single_script/flkl.rs fn main() { let x = lext(readFile("test.flkl")); let p = parses(x); exc(p.clone(), 0, "".to_string()); } pub fn readFile(names: &str) -> String { //reads the file from names let s = "".to_string(); let fnm = s+&name...
code_fim
hard
{ "lang": "rust", "repo": "salmmanfred/esolangs", "path": "/langs/single_script/flkl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut str = "".to_string(); for x in x[0]..x[1] { match code.lex[x].clone() { TT::char(a) => { str.push_str(a.as_str()); } } } str } fn exc(ps: Vec<Parse>, i: usize, data: String) { let p = ps[i].clone(); let mut data = data...
code_fim
hard
{ "lang": "rust", "repo": "salmmanfred/esolangs", "path": "/langs/single_script/flkl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> a => { panic!("not implemented {},{},{}", a, mof, x) } } } pr.push(prs); } pr } fn col(x: [usize; 2], code: Coder) -> String { let mut str = "".to_string(); for x in x[0]..x[1] { match code.lex[x].clone...
code_fim
hard
{ "lang": "rust", "repo": "salmmanfred/esolangs", "path": "/langs/single_script/flkl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoshKarpel/fungoid path: /src/program.rs use std::{collections::HashMap, fs::File, io, io::Read, str::FromStr}; use itertools::{Itertools, MinMaxResult}; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Position { pub x: isize, pub y: isize, } #[derive(De...
code_fim
hard
{ "lang": "rust", "repo": "JoshKarpel/fungoid", "path": "/src/program.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> program.set(&pos, '.'); assert_eq!(program.get(&pos), '.'); Ok(()) } #[test] fn test_extent_with_empty_program_is_none() -> GenericResult { let program = Program::new(); assert!(program.extent().is_none()); Ok(()) } #[test] fn te...
code_fim
hard
{ "lang": "rust", "repo": "JoshKarpel/fungoid", "path": "/src/program.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let program = Program::from_str("12\n34")?; assert_eq!(program.get(&Position { x: 0, y: 0 }), '1'); assert_eq!(program.get(&Position { x: 1, y: 0 }), '2'); assert_eq!(program.get(&Position { x: 0, y: 1 }), '3'); assert_eq!(program.get(&Position { x: 1, y: 1 }), '4'...
code_fim
hard
{ "lang": "rust", "repo": "JoshKarpel/fungoid", "path": "/src/program.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIInputStreamChannel.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIInputStreamChannel.idl // #[repr(C)] pub struct nsIInputStreamChannel { vtable: *const nsIInputStreamChannelVTable, /// This field is a phantomdata to ensur...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIInputStreamChannel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl nsIInputStreamChannel { /* void setURI (in nsIURI aURI); */ #[inline] pub unsafe fn setURI(&self, aURI: Option<&nsIURI>) -> Result<(), nsresult> { match ((*self.vtable).setURI)(self as *const _, aURI.map_or(::std::ptr::null(), |x| x as *const _)) { NS_OK => {}, ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIInputStreamChannel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn retrieve_pipeline(&self, device: Arc<Device>, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>, dimensions: [u32; 2] ) -> Vec<Arc<dyn GraphicsPipelineAbstract + Send + Sync>> { vec![self.cub...
code_fim
hard
{ "lang": "rust", "repo": "AndrewHC36/Mineblock", "path": "/src/mesh/mesh.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndrewHC36/Mineblock path: /src/mesh/mesh.rs use crate::renderer::CubeVtx; use crate::block::Block; use crate::chunk::{Chunk, ChunkID}; use vulkano::device::Device; use vulkano::image::{SwapchainImage}; use vulkano::pipeline::GraphicsPipelineAbstract; use vulkano::framebuffer::RenderPassAbstrac...
code_fim
hard
{ "lang": "rust", "repo": "AndrewHC36/Mineblock", "path": "/src/mesh/mesh.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OlivierLemoine/rust_embedded path: /hal/src/rcc/mod.rs #![allow(dead_code)] pub mod raw; use super::flash; pub const HSI_SPEED: u32 = 16_000_000; static mut PLL_M: u32 = 1; static mut PLL_N: u32 = 1; static mut PLL_P: u32 = 1; static mut PLL_Q: u32 = 1; static mut PLL_R: u32 = 1; static mut...
code_fim
hard
{ "lang": "rust", "repo": "OlivierLemoine/rust_embedded", "path": "/hal/src/rcc/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn enable_hsi(self) -> Rcc<STATE> { self.base.hsi_on_not_off().set(true); while !self.base.hsi_is_ready().get() {} self } pub fn sysclock_into_hsi(self) -> Rcc<STATE> { let (mut b1, mut b2) = self.base.system_clock_switch(); b1.set(false); b...
code_fim
hard
{ "lang": "rust", "repo": "OlivierLemoine/rust_embedded", "path": "/hal/src/rcc/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn main_pll_src_into_hsi(self) -> Rcc<pll_state::Off> { self.base.main_pll_and_i2s_pll_src().set(false); self } pub fn main_pll_src_into_hse(self) -> Rcc<pll_state::Off> { self.base.main_pll_and_i2s_pll_src().set(true); self } pub fn set_pll_p(self...
code_fim
hard
{ "lang": "rust", "repo": "OlivierLemoine/rust_embedded", "path": "/hal/src/rcc/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d0nutptr/10kchallenge path: /src/iam/iam_state.rs use std::sync::{Arc, Mutex}; use rsa::RSAPublicKey; #[derive(Clone, StateData)] pub struct IAMState { pub alice_pub_key: Arc<Mutex<Option<RSAPublicKe<|fim_suffix|>new(None)), challenge_pub_key: Arc::new(Mutex::new(Some(challenge_...
code_fim
hard
{ "lang": "rust", "repo": "d0nutptr/10kchallenge", "path": "/src/iam/iam_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>new(None)), challenge_pub_key: Arc::new(Mutex::new(Some(challenge_pub_key))) } } } pub enum ServiceIdentity { ALICE, BOB }<|fim_prefix|>// repo: d0nutptr/10kchallenge path: /src/iam/iam_state.rs use std::sync::{Arc, Mutex}; use rsa::RSAPublicKey; #[derive(Clone, StateDat...
code_fim
hard
{ "lang": "rust", "repo": "d0nutptr/10kchallenge", "path": "/src/iam/iam_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type NewSession = fn( interpreter: SBCommandInterpreter, event_sink: Box<dyn EventSink + Send>, ) -> Result<Box<dyn PythonInterface>, Error>;<|fim_prefix|>// repo: CrackerCat/vscode-lldb path: /adapter2/deps/python-interface/src/lib.rs use lldb::*; #[derive(Debug)] pub enum PythonValue { ...
code_fim
medium
{ "lang": "rust", "repo": "CrackerCat/vscode-lldb", "path": "/adapter2/deps/python-interface/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CrackerCat/vscode-lldb path: /adapter2/deps/python-interface/src/lib.rs use lldb::*; #[derive(Debug)] pub enum PythonValue { SBValue(SBValue), Int(i64), Bool(bool), String(String), Object(String), } <|fim_suffix|>} pub trait PythonInterface { fn evaluate(&self, expr: &...
code_fim
medium
{ "lang": "rust", "repo": "CrackerCat/vscode-lldb", "path": "/adapter2/deps/python-interface/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn modules_loaded(&self, modules: &mut dyn Iterator<Item = &SBModule>); } pub type Entry = fn() -> Result<(), Error>; pub type NewSession = fn( interpreter: SBCommandInterpreter, event_sink: Box<dyn EventSink + Send>, ) -> Result<Box<dyn PythonInterface>, Error>;<|fim_prefix|>// repo: Cracke...
code_fim
hard
{ "lang": "rust", "repo": "CrackerCat/vscode-lldb", "path": "/adapter2/deps/python-interface/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct ButtplugRemoteServer { server: Arc<ButtplugServer>, server_receiver: Receiver<ButtplugServerMessage>, pub(super) event_sender: Sender<ButtplugRemoteServerEvent>, task_channel: Arc<Mutex<Option<Sender<ButtplugServerCommand>>>>, } async fn run_server<ConnectorType>( server: Arc<Buttplu...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/buttplug-rs", "path": "/buttplug/src/server/remote_server.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/buttplug-rs path: /buttplug/src/server/remote_server.rs use super::{ButtplugServer, ButtplugServerOptions, ButtplugServerStartupError}; use crate::{ connector::ButtplugConnector, core::{ errors::{ButtplugError, ButtplugServerError}, messages::{self, ButtplugClientMessage, But...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/buttplug-rs", "path": "/buttplug/src/server/remote_server.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>async fn run_server<ConnectorType>( server: Arc<ButtplugServer>, remote_event_sender: Sender<ButtplugRemoteServerEvent>, mut server_receiver: Receiver<ButtplugServerMessage>, connector: ConnectorType, mut connector_receiver: Receiver<Result<ButtplugClientMessage, ButtplugServerError>>, mut con...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/buttplug-rs", "path": "/buttplug/src/server/remote_server.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for ClientTimeout { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.duration.as_secs()) } } pub struct StudioClientConfig { pub(crate) config: config::Config, client: Client, uri: String, version: String, is_sudo: bool,...
code_fim
hard
{ "lang": "rust", "repo": "mimattan/rover", "path": "/src/utils/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mimattan/rover path: /src/utils/client.rs use core::fmt; use std::{str::FromStr, time::Duration}; use crate::error::RoverError; use crate::Result; use crate::PKG_VERSION; use houston as config; use reqwest::blocking::Client; use rover_client::blocking::StudioClient; use serde::Serialize; ///...
code_fim
hard
{ "lang": "rust", "repo": "mimattan/rover", "path": "/src/utils/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_authenticated_client(&self, profile_name: &str) -> Result<StudioClient> { let credential = config::Profile::get_credential(profile_name, &self.config)?; Ok(StudioClient::new( credential, &self.uri, &self.version, self.is_sudo, ...
code_fim
hard
{ "lang": "rust", "repo": "mimattan/rover", "path": "/src/utils/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dvshur/waves-node-grpc-testing path: /src/subscribe.rs use humantime::format_duration; use std::env::var; use std::time::Duration; use waves_protobuf_schemas::waves::events::grpc::blockchain_updates_api_client::BlockchainUpdatesApiClient; use waves_protobuf_schemas::waves::events::grpc::Subscrib...
code_fim
hard
{ "lang": "rust", "repo": "dvshur/waves-node-grpc-testing", "path": "/src/subscribe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !silent { println!("{:?}", &upd.height); } if throttle_millis > 0 { tokio::time::sleep(Duration::from_millis(throttle_millis)).await; } } println!( "Finished streaming in {}", format_duration(Duration::from_millis( ...
code_fim
hard
{ "lang": "rust", "repo": "dvshur/waves-node-grpc-testing", "path": "/src/subscribe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_event_stats_for_account( api: &mut crate::WebApi, eventid: u32, accountid: u32, language: Option<&str>, ) -> Result<get_event_stats_for_account::Response> { let query = format!( "?key={}&eventid={}&accountid={}&language={}", api.get_key()?, even...
code_fim
hard
{ "lang": "rust", "repo": "Alegr37/steam-web-api-rs", "path": "/src/econ_dota2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_heroes( api: &mut crate::WebApi, language: Option<&str>, itemizedonly: Option<bool>, ) -> Result<get_heroes::Response> { let query = format!( "?key={}&language={}&itemizedonly={}", api.get_key()?, language.unwrap_or_default(), itemizedonly.u...
code_fim
hard
{ "lang": "rust", "repo": "Alegr37/steam-web-api-rs", "path": "/src/econ_dota2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alegr37/steam-web-api-rs path: /src/econ_dota2.rs // THIS FILE HAS BEEN AUTOGENERATED AND MAY BE REDACTED (DELETE THIS LINE IF YOU WANT TO SAVE CHANGES) use anyhow::Result; #[allow(unused_imports)] use itertools::Itertools; pub mod get_event_stats_for_account; pub mod get_game_items; pub mod ge...
code_fim
hard
{ "lang": "rust", "repo": "Alegr37/steam-web-api-rs", "path": "/src/econ_dota2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn lockdownd_pair(client: lockdownd_client_t, pair_record: lockdownd_pair_record_t) -> lockdownd_error_t; pub fn lockdownd_validate_pair(client: lockdownd_client_t, pair_record: lockdownd_pair_record_t) -> lockdownd_error_t; pub fn lockdownd_unpair(client: lockdownd_client_t, pair_record: ...
code_fim
hard
{ "lang": "rust", "repo": "kennytm/libimobiledevice-rust", "path": "/libimobiledevice-sys/src/lockdown.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kennytm/libimobiledevice-rust path: /libimobiledevice-sys/src/lockdown.rs //! Bindings to `lockdown.h`. use std::os::raw::{c_void, c_char, c_int}; use idevice::{idevice_t}; use libplist_sys::plist_t; #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(i32)] pub enum lockdownd_error_t { // ...
code_fim
hard
{ "lang": "rust", "repo": "kennytm/libimobiledevice-rust", "path": "/libimobiledevice-sys/src/lockdown.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Terminating zeroed hit buf.write_u128::<LittleEndian>(0_u128)?; file.write_all(&buf)?; Ok(()) }<|fim_prefix|>// repo: jaredvann/timepix-spidr-data-parser path: /src/io/write_cluster_data.rs /* * ARIADNE Experiment, Department of Physics, University of Liverpool * * timepix-spidr-d...
code_fim
hard
{ "lang": "rust", "repo": "jaredvann/timepix-spidr-data-parser", "path": "/src/io/write_cluster_data.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaredvann/timepix-spidr-data-parser path: /src/io/write_cluster_data.rs /* * ARIADNE Experiment, Department of Physics, University of Liverpool * * timepix-spidr-data-parser/src/io/write_cluster_data.rs * * Authors: Jared Vann */ <|fim_suffix|> buf.write_u16::<LittleEndian>(hit.col...
code_fim
hard
{ "lang": "rust", "repo": "jaredvann/timepix-spidr-data-parser", "path": "/src/io/write_cluster_data.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FoamCactus/euler path: /src/problems/problem9.rs pub fn problem9() { println!("The only pythagorean triple that sums to 1000 has a product of {}", get_pythagorean_triple_that_sums_to(1000)); } fn get_pythagorean_triple_that_sums_to(n: u32) -> u32 { <|fim_suffix|> b += 1; ...
code_fim
medium
{ "lang": "rust", "repo": "FoamCactus/euler", "path": "/src/problems/problem9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b += 1; } a += 1; b = 1; } return 0; }<|fim_prefix|>// repo: FoamCactus/euler path: /src/problems/problem9.rs pub fn problem9() { println!("The only pythagorean triple that sums to 1000 has a product of {}", get_pythagorean_triple_that_sums_to(1000)); } ...
code_fim
medium
{ "lang": "rust", "repo": "FoamCactus/euler", "path": "/src/problems/problem9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = 2; let mut b = 1; while a < n { while b < a { if a*a + b*b == (n - a - b) * (n - a - b) { return a * b * (n - a - b); } b += 1; } a += 1; b = 1; } return 0; }<|fim_prefix|>// repo: FoamCa...
code_fim
easy
{ "lang": "rust", "repo": "FoamCactus/euler", "path": "/src/problems/problem9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Access a mutable rope. pub fn as_mut_rope(&mut self) -> Option<&mut Rope> { if let Readable::Rope(_, ref mut rope) = self.readable { return Some(rope); } None } /// Open up a readable. pub fn read(&self) -> Result<Box<dyn Read>> { self....
code_fim
hard
{ "lang": "rust", "repo": "reproto/reproto", "path": "/lib/core/src/source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Create a new bytes source. /// /// Byte sources are read-only by default. /// This can be turned off if this is an in-memory representation of something in the /// filesystem, in which case `path` should also be set to indicate where. pub fn bytes<S: AsRef<str>>(name: S, bytes:...
code_fim
hard
{ "lang": "rust", "repo": "reproto/reproto", "path": "/lib/core/src/source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reproto/reproto path: /lib/core/src/source.rs //! The primary abstraction to indicate a "source" of data. //! //! Sources are primarily available to be read through `Source::read`, but also support auxiliary //! functions like finding the line of a given span `Source::find_range` or printing pre...
code_fim
hard
{ "lang": "rust", "repo": "reproto/reproto", "path": "/lib/core/src/source.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amfl/rustlike-revisited path: /include/examples/pancurses.rs extern crate pancurses; fn main() { println!("Wew!"); // let locale_conf = pancurses::LcCategory::all; // // pancurses::setlocale(locale_conf, "en_US.UTF-8"); // // pancurses::setlocale(locale_conf, "zh_CN.UTF-8"); ...
code_fim
hard
{ "lang": "rust", "repo": "amfl/rustlike-revisited", "path": "/include/examples/pancurses.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Can enable attributes one at a time... win.attron(pancurses::A_BOLD); win.printw("test string goes here\n"); // Or brute-force set them in one go with OR win.attrset(pancurses::COLOR_PAIR(1) |pancurses::A_BOLD); win.printw("test string goes here\n"); ...
code_fim
hard
{ "lang": "rust", "repo": "amfl/rustlike-revisited", "path": "/include/examples/pancurses.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drewet/name-my-indie-game-please path: /shared/src/component/components.rs use cgmath::{Matrix4, Point, Point3, ToMatrix4, Quaternion}; use component::{ComponentHandle, ComponentStore}; pub type EntityHandle = ComponentHandle<EntityComponent>; <|fim_suffix|> /// Constructs an EntityComponen...
code_fim
hard
{ "lang": "rust", "repo": "drewet/name-my-indie-game-please", "path": "/shared/src/component/components.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Constructs an EntityComponent inside a pub fn new(ents: &mut ComponentStore<EntityComponent>, pos: Point3<f32>, rot: Quaternion<f32>) -> EntityHandle { ents.add_with_handle(|handle| EntityComponent { handle: handle, pos: pos, ...
code_fim
hard
{ "lang": "rust", "repo": "drewet/name-my-indie-game-please", "path": "/shared/src/component/components.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for e in &lib_cfg.filename.extensions_md { if e == file_extension { return MarkupLanguage::Markdown; } } for e in &lib_cfg.filename.extensions_rst { if e == file_extension { return MarkupLanguage::RestructuredText;...
code_fim
hard
{ "lang": "rust", "repo": "getreu/tp-note", "path": "/tpnote-lib/src/markup_language.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // If ever `extension_default` got forgotten in // one of the above lists, make sure that Tp-Note // recognizes its own files. Even without Markup // rendition. let settings = SETTINGS.read_recursive(); if file_extension == lib_cfg.filename.extension_defaul...
code_fim
hard
{ "lang": "rust", "repo": "getreu/tp-note", "path": "/tpnote-lib/src/markup_language.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: getreu/tp-note path: /tpnote-lib/src/markup_language.rs //! Helper functions dealing with markup languages. use crate::config::LIB_CFG; use crate::settings::SETTINGS; use std::path::Path; /// The Markup language of the note content. #[derive(Eq, PartialEq, Debug, Clone)] pub enum MarkupLanguage...
code_fim
hard
{ "lang": "rust", "repo": "getreu/tp-note", "path": "/tpnote-lib/src/markup_language.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikialex/rendiation-legacy path: /rendium/src/core/component.rs use std::{any::Any, cell::RefCell, marker::PhantomData}; // use super::{Element, ElementHandle}; use arena::{Arena, Handle}; use arena_tree::ArenaTree; use rendiation_algebra::Vec2; type Event = winit::event::Event<'static, ()>; ...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation-legacy", "path": "/rendium/src/core/component.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn render(&self, list: &mut DisplayList) { todo!() } fn as_any(&self) -> &dyn Any { self } } type DisplayList = Vec<usize>; pub trait DocumentUnit: Any { type Props; /// receive event from outside, emit listener and modify self state fn event(&self, props: &Self::Props, event: &Eve...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation-legacy", "path": "/rendium/src/core/component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/selectors/build.rs /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/selectors/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(&mut file, "{{ static SET: ::phf::Set<&'static str> = ",).unwrap(); let mut set = phf_codegen::Set::new(); for name in ASCII_CASE_INSENSITIVE_HTML_ATTRIBUTES.split_whitespace() { set.entry(name); } set.build(&mut file).unwrap(); write!(&mut file, "; &SET }}").unwrap(...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/selectors/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ys)] pub fn caplength(&self) -> CAPLENGTH_R { CAPLENGTH_R::new((self.bits & 0xff) as u8) } }<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-usb1/src/caplength.rs #[doc = "Reader of register CAPLENGTH"] pub type R = crate::R<u8, super::CAPLENGTH>; #[doc = "Reader o...
code_fim
medium
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-usb1/src/caplength.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-usb1/src/caplength.rs #[doc = "Reader of register CAPLENGTH"] pub type R = crate::R<u8, super::CAPLENGTH>; #[doc = "Reader of fiel<|fim_suffix|>d as an offset to add to register base to find the beginning of the Operational Register"] #[inlin...
code_fim
medium
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-usb1/src/caplength.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jormungandr12/tns path: /contracts/resolver/src/test.rs mod tests { use crate::contract::{execute, instantiate, query}; use crate::error::ContractError; use crate::mock_querier::mock_dependencies; use cosmwasm_std::testing::{mock_env, mock_info}; use cosmwasm_std::{coins, fro...
code_fim
hard
{ "lang": "rust", "repo": "jormungandr12/tns", "path": "/contracts/resolver/src/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut deps = mock_dependencies(&[]); let msg = InstantiateMsg { interface_id: 1, registry_address: String::from("registry_address"), }; let info = mock_info("owner", &coins(0, "uusd")); instantiate(deps.as_mut(), mock_env(), info, msg).unw...
code_fim
hard
{ "lang": "rust", "repo": "jormungandr12/tns", "path": "/contracts/resolver/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: holochain/holochain-tracing path: /crates/tracing/src/span_wrap.rs use crate::{ span::{test_span, HSpan, NOOP_SPAN}, span_context::{EncodedSpanContext, HSpanContext}, }; use rustracing::{sampler::*, span::StartSpanOptions}; use rustracing_jaeger::{span::SpanContextState, Span as RjSpan, ...
code_fim
hard
{ "lang": "rust", "repo": "holochain/holochain-tracing", "path": "/crates/tracing/src/span_wrap.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> Self { data: sw.data, span_context: match sw.span_context { Some(c) => c.encode().ok().or_else(|| { warn!("Failed to decode SpanContext, throwing it away!"); None }), None => None, ...
code_fim
hard
{ "lang": "rust", "repo": "holochain/holochain-tracing", "path": "/crates/tracing/src/span_wrap.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> Self { props, link } } fn update(&mut self, msg: Self::Message) -> bool { match msg { Msg::ToggleSidebar => self.toggle_sidebar(), } true } fn change(&mut self, props: Self::Properties) -> bool { if self.props != props { se...
code_fim
hard
{ "lang": "rust", "repo": "chandero/patternfly-yew", "path": "/src/page.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chandero/patternfly-yew path: /src/page.rs use crate::logo::Logo; use crate::pagesidebar::PageSidebar; use yew::virtual_dom::VChild; use yew::Properties; use yew::{html, Children, Component, ComponentLink, Html}; #[derive(Clone, PartialEq, Properties)] pub struct Props { pub children: Chil...
code_fim
hard
{ "lang": "rust", "repo": "chandero/patternfly-yew", "path": "/src/page.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vmasdani/smart-garden path: /src/db_poller.rs use rusqlite::{params, Connection}; use std::sync::{Arc, Mutex}; use std::{thread, time::Duration}; use crate::model::*; use gpio_cdev::LineHandle; use chrono::prelude::*; pub fn poll_loop( conn: Arc<Mutex<Connection>>, relay_pin: Arc<Mutex...
code_fim
hard
{ "lang": "rust", "repo": "vmasdani/smart-garden", "path": "/src/db_poller.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut relay_pin = relay_pin.lock().unwrap(); relay_pin.set_value(0).unwrap(); println!("Watering done"); } } }, Err(_) => { ...
code_fim
hard
{ "lang": "rust", "repo": "vmasdani/smart-garden", "path": "/src/db_poller.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberzs/duku path: /src/pipeline/mod.rs // Oliver Berzs // https://github.com/oberzs/duku mod attachment; mod material; mod properties; mod render_pass; mod sampler; mod shader; mod uniforms; <|fim_suffix|>pub(crate) use attachment::Attachment; pub(crate) use render_pass::RenderPass; pub(crate)...
code_fim
medium
{ "lang": "rust", "repo": "oberzs/duku", "path": "/src/pipeline/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) use attachment::Attachment; pub(crate) use render_pass::RenderPass; pub(crate) use sampler::Sampler; pub(crate) use shader::ShaderConfig; pub(crate) use uniforms::Descriptor; pub(crate) use uniforms::ShaderConstants; pub(crate) use uniforms::ShaderLight; pub(crate) use uniforms::ShaderMaterial;...
code_fim
medium
{ "lang": "rust", "repo": "oberzs/duku", "path": "/src/pipeline/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3)); glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core)); glfw.window_hint(glfw::WindowHint::Samples(Some(4))); let (mut window, events) = glfw.create_window(SCR_WIDTH, SCR_HEIGHT, "Rusted Christmas tree", g...
code_fim
hard
{ "lang": "rust", "repo": "jacekbilski/rusted-christmas-tree", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jacekbilski/rusted-christmas-tree path: /src/main.rs extern crate gl; extern crate glfw; use std::f32::consts::{FRAC_PI_8, PI}; use std::sync::mpsc::Receiver; use fps_calculator::FpsCalculator; use observer::RenderLoopObserver; use xmas_tree::scene::Scene; use self::glfw::{Action, Context, Gl...
code_fim
hard
{ "lang": "rust", "repo": "jacekbilski/rusted-christmas-tree", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn process_events(main: &mut Main, window: &mut glfw::Window, events: &Receiver<(f64, glfw::WindowEvent)>, scene: &mut Scene) { let mut mouse_offset_x: f64 = 0.; let mut mouse_offset_y: f64 = 0.; for (_, event) in glfw::flush_messages(events) { let angle_change = FRAC_PI_8 / 4.; ...
code_fim
hard
{ "lang": "rust", "repo": "jacekbilski/rusted-christmas-tree", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: PartialOrd, F: FnMut(&T, &T) -> Ordering> SortBy<T, F> for [T] { fn adv_sort_by_mut(&mut self, compare: &mut F, algo: SortingAlgorithmn) { match algo { SortingAlgorithmn::Bubble => bubble_sort_by_mut(compare, self), SortingAlgorithmn::Quick => quick_sort_by_mut(...
code_fim
medium
{ "lang": "rust", "repo": "NorabX/rustils", "path": "/src/impls/sorting_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NorabX/rustils path: /src/impls/sorting_impl.rs use std::cmp::Ordering; use sorting::*; impl<T: Ord + Clone> Sort for [T] { fn adv_sort_mut(&mut self, algo: SortingAlgorithmn) { match algo { SortingAlgorithmn::Bubble => bubble_sort_mut(self), SortingAlgorithm...
code_fim
medium
{ "lang": "rust", "repo": "NorabX/rustils", "path": "/src/impls/sorting_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arnavion/fac-rs path: /src/solve/mod.rs Asks the user for confirmation, then applies the diff. /// /// Returns true if the diff was successfully applied or empty. pub(crate) async fn compute_and_apply_diff( local_api: &factorio_mods_local::Api, web_api: &factorio_mods_web::Api, mut config: cr...
code_fim
hard
{ "lang": "rust", "repo": "Arnavion/fac-rs", "path": "/src/solve/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arnavion/fac-rs path: /src/solve/mod.rs se anyhow::Context; mod web_reader; mod zip; /// Computes which old mods to uninstall and which new mods to install based on the given reqs. /// Asks the user for confirmation, then applies the diff. /// /// Returns true if the diff was successfully appl...
code_fim
hard
{ "lang": "rust", "repo": "Arnavion/fac-rs", "path": "/src/solve/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let solver_reqs = reqs.iter() .map(|(name, version_req)| { let is_base = name.0 == "base"; (name, factorio_mods_common::VersionReqMatcher { version_req: &version_req.0, is_base, }) }) .collect(); let solution = package::compute_solution(packages, &solver_reqs) ...
code_fim
hard
{ "lang": "rust", "repo": "Arnavion/fac-rs", "path": "/src/solve/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl std::fmt::Display for Direction { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Direction::Rotation(Rotation::Left) => write!(f, "L"), Direction::Rotation(Rotation::Right) => write!(f, "R"), Direction::Movement(len) =...
code_fim
hard
{ "lang": "rust", "repo": "aszecsei/AdventOfCode2019", "path": "/src/days/day17.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let delta_left = get_delta_for_direction(rotate(robot_dir, Rotation::Left)); if is_valid_position(robot_pos + delta_left, &map) { directions.push(Direction::Rotation(Rotation::Left)); robot_dir = rotate(robot_dir, Rotation::Left); continue; } ...
code_fim
hard
{ "lang": "rust", "repo": "aszecsei/AdventOfCode2019", "path": "/src/days/day17.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aszecsei/AdventOfCode2019 path: /src/days/day17.rs use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; use crate::helper::{replace_all_with, Point}; use crate::shared::*; // ====================================================== // DAY 17 // =================================...
code_fim
hard
{ "lang": "rust", "repo": "aszecsei/AdventOfCode2019", "path": "/src/days/day17.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> runtime .block_on(asset_id_db.create_mapping( &HostId::Hostname("fakehostname".to_owned()), "asset_id_a".into(), 1500, )) .expect("Mapping creation failed"); let mapping = runtime .block_on(asset_id_db.resolve_asset_id(&HostId::H...
code_fim
hard
{ "lang": "rust", "repo": "0xflotus/grapl", "path": "/src/rust/node-identifier/tests/assetdb_integration_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mapping = runtime .block_on(asset_id_db.resolve_asset_id(&HostId::Hostname("fakehostname".to_owned()), 1510)) .expect("Failed to resolve asset id mapping") .expect("Failed to resolve asset id mapping"); assert_eq!(mapping, "asset_id_a"); }<|fim_prefix|>// repo: 0xflotu...
code_fim
hard
{ "lang": "rust", "repo": "0xflotus/grapl", "path": "/src/rust/node-identifier/tests/assetdb_integration_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }