text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: naturemickey/chi-lang path: /projects/chic/src/grammar/parser/mod.rs use std::rc::Rc; include!("ParserNode.<|fim_suffix|>); include!("ParserNodeConcatenate.rs");<|fim_middle|>rs"); include!("ParserNodeType.rs"); include!("ParserNodeChildrenAlternate.rs"
code_fim
medium
{ "lang": "rust", "repo": "naturemickey/chi-lang", "path": "/projects/chic/src/grammar/parser/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>); include!("ParserNodeConcatenate.rs");<|fim_prefix|>// repo: naturemickey/chi-lang path: /projects/chic/src/grammar/parser/mod.rs use std::rc::Rc; include!("ParserNode.<|fim_middle|>rs"); include!("ParserNodeType.rs"); include!("ParserNodeChildrenAlternate.rs"
code_fim
medium
{ "lang": "rust", "repo": "naturemickey/chi-lang", "path": "/projects/chic/src/grammar/parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ParkMyCar/spiff-rs path: /src/twilio.rs use actix_rt::System; use actix_web::client::{Client, ClientBuilder, Connector}; use actix_web::web; use futures::future::lazy; use futures::future::Future; use openssl::ssl::{SslConnector, SslMethod}; use serde_derive::{Deserialize, Serialize}; use std::f...
code_fim
hard
{ "lang": "rust", "repo": "ParkMyCar/spiff-rs", "path": "/src/twilio.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] pub struct TwilioKeys { pub account_sid: Option<String>, pub auth_token: Option<String>, } #[derive(Debug, Deserialize)] pub struct TwilioConfig { pub twilio: Option<TwilioKeys>, } pub fn read_config_file(config_filename: &str) -> Result<TwilioConfig, toml::de::...
code_fim
hard
{ "lang": "rust", "repo": "ParkMyCar/spiff-rs", "path": "/src/twilio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> System::new("test") .block_on(lazy(|| { self.client .post(base_url) .send_form(&form_body) .map_err(|err| (println!("{:?}", err))) .and_then(|response| { println!("{:...
code_fim
hard
{ "lang": "rust", "repo": "ParkMyCar/spiff-rs", "path": "/src/twilio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn print_expression(e: Expression) -> String { match e { Expression::Assignment(e) => print_assignment_expression(e), Expression::Literal(l) => print_literal(l), Expression::BinaryExpression(b) => print_binary_expression(b), Expression::CallExpression(c) => print_call_e...
code_fim
hard
{ "lang": "rust", "repo": "pveyes/naskah", "path": "/printer/src/js.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> res.push_str(" else "); res.push_str(&x); res } None => String::from(""), }; if !inside_else { res.push_str(&insert_indent(depth)); } res.push_str("if ("); res.push_str(&print_expression(i.test)); res.push_str(") "); ...
code_fim
hard
{ "lang": "rust", "repo": "pveyes/naskah", "path": "/printer/src/js.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pveyes/naskah path: /printer/src/js.rs use parser::ast::*; fn insert_indent(depth: u8) -> String { let mut res = String::new(); let mut x = 0; if depth == 0 { return res; } loop { res.push_str(" "); x = x + 1; if x >= depth { br...
code_fim
hard
{ "lang": "rust", "repo": "pveyes/naskah", "path": "/printer/src/js.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helvm/unlambda-rs-jfrikker path: /src/unlambda.rs use crate::lexer::{self, lex}; use crate::parser::{TreeNode, parse}; use std::io::Write; use std::mem::swap; use std::rc::Rc; pub type ValueRef = Rc<Value>; pub type TreeRef = Rc<TreeNode>; type PStack = Vec<StackFrame>; pub enum Value { Do...
code_fim
hard
{ "lang": "rust", "repo": "helvm/unlambda-rs-jfrikker", "path": "/src/unlambda.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn apply(&mut self, func: ValueRef, arg: ValueRef) -> Result<ValueRef, Error> { match &*func { Value::Dot(c) => { write!(self.out, "{}", c).map_err(|e| Error::OutputError(e))?; Ok(arg) }, Value::I => Ok(arg), Value...
code_fim
hard
{ "lang": "rust", "repo": "helvm/unlambda-rs-jfrikker", "path": "/src/unlambda.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match err { lexer::Error::IllegalCharacter(c) => Error::IllegalCharacter(c), lexer::Error::UnexpectedEndOfInput => Error::UnexpectedEndOfInput } } } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { ...
code_fim
hard
{ "lang": "rust", "repo": "helvm/unlambda-rs-jfrikker", "path": "/src/unlambda.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: normano/rust-delay-queue path: /examples/basic_usage.rs extern crate delay_queue; use std::time::{Duration, Instant}; use std::thread; use delay_queue::{Delay, DelayQueue}; use chrono::Utc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; fn main() { let queue: DelayQueue...
code_fim
medium
{ "lang": "rust", "repo": "normano/rust-delay-queue", "path": "/examples/basic_usage.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Clone the queue and move it to the producer thread let mut producer_queue = queue.clone(); let producer_handle = thread::spawn(move || { // This item can only be popped after 3 seconds have passed producer_queue.push(Delay::for_duration("3s", Duration::from_secs(3))); ...
code_fim
hard
{ "lang": "rust", "repo": "normano/rust-delay-queue", "path": "/examples/basic_usage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // This item can only be popped after 5 seconds have passed producer_queue.push(Delay::for_duration("10s", Duration::from_secs(10))); }); consumer_handle.join().unwrap(); producer_handle.join().unwrap(); assert!(queue.is_empty()); }<|fim_prefix|>// repo: normano/rust-dela...
code_fim
hard
{ "lang": "rust", "repo": "normano/rust-delay-queue", "path": "/examples/basic_usage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Timer { senders: Vec<SignalSender<()>>, interval: Duration, } impl Timer { pub fn new(interval: Duration) -> Self { Self { senders: Vec::new(), interval, } } pub fn receiver(&mut self) -> SignalReceiver<()> { let receiver = ...
code_fim
medium
{ "lang": "rust", "repo": "hagsteel/pubsub", "path": "/src/timer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hagsteel/pubsub path: /src/timer.rs use sonr::sync::signal::{SignalSender, SignalReceiver, ReactiveSignalReceiver}; use std::thread; use std::time::Duration; pub type ReactiveTimerNotifier = ReactiveSignalReceiver<()>; pub type TimerNotifier = SignalReceiver<()>; <|fim_suffix|> pub fn recei...
code_fim
hard
{ "lang": "rust", "repo": "hagsteel/pubsub", "path": "/src/timer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swfsql/leetcode path: /src/_1313_decompress_run_length_encoded_list.rs //! # Decompress Run-Length Encoded List //! //! [![src]][srcurl] [![Tests]][testsurl] [![Doc]][docurl] [![Problem]][problemurl] //! //! [src]: https://img.shields.io/badge/source-swfsql/leetcode-8DA0CB?style=for-the-badge&la...
code_fim
hard
{ "lang": "rust", "repo": "swfsql/leetcode", "path": "/src/_1313_decompress_run_length_encoded_list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Idiomatic entry point. pub fn _decompress_rl_elist(nums: impl Iterator<Item = (usize, u8)>) -> impl Iterator<Item = u8> { nums.flat_map(|(freq, val)| std::iter::repeat(val).take(freq)) }<|fim_prefix|>// repo: swfsql/leetcode path: /src/_1313_decompress_run_length_encoded_list.rs //! # Decompress ...
code_fim
hard
{ "lang": "rust", "repo": "swfsql/leetcode", "path": "/src/_1313_decompress_run_length_encoded_list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn WdbNftPtrDestroy(owner_address: u64) { RUNTIME.block_on(NFTPTRLIB.lock().unwrap().ptr_destroy(owner_address)); } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }<|fim_prefix|>// repo: Phara0h/nft_ptr path: /impl/nft-ptr/src...
code_fim
hard
{ "lang": "rust", "repo": "Phara0h/nft_ptr", "path": "/impl/nft-ptr/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// # Safety /// ptr_object_type should contain a valid null-terminated string. #[no_mangle] pub unsafe extern "C" fn WdbNftPtrInitialize( owner_address: u64, caller_pc: u64, ptr_object_type: *const i8, ) { let ptr_object_type_str = CStr::from_ptr(ptr_object_type).to_str().unwrap(); RU...
code_fim
hard
{ "lang": "rust", "repo": "Phara0h/nft_ptr", "path": "/impl/nft-ptr/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Phara0h/nft_ptr path: /impl/nft-ptr/src/lib.rs #![feature(once_cell)] use nft_ptr_lib::{make_nft_ptr_lib, NftPtrLib, NftPtrLibTransport}; use std::ffi::CStr; use std::lazy::SyncLazy; use std::sync::Mutex; static RUNTIME: SyncLazy<tokio::runtime::Runtime> = SyncLazy::new(|| tokio::runtime::...
code_fim
hard
{ "lang": "rust", "repo": "Phara0h/nft_ptr", "path": "/impl/nft-ptr/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casey/intermodal path: /bin/gen/src/options.rs use crate::common::*; #[derive(StructOpt)] pub(crate) struct Options { #[structopt( long("bin"),<|fim_suffix|>e `imdl` binary.") )] pub(crate) bin: PathBuf, }<|fim_middle|> value_name("EXECUTABLE"), help("Path to th
code_fim
easy
{ "lang": "rust", "repo": "casey/intermodal", "path": "/bin/gen/src/options.rs", "mode": "psm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|>e `imdl` binary.") )] pub(crate) bin: PathBuf, }<|fim_prefix|>// repo: casey/intermodal path: /bin/gen/src/options.rs use crate::common::*; #[derive(StructOpt)] pub(crate) struct Options { #[structopt( long("bin"),<|fim_middle|> value_name("EXECUTABLE"), help("Path to th
code_fim
easy
{ "lang": "rust", "repo": "casey/intermodal", "path": "/bin/gen/src/options.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|> /// Consumes messages and sends them through the channel. /// /// # Errors /// /// This function can return [`KafkaError`](rdkafka::error::KafkaError) on /// unsuccessful poll. pub async fn consume(&mut self) -> KafkaResult<()> { let mut stream = self.consumer.start(); ...
code_fim
hard
{ "lang": "rust", "repo": "valff/kafka-bridge", "path": "/src/kafka/subscribe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let parsetest = json::parse(&data); if parsetest.is_err() { data = json::stringify(data); } if let Err(err) = self .sender .send(Message { topic: self.topic.clone(), gro...
code_fim
hard
{ "lang": "rust", "repo": "valff/kafka-bridge", "path": "/src/kafka/subscribe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valff/kafka-bridge path: /src/kafka/subscribe.rs use super::{ClientConfig, Error, Message}; use futures::prelude::*; use rdkafka::consumer::{Consumer as _, StreamConsumer}; use rdkafka::error::KafkaResult; use rdkafka::{Message as _, Offset, TopicPartitionList}; use std::str; use tokio::sync::mp...
code_fim
hard
{ "lang": "rust", "repo": "valff/kafka-bridge", "path": "/src/kafka/subscribe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let p2 = Post::new( "second", "post second", "mike", chrono::offset::Utc::now(), Uuid::new_v4(), ); db.add_post(p1); db.add_post(p2); let handlers = Handlers::new(db); let jmw = JsonAfterMiddleware; let mut router = Router::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "zhangmingkai4315/learning-rust", "path": "/rust-api/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangmingkai4315/learning-rust path: /rust-api/src/main.rs extern crate chrono; extern crate env_logger; extern crate iron; extern crate logger; extern crate router; extern crate serde; extern crate uuid; mod models; mod database; mod handler; use models::*; use database::Database; use hand...
code_fim
medium
{ "lang": "rust", "repo": "zhangmingkai4315/learning-rust", "path": "/rust-api/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f3/src/stm32f301/adc1/ofr2.rs #[doc = "Register `OFR2` reader"] pub type R = crate::R<OFR2_SPEC>; #[doc = "Register `OFR2` writer"] pub type W = crate::W<OFR2_SPEC>; #[doc = "Field `OFFSET2` reader - Data offset 2 for the channel programmed into bits OFFSE...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f301/adc1/ofr2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> OFFSET2_EN_W::new(self) } #[doc = "Writes raw bits to the register."] #[inline(always)] pub unsafe fn bits(&mut self, bits: u32) -> &mut Self { self.bits = bits; self } } #[doc = "ADC offset register2\n\nYou can [`read`](crate::generic::Reg::read) this register and g...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f301/adc1/ofr2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn pop(&mut self) -> i32 { self.stack.pop().unwrap_or(-1) } fn increment(&mut self, k: i32, val: i32) { // let n = if self.stack.len() < k as usize { self.stack.len() } else { k as usize }; let n = (k as usize).min(self.stack.len()); for i in 0..n { ...
code_fim
medium
{ "lang": "rust", "repo": "ultracold273/leetcode-rs", "path": "/src/contest_180/pr2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ultracold273/leetcode-rs path: /src/contest_180/pr2.rs struct CustomStack { max_size: usize, stack: Vec<i32> } impl CustomStack { fn new(max_size: i32) -> Self { Self { max_size: max_size as usize, stack: Vec::new() } } fn push(&mut self, x: i32) { if self....
code_fim
medium
{ "lang": "rust", "repo": "ultracold273/leetcode-rs", "path": "/src/contest_180/pr2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_algorithms(self) -> Vec<Box<dyn Algorithm>> { if self.transboundary { vec![Box::new(Staggered::new())] } else { vec![Box::new(Rasterized::new())] } } }<|fim_prefix|>// repo: RyanMeulenkamp/solplan-rust path: /src/model/constraints.rs use ...
code_fim
hard
{ "lang": "rust", "repo": "RyanMeulenkamp/solplan-rust", "path": "/src/model/constraints.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RyanMeulenkamp/solplan-rust path: /src/model/constraints.rs use druid::{Data, Lens}; use druid::im::Vector; use crate::model::orientation::Orientation; use crate::algorithm::{ algorithm::Algorithm, rasterized::Rasterized, staggered::Staggered }; use serde::{Serialize, Deserialize}; ...
code_fim
hard
{ "lang": "rust", "repo": "RyanMeulenkamp/solplan-rust", "path": "/src/model/constraints.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustfmt path: /tests/source/associated-types-bounds-wrapping.rs // Test proper wrapping of long associated typ<|fim_suffix|>ervice: 'static + Service<Request = WsCommand, Response = WsResponse, Error = ServerError>; }<|fim_middle|>e bounds pub trait HttpService { type WsS
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rustfmt", "path": "/tests/source/associated-types-bounds-wrapping.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Response = WsResponse, Error = ServerError>; }<|fim_prefix|>// repo: rust-lang/rustfmt path: /tests/source/associated-types-bounds-wrapping.rs // Test proper wrapping of long associated type bounds pub trait HttpService { type WsS<|fim_middle|>ervice: 'static + Service<Request = WsCommand,
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/rustfmt", "path": "/tests/source/associated-types-bounds-wrapping.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: namatoj/aoc2020 path: /src/day7.rs use std::collections::{HashMap, HashSet}; pub fn run(input: Vec<String>) { println!("Day 7"); println!("====="); println!("part one: {}", part_one(&input)); println!("part two: {}", part_two(&input)); } pub fn part_one(input: &[String]) -> u3...
code_fim
hard
{ "lang": "rust", "repo": "namatoj/aoc2020", "path": "/src/day7.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v: Vec<_> = v.iter().map(|x| x.to_string()).collect(); assert_eq!(4, part_one(&v)); } #[test] fn part2_example_1() { let v = vec![ "light red bags contain 1 bright white bag, 2 muted yellow bags.", "dark orange bags contain 3 bright white bags, 4 muted yellow bags.", ...
code_fim
hard
{ "lang": "rust", "repo": "namatoj/aoc2020", "path": "/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn part2_example_2() { let v = vec![ "shiny gold bags contain 2 dark red bags.", "dark red bags contain 2 dark orange bags.", "dark orange bags contain 2 dark yellow bags.", "dark yellow bags contain 2 dark green bags.", "dark green bags contain 2 dark b...
code_fim
hard
{ "lang": "rust", "repo": "namatoj/aoc2020", "path": "/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pop-os/debrepbuild path: /src/debian/info.rs use std::path::Path; pub fn get_debian_package_info(package: &Path) -> Option<(String, String)> { let mut filename = package.file_name()?.to_str()?; let mut underscore_pos = filename.find('_')?; let name = &filename[..underscore_pos]; ...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/debrepbuild", "path": "/src/debian/info.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn debian_version() { let package = Path::new("/some_/pa_th/to/name_version_arch.deb"); assert_eq!( get_debian_package_info(&package), Some(("name".to_owned(), "version".to_owned())) ); let package = Path::new("/some_/pa_th/to/name_v...
code_fim
medium
{ "lang": "rust", "repo": "pop-os/debrepbuild", "path": "/src/debian/info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: norcalli/typeracer.nvim path: /server/src/main.rs de, client_id: client.id, } } Command::JoinRandom => { client.state = PlayerState::default(); ParseAction::JoinLobby { lobby_code: PLA...
code_fim
hard
{ "lang": "rust", "repo": "norcalli/typeracer.nvim", "path": "/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // TODO(ashkan): we could group these to avoid redundant hashmap lookups... while let Some((client_id, command)) = command_buffer.pop_front() { debug!("[client={}] command: {:?}", client_id, command); let client = match clients.get_mut(&client_id) { ...
code_fim
hard
{ "lang": "rust", "repo": "norcalli/typeracer.nvim", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: canndrew/malk-2018 path: /src/core.old/term.rs { .. } | Term::EnumType { .. } | Term::NeverType, Term::FuncType { .. } | Term::CaseType { .. } | Term::NilType | => Occurances::Zero, Term::Pair { name, head, ...
code_fim
hard
{ "lang": "rust", "repo": "canndrew/malk-2018", "path": "/src/core.old/term.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: canndrew/malk-2018 path: /src/core.old/term.rs lf); redex_at_position.found } /* pub fn app_at_position(&self, position: Position) -> Option<&Ast<Term>> { if let Origin::Document { range, .. } = self.origin { if !range.contains(position) { ...
code_fim
hard
{ "lang": "rust", "repo": "canndrew/malk-2018", "path": "/src/core.old/term.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match &*pat.node { Pat::Unit => { match &*arg.node { Term::Unit => { return (body.clone(), None); }, _ => (), } }, Pat::Bind(name) => { let ident = Ast { node...
code_fim
hard
{ "lang": "rust", "repo": "canndrew/malk-2018", "path": "/src/core.old/term.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steamroller-airmash/airmash-ground-control path: /src/wing.rs //! Wingman, a component that attacks a player //! //! Once spawned, a wingman can only be shutdown by setting //! an atomic flag that's provided on startup. //! //! Right now, the wingman simply follows and shoots a player. //! It's ...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/airmash-ground-control", "path": "/src/wing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Wingman; impl Wingman { /// Spawn a wingman that connects to the associated URL and follows the target /// /// When the shutdown flag goes high, the wingman shuts down. /// /// We need to use the name of a target, not an ID, because the IDs for players /// seem to vary ...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/airmash-ground-control", "path": "/src/wing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/peak_index_in_mountain_array.rs pub struct Solution; impl Solution { pub fn peak_index_in_mountain_array(a: Vec<i32>) -> i32 { let mut low = 1; let mut high = a.len() - 2; while low < high { <|fim_suffix|>; ...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/peak_index_in_mountain_array.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; } else { high = mid; } } low as i32 } }<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/peak_index_in_mountain_array.rs pub struct Solution; impl Solution { pub fn peak_index_in_mountain_array(a: Vec<i32>) -> i32 { <|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/peak_index_in_mountain_array.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aautar/bitfenix-icon-sysstatus path: /src/image.rs use std::fs::File; pub fn load_png_image(filepath: &str) -> Vec<u8> { let decoder = png::Decoder::new(File::open(filepath).unwrap()); let (info, mut reader) = decoder.read_info().unwrap(); // Allocate the output buffer. let...
code_fim
medium
{ "lang": "rust", "repo": "aautar/bitfenix-icon-sysstatus", "path": "/src/image.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> result.push( ((rgb >> 8) & 0x00FF) as u8 ); result.push( (rgb & 0x00FF) as u8 ); } result }<|fim_prefix|>// repo: aautar/bitfenix-icon-sysstatus path: /src/image.rs use std::fs::File; pub fn load_png_image(filepath: &str) -> Vec<u8> { let decoder = png::Decoder::new(File::op...
code_fim
hard
{ "lang": "rust", "repo": "aautar/bitfenix-icon-sysstatus", "path": "/src/image.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( rsass( "div {\n color: rgb(255, $blue: 0, $green: 255);\n background: rgb(123, 45, 6);\n}\n" ) .unwrap(), "div {\n color: yellow;\n background: #7b2d06;\n}\n" ); } /// From "sass-spec/spec/basic/22_colors_with_alpha" #[test] fn t22_color...
code_fim
hard
{ "lang": "rust", "repo": "glebm/rsass", "path": "/tests/basic/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// From "sass-spec/spec/basic/45_str_insert" #[test] fn t45_str_insert() { assert_eq!( rsass( "div {\n bar: str-insert(\"abcd\", \"X\", 1);\n bar: str-insert(\"abcd\", \'X\', 1);\n bar: str-insert(\"abcd\", \'X\\\'fjd\\\'sk\', 1);\n bar: str-insert(\"abcd\", \"e\", 3);\n bar:...
code_fim
hard
{ "lang": "rust", "repo": "glebm/rsass", "path": "/tests/basic/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glebm/rsass path: /tests/basic/main.rs , "div {\n /* begin foo */\n margin: 1 2;\n /* end foo */\n /* begin foo */\n margin: 1 3;\n /* end foo */\n margin: 1 2 zee;\n margin: 1 kwd-y kwd-z;\n}\ndiv blip {\n hey: now;\n}\ndiv blip {\n hey: now;\n}\n\ndiv {\n /* begin hux */\n ...
code_fim
hard
{ "lang": "rust", "repo": "glebm/rsass", "path": "/tests/basic/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LegNeato/asciinema-rs path: /src/session.rs use crate::clock::{get_elapsed_seconds, Clock}; use crate::output_formats::Msg; use crate::terminal::{Height, Width}; use failure::Error; use std::boxed::Box; use std::collections::HashMap; use std::str; use std::sync::mpsc::Sender; pub struct Session...
code_fim
hard
{ "lang": "rust", "repo": "LegNeato/asciinema-rs", "path": "/src/session.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let duration = Duration::new(123, 4); let (tx, rx) = channel(); let mut session = make_mock_session(tx, true, None, Some(duration)); session .write_input("hello input".to_string().as_bytes()) .unwrap(); let result = rx.try_recv(); a...
code_fim
hard
{ "lang": "rust", "repo": "LegNeato/asciinema-rs", "path": "/src/session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut non_canonical_directory = TestDirectory::containing_roland().directory(); non_canonical_directory.mut_files().push({ let mut file = bazel_protos::remote_execution::FileNode::new(); file.set_name("roland".to_string()); file.set_digest((&TestData::roland().digest()).into())...
code_fim
hard
{ "lang": "rust", "repo": "foursquare/pants", "path": "/src/rust/engine/fs/src/store.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foursquare/pants path: /src/rust/engine/fs/src/store.rs ata::roland(); let dir = TempDir::new("store").unwrap(); let store = new_store(dir.path()); let hash = store .store_bytes(EntryType::File, testdata.bytes(), false) .wait() .unwrap(); assert_e...
code_fim
hard
{ "lang": "rust", "repo": "foursquare/pants", "path": "/src/rust/engine/fs/src/store.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foursquare/pants path: /src/rust/engine/fs/src/store.rs ning_roland()], ) } fn new_local_store<P: AsRef<Path>>(dir: P) -> Store { Store::local_only(dir, Arc::new(ResettablePool::new("test-pool-".to_string()))) .expect("Error creating local store") } fn new_store<P: AsRef<...
code_fim
hard
{ "lang": "rust", "repo": "foursquare/pants", "path": "/src/rust/engine/fs/src/store.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: serlo/serlo-he-spec path: /src/lib.rs mod plugins; pub use crate::plugins::*; #[cfg(test)] mod test { use crate::*; use uuid::Uuid; fn example_heading_doc() -> HEPluginInstance<Plugins> { Plugins::HeHeading(HeHeading { id: Uuid::new_v4(), caption: H...
code_fim
hard
{ "lang": "rust", "repo": "serlo/serlo-he-spec", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[should_panic] fn deserialize_wrong_plugin() { // state is in fact a markdown plugin -> should panic let doc = r#"{ "type": "@splish-me/editor-core/editable", "state": { "id": "a6f91bdc-403f-49d3-831d-5c0d09bfc28f", "cells": ...
code_fim
hard
{ "lang": "rust", "repo": "serlo/serlo-he-spec", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut x = 0; while x < config.len() { let cx = (x / chunk_size) * (chunk_size + 1); let mut y = 0; while y < config.len() { let cy = (y / chunk_size) * (chunk_size + 1); let chunk = extract_chunk_cfg_str(config, x, y, chunk_size); let ...
code_fim
hard
{ "lang": "rust", "repo": "bcongdon/advent_of_code_2017", "path": "/Day20-25/day21.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut cfg_chars: Vec<char> = Vec::new(); let chunk_len = chunk.len(); for x in 0..chunk_len { for y in 0..chunk.len() { cfg_chars.push(chunk[x][y] as char); } if x + 1 != chunk_len { cfg_chars.push('/'); } } cfg_chars.iter().col...
code_fim
hard
{ "lang": "rust", "repo": "bcongdon/advent_of_code_2017", "path": "/Day20-25/day21.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bcongdon/advent_of_code_2017 path: /Day20-25/day21.rs use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; type Config = Vec<Vec<u8>>; struct RuleMatcher { rules: HashMap<String, String>, } impl RuleMatcher { fn find_match(&mut self, cfg: String) -> String { ...
code_fim
hard
{ "lang": "rust", "repo": "bcongdon/advent_of_code_2017", "path": "/Day20-25/day21.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dotenv-linter/dotenv-linter path: /dotenv-linter/tests/common/args.rs pub fn with_default_args<'a>(args: &'a [&'a str]) -> Vec<&'a str> { let<|fim_suffix|>ush("--not-check-updates"); args }<|fim_middle|> mut args = args.to_vec(); args.p
code_fim
easy
{ "lang": "rust", "repo": "dotenv-linter/dotenv-linter", "path": "/dotenv-linter/tests/common/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ush("--not-check-updates"); args }<|fim_prefix|>// repo: dotenv-linter/dotenv-linter path: /dotenv-linter/tests/common/args.rs pub fn with_default_args<'a>(args: &'a [&'a str]) -> Vec<&'a str> { let<|fim_middle|> mut args = args.to_vec(); args.p
code_fim
easy
{ "lang": "rust", "repo": "dotenv-linter/dotenv-linter", "path": "/dotenv-linter/tests/common/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: olivernn/ff path: /src/index.rs use std::collections::HashMap; use std::convert::From; use std::fmt; use std::path::Path; use std::io::BufRead; use ignore::Walk; use jump::{Jumps, Jump}; use query::Query; pub type Node = String; #[derive(Debug)] pub struct Edge { pub path: String, pu...
code_fim
hard
{ "lang": "rust", "repo": "olivernn/ff", "path": "/src/index.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn push(&mut self, s: &str) { let jumps = Jumps::new(s); for jump in jumps { self.graph .entry(jump.source.prefix.to_owned()) .or_insert(HashMap::new()) .entry(jump.destination.character) .or_insert(Vec::n...
code_fim
hard
{ "lang": "rust", "repo": "olivernn/ff", "path": "/src/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for jump in jumps { self.graph .entry(jump.source.prefix.to_owned()) .or_insert(HashMap::new()) .entry(jump.destination.character) .or_insert(Vec::new()) .push(jump.into()); } } pub fn quer...
code_fim
hard
{ "lang": "rust", "repo": "olivernn/ff", "path": "/src/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: docknetwork/quaerit-machina path: /src/ttl.rs // deserialize an rdf turtle document into a rdf Graph #[cfg(test)] /// Panics if input is invalid ttl. pub fn from_ttl(src: &str) -> crate::rdf_graph::Graph { use crate::convert::rm_to_om::triple; use crate::rdf_graph::Graph; use rio_a...
code_fim
hard
{ "lang": "rust", "repo": "docknetwork/quaerit-machina", "path": "/src/ttl.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // <#green-goblin> // rel:enemyOf <#spiderman> ; // a foaf:Person ; # ipn the context of the Marvel universe // foaf:name "Green Goblin" . // <#spiderman> // rel:enemyOf <#green-goblin> ; // a foaf:P...
code_fim
hard
{ "lang": "rust", "repo": "docknetwork/quaerit-machina", "path": "/src/ttl.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: menzel/aoc2018 path: /day3/patches.rs use std::fs::File; use std::io::Read; fn main(){ let mut file = File::open("input.txt").expect("opening file"); let mut text = String::new(); file.read_to_string(&mut text).expect("reading file"); const MAX: usize = 1000; <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "menzel/aoc2018", "path": "/day3/patches.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn setpatch(x : i32, y : i32, w : i32, h : i32, patches: &mut Vec<Vec<u8>>){ //println!("{}{}{}{}",x,y,w,h); for xpos in x..(x+w) { for ypos in y..(y+h){ patches[ypos as usize][xpos as usize] += 1; } } }<|fim_prefix|>// repo: menzel/aoc2018 path: /day3/patches....
code_fim
hard
{ "lang": "rust", "repo": "menzel/aoc2018", "path": "/day3/patches.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> context.draw(&mut self.batch.all(), &screen); } pub fn load_map(&mut self, context: &mut Gfx2dContext, map: &MapFile) { self.map = MapGraphics::new(context, map); } pub fn load_sprites(&mut self, context: &mut Gfx2dContext) { let mut main: Vec<SpriteInfo> = Vec::n...
code_fim
hard
{ "lang": "rust", "repo": "gtgsantos/soldank", "path": "/src/render/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gtgsantos/soldank path: /src/render/game.rs use super::*; use gfx::SpriteData; use ini::Ini; use std::str::FromStr; pub struct GameGraphics { map: MapGraphics, soldier_graphics: SoldierGraphics, sprites: Vec<Vec<Sprite>>, batch: DrawBatch, } impl GameGraphics { pub fn new(_...
code_fim
hard
{ "lang": "rust", "repo": "gtgsantos/soldank", "path": "/src/render/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !path.exists() { fs::create_dir_all(&path).unwrap_or_else(|error| { panic!("Failed to create data directory {:?}: {:?}", path, error) }); } path }<|fim_prefix|>// repo: isgasho/subspace path: /crates/spartan-farmer/src/utils.rs use async_std::task; use std::fs;...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/subspace", "path": "/crates/spartan-farmer/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/subspace path: /crates/spartan-farmer/src/utils.rs use async_std::task; use std::fs; use std::path::PathBuf; pub(crate) fn spawn_blocking<F, T>(f: F) -> task::JoinHandle<T> where F: FnOnce() -> T + Send + 'static, T: Send + 'static, { task::spawn(async_global_executor::spawn...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/subspace", "path": "/crates/spartan-farmer/src/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl MultibootStructure { pub fn new(address: usize) -> MultibootStructure { MultibootStructure { address: address + ::KERNEL_BASE as usize, } } pub fn get(&self) -> BootInformation { unsafe { ::multiboot2::load(self.address) } } }<|fim_prefix|>// repo: Techno-coder/example_os path: /kernel...
code_fim
medium
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/utility/multiboot_structure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get(&self) -> BootInformation { unsafe { ::multiboot2::load(self.address) } } }<|fim_prefix|>// repo: Techno-coder/example_os path: /kernel/src/utility/multiboot_structure.rs use multiboot2::BootInformation; // This structure is needed as multiboot2's ModuleIter cannot be cloned. // See memor...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/utility/multiboot_structure.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Techno-coder/example_os path: /kernel/src/utility/multiboot_structure.rs use multiboot2::BootInformation; // This structure is needed as multiboot2's ModuleIter cannot be cloned. // See memory/huge_frame_allocators/huge_boot_bump_allocator for its // main usage <|fim_suffix|> pub fn get(&self)...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/example_os", "path": "/kernel/src/utility/multiboot_structure.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Tools, Info, Return, Exit, Enter, Up, Down, Left, Right, Red, Green, Yellow, Blue, Emanual, PictureSize, Subtitle, Stop, Rewind, Play, Paus, Play_Pause, Play_Pause2, Forward, Mode, Shuffle, U_SD, P...
code_fim
hard
{ "lang": "rust", "repo": "TheNeikos/infrared", "path": "/src/remotecontrol/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheNeikos/infrared path: /src/remotecontrol/mod.rs //! Library with some example remote controls #[cfg(feature = "nec")] pub mod nec; #[cfg(feature = "rc5")] pub mod rc5; #[cfg(feature = "rc6")] pub mod rc6; #[cfg(feature = "sbp")] pub mod sbp; use crate::ProtocolId; /// A trait describing a ...
code_fim
hard
{ "lang": "rust", "repo": "TheNeikos/infrared", "path": "/src/remotecontrol/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.custom_element.focus() } /// Open this modal by attaching directly to `document.body` with position /// absolutely positioned relative to an alread-connected `target` /// element. /// /// Because the Custom Element has a `blur` handler, we must invoke this before ...
code_fim
hard
{ "lang": "rust", "repo": "kprakhar27/finos_viz", "path": "/node_modules/@finos/perspective-viewer/dist/esm/@finos/perspective-vieux/src/rust/custom_elements/modal.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let elem_over_y = inner_height < rect_top + rect_height; let elem_over_x = inner_width < rect_left + rect_width; let target_over_x = inner_width < rect_left + width; let target_over_y = inner_height < rect_top + height; match (elem_over_y, elem_over_x, target_over_x, target_over_y) { ...
code_fim
hard
{ "lang": "rust", "repo": "kprakhar27/finos_viz", "path": "/node_modules/@finos/perspective-viewer/dist/esm/@finos/perspective-vieux/src/rust/custom_elements/modal.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoDart for u32 { fn into_dart(self) -> DartCObject { DartCObject { ty: DartCObjectType::DartInt32, value: DartCObjectValue { as_int32: self as i32, }, } } } impl IntoDart for i32 { fn into_dart(self) -> DartCObject { ...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/nekoton-flutter", "path": "/core/src/ffi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xdeafbeef/nekoton-flutter path: /core/src/ffi.rs use serde::{Deserialize, Serialize}; use std::ffi::CString; use std::mem::ManuallyDrop; use std::os::raw::{c_char, c_longlong, c_uchar, c_void}; /// cbindgen:ignore #[derive(Deserialize, Serialize)] pub enum StringResult { Ok(String), Er...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/nekoton-flutter", "path": "/core/src/ffi.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf-pacs path: /pacs/nrf5340-app-pac/src/ficr_s.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { _reserved0: [u8; 0x0200], #[doc = "0x200..0x22c - Device info"] pub info: INFO, _reserved1: [u8; 0xd4], #[doc = "0x300..0x400 - Unspecified"] pub tri...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf5340-app-pac/src/ficr_s.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|>:TRNG90B; #[doc = r"Cluster"] #[doc = "NIST800-90B RNG calibration data"] pub mod trng90b; #[doc = "XOSC32MTRIM (r) register accessor: an alias for `Reg<XOSC32MTRIM_SPEC>`"] pub type XOSC32MTRIM = crate::Reg<xosc32mtrim::XOSC32MTRIM_SPEC>; #[doc = "XOSC32M capacitor selection trim values"] pub mod xosc32m...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf5340-app-pac/src/ficr_s.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, request: tonic::Request<super::EssemblyClientRegistration>, ) -> Self::Future { let inner = self.0.clone(); let fut = async move { inner.register_client(reques...
code_fim
hard
{ "lang": "rust", "repo": "blittable/essembly", "path": "/essembly-interfaces/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blittable/essembly path: /essembly-interfaces/src/api.rs /// Essembly. Client Registration #[derive(Clone, PartialEq, ::prost::Message)] pub struct EssemblyClientRegistration { #[prost(message, optional, tag = "1")] pub client: ::std::option::Option<super::registration::Client>, #[pr...
code_fim
hard
{ "lang": "rust", "repo": "blittable/essembly", "path": "/essembly-interfaces/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct SpriteId(pub usize);<|fim_prefix|>// repo: samkellett/battles path: /src/render/sprites/mod.rs mod sprite; mod mesh; mod vertex; <|fim_middle|>pub use self::mesh::Mesh; pub use self::sprite::{ProgramSource, SpriteSource, Sprite}; pub use self::vertex::Vertex;
code_fim
medium
{ "lang": "rust", "repo": "samkellett/battles", "path": "/src/render/sprites/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samkellett/battles path: /src/render/sprites/mod.rs mod sprite; mod mesh; mod vertex; <|fim_suffix|>pub struct SpriteId(pub usize);<|fim_middle|>pub use self::mesh::Mesh; pub use self::sprite::{ProgramSource, SpriteSource, Sprite}; pub use self::vertex::Vertex;
code_fim
medium
{ "lang": "rust", "repo": "samkellett/battles", "path": "/src/render/sprites/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Error::Client(err) => Some(err), Error::Authentication => None, } } } impl Service { /// Create a new GraphQL service. pub(crate) fn new<T: Into<String>>(endpoint: T, cookie: CookieService) -> Self { Self { endpoint: end...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/web-client/src/service/graphql.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pedrotojal/automaat path: /src/web-client/src/service/graphql.rs //! The GraphQL service is a thin wrapper around a GraphQL-capable HTTP client. use crate::CookieService; use failure::{Compat, Fail}; use futures::future::Future; use graphql_client::{web, GraphQLQuery, Response}; use std::{error...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/web-client/src/service/graphql.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Service { /// Create a new GraphQL service. pub(crate) fn new<T: Into<String>>(endpoint: T, cookie: CookieService) -> Self { Self { endpoint: endpoint.into(), cookie, } } /// Perform a request to the GraphQL server. pub(crate) fn request<Q:...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/web-client/src/service/graphql.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match std::os::args().as_slice() { [_, ref left, ref right] => { match hex_xor(left, right) { Ok(stri) => println!("{}", stri), Err(_) => std::os::set_exit_status(2) } } _ => std::os::set_exit_status(1) } } fn hex_xor...
code_fim
medium
{ "lang": "rust", "repo": "mosesn/crypto", "path": "/1/2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(vec.as_slice().to_hex()) } fn hexify(first: &String, second: &String) -> Result<(Vec<u8>, Vec<u8>), FromHexError> { Ok((try!(first.as_slice().from_hex()), try!(second.as_slice().from_hex()))) }<|fim_prefix|>// repo: mosesn/crypto path: /1/2.rs extern crate serialize; extern crate core; use s...
code_fim
hard
{ "lang": "rust", "repo": "mosesn/crypto", "path": "/1/2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mosesn/crypto path: /1/2.rs extern crate serialize; extern crate core; use std::iter::Zip; use core::iter::Map; use core::slice::Items; use serialize::hex::FromHex; use serialize::hex::FromHexError; use serialize::hex::ToHex; fn main() { <|fim_suffix|> let aiter: Items<u8> = a.iter(); l...
code_fim
hard
{ "lang": "rust", "repo": "mosesn/crypto", "path": "/1/2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrew-d/deploy-flake path: /src/os/nixos.rs use kv_log_macro as log; use core::fmt; use serde::Deserialize; use std::{ borrow::Cow, path::{Path, PathBuf}, process::{Output, Stdio}, }; use ::log::kv::{self, ToValue}; use crate::{NixOperatingSystem, Verb}; /// A nixos operating sy...
code_fim
hard
{ "lang": "rust", "repo": "andrew-d/deploy-flake", "path": "/src/os/nixos.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }