text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> match (self, other) { (&String(ref s1), &String(ref s2)) if s1 == s2 => true, (&Whitespace(ref c1), &Whitespace(ref c2)) if c1 == c2 => true, (&Operator(ref c1), &Operator(ref c2)) if c1 == c2 => true, (&AtSymbol, &AtSymbol) => true, _ =>...
code_fim
hard
{ "lang": "rust", "repo": "Geal/rust-web", "path": "/src/compiler/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self { String(ref s) => write!(f.buf, "String({})", *s), Whitespace(ref c) => write!(f.buf, "Whitespace({})", *c), Operator(ref c) => write!(f.buf, "Operator({})", *c), AtSymbol => write!(f.buf, "AtSymbol") } } } impl Eq for Token...
code_fim
medium
{ "lang": "rust", "repo": "Geal/rust-web", "path": "/src/compiler/token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Geal/rust-web path: /src/compiler/token.rs use std::fmt; #[deriving(Clone)] pub enum Token { String(~str), Whitespace(char), Operator(char), AtSymbol } <|fim_suffix|> match *self { String(ref s) => write!(f.buf, "String({})", *s), Whitespace(ref c...
code_fim
medium
{ "lang": "rust", "repo": "Geal/rust-web", "path": "/src/compiler/token.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> src_path: SrcPath, frequency: Duration ) -> Result<(Handler, mpsc::Receiver<Result<Message, Error>>), Error> { let (notify_tx, notify_rx) = mpsc::channel(); let (thread_tx, thread_rx) = mpsc::channel(); let mut watcher: RecommendedWatcher = Watcher::new(notify_tx, frequency).ma...
code_fim
hard
{ "lang": "rust", "repo": "MitchellHansen/shade_runner", "path": "/src/watch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (loader, rx) = ComputeLoader::create(compute_path); (Loader::Compute(loader), rx) } }; let handle = thread::spawn(move || 'watch_loop: loop { if thread_rx.try_recv().is_ok() { break 'watch_loop; } if let Ok(notify::Debounced...
code_fim
hard
{ "lang": "rust", "repo": "MitchellHansen/shade_runner", "path": "/src/watch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MitchellHansen/shade_runner path: /src/watch.rs use crate::error::Error; use crate::layouts::Entry; use crate::CompiledShaders; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; use std::path::{Path, PathBuf}; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::thread;...
code_fim
hard
{ "lang": "rust", "repo": "MitchellHansen/shade_runner", "path": "/src/watch.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} #[wasm_bindgen] pub fn parse(rjs_config: &str, req_log: &str, bundle_config: &str) -> String { match RequireJsBuildConfig::from_generated_string(rjs_config) { Ok(rjs_conf) => { match BundleConfig::from_json_string(bundle_config) { Ok(bc) => { ...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/config-gen-web", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shakyShane/config-gen-web path: /src/lib.rs extern crate wasm_bindgen; extern crate rjs; use wasm_bindgen::prelude::*; use rjs::{RequireJsBuildConfig, ModuleData, BundleConfig}; <|fim_suffix|>#[wasm_bindgen] pub fn parse(rjs_config: &str, req_log: &str, bundle_config: &str) -> String { ma...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/config-gen-web", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>< 20)) | (((value as u32) & 0x01) << 20); self.w } } #[doc = "Reader of field `B149`"] pub type B149_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B149`"] pub struct B149_W<'a> { w: &'a mut W, } impl<'a> B149_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l562/sec_gtzc_mpcbb1/mpcbb1_vctr4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32l5/src/stm32l562/sec_gtzc_mpcbb1/mpcbb1_vctr4.rs s)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { se...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l562/sec_gtzc_mpcbb1/mpcbb1_vctr4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: berardino/rusty path: /src/main.rs extern crate gl; extern crate glfw; use glfw::*; use gl::types::*; use std::str; use std::ffi::CString; use std::ptr; use std::mem; // Vertex data const VERTEX_DATA: [GLfloat; 15] = [ 0.0, 0.5, 1.0, 0.0, 0.0, 0.5, -0.5, 0.0, 1.0, 0.0, -0.5, -0.5, ...
code_fim
hard
{ "lang": "rust", "repo": "berardino/rusty", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { // Clear the screen to black gl::ClearColor(0.3, 0.3, 0.3, 1.0); gl::Clear(gl::COLOR_BUFFER_BIT); // Draw a triangle from the 3 vertices gl::DrawArrays(gl::TRIANGLES, 0, 3); } window.swap_buffers(); for...
code_fim
hard
{ "lang": "rust", "repo": "berardino/rusty", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn link_program(vs: GLuint, fs: GLuint) -> GLuint { unsafe { let program = gl::CreateProgram(); gl::AttachShader(program, vs); gl::AttachShader(program, fs); gl::LinkProgram(program); // Get the link status let mut status = gl::FALSE as GLint; gl...
code_fim
hard
{ "lang": "rust", "repo": "berardino/rusty", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: inspier/stevia path: /bitvec/src/tests.rs sert_eq!(Bitvec::from(snd).bvnot(), Bitvec::from(fst)) } #[test] fn zero_to_all_set() { assert_eq!( Bitvec::all_set(BitWidth::w32()).bvnot(), Bitvec::zero(BitWidth::w32()) ); assert_eq!( Bitvec::zero(BitWidth::w32()).bvnot(), Bitvec...
code_fim
hard
{ "lang": "rust", "repo": "inspier/stevia", "path": "/bitvec/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: inspier/stevia path: /bitvec/src/tests.rs t_with(true, false, false); test_with(true, true, true); } #[test] fn simple() { assert_eq!( Bitvec::from(0b_0101_1010_1001_0110_u16) .bvand(&Bitvec::from(0b_0011_1100_0101_1010_u16)), Ok(Bitvec::from(0b_0001_1000_0001_0010_u16)) ) }...
code_fim
hard
{ "lang": "rust", "repo": "inspier/stevia", "path": "/bitvec/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Bitvec::from(0x_FEDC_BA98_u32).bvashr(16), Ok(Bitvec::from(0x_FFFF_FEDC_u32)) ) } #[test] fn shift_by_zero() { assert_eq!(Bitvec::from(42_u32).bvashr(0), Ok(Bitvec::from(42_u32))) } #[test] fn shift_overflow() { assert!(Bitvec::from(1337_u32).bvashr(32).is_err()); asser...
code_fim
hard
{ "lang": "rust", "repo": "inspier/stevia", "path": "/bitvec/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charleschege/TuringDB path: /TuringDB-Server/src/errors.rs use custom_codes::DbOps; use turingdb_helpers::TuringOp; /// Handles converting an error to a common error syntax `[TuringDB::<TuringOp>::(ERROR)-{error}]` pub(crate) fn format_error(op: &TuringOp, error: &any<|fim_suffix|> op, ...
code_fim
medium
{ "lang": "rust", "repo": "charleschege/TuringDB", "path": "/TuringDB-Server/src/errors.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> op, custom_codes::try_downcast(error) ); DbOps::EncounteredErrors(unhandled_error) }<|fim_prefix|>// repo: charleschege/TuringDB path: /TuringDB-Server/src/errors.rs use custom_codes::DbOps; use turingdb_helpers::TuringOp; /// Handles converting an error to a common error syntax `[T...
code_fim
medium
{ "lang": "rust", "repo": "charleschege/TuringDB", "path": "/TuringDB-Server/src/errors.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alxolr/rust_land path: /patern_matching/src/main.rs fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(i) => Some(i + 1), } } <|fim_suffix|> match some_u8_value { Some(3) => println!("three"), _ => (), } if let Some(3) =...
code_fim
medium
{ "lang": "rust", "repo": "alxolr/rust_land", "path": "/patern_matching/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(3) = some_u8_value { println!("three"); } }<|fim_prefix|>// repo: alxolr/rust_land path: /patern_matching/src/main.rs fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(i) => Some(i + 1), } } fn main() { <|fim_middle|> let fiv...
code_fim
hard
{ "lang": "rust", "repo": "alxolr/rust_land", "path": "/patern_matching/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: M-Isonni/guessing_game path: /src/main.rs use std::io; use std::cmp::Ordering; use rand::Rng; fn main(){ println!("Guess the number"); let secret_number = rand::thread_rng().gen_range(1,101); <|fim_suffix|> println!("your guess: {}", guess); match guess.cmp(&secret...
code_fim
hard
{ "lang": "rust", "repo": "M-Isonni/guessing_game", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match guess.cmp(&secret_number){ Ordering::Less=>println!("too small"), Ordering::Greater=>println!("too great"), Ordering::Equal=>{println!("win"); break;} } } }<|fim_prefix|>// repo: M-Isonni/guessing_game path: /src/main.rs use std::io; use std...
code_fim
medium
{ "lang": "rust", "repo": "M-Isonni/guessing_game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let decrypted_string = encrypted_input.original_string().expect(""); println!("Your original string: {}", decrypted_string); }<|fim_prefix|>// repo: rohanpaspallu/Web-Development-with-Rocket path: /Chapter01/04Crates/src/main.rs use our_package::cipher::{rot13, rsa, Cipher}; use std::io; fn main...
code_fim
medium
{ "lang": "rust", "repo": "rohanpaspallu/Web-Development-with-Rocket", "path": "/Chapter01/04Crates/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rohanpaspallu/Web-Development-with-Rocket path: /Chapter01/04Crates/src/main.rs use our_package::cipher::{rot13, rsa, Cipher}; use std::io; fn main() { println!("Input the string you want to encrypt:"); let mut user_input = String::new(); io::stdin() .read_line(&mut user_i...
code_fim
hard
{ "lang": "rust", "repo": "rohanpaspallu/Web-Development-with-Rocket", "path": "/Chapter01/04Crates/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sblackshear/libra path: /config/management/src/lib.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] <|fim_suffix|>#[macro_export] macro_rules! execute_command { ($obj:ident, $command:path, $expected_name:path) => { if le...
code_fim
hard
{ "lang": "rust", "repo": "sblackshear/libra", "path": "/config/management/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! execute_command { ($obj:ident, $command:path, $expected_name:path) => { if let $command(cmd) = $obj { cmd.execute() } else { Err(Error::UnexpectedCommand( $expected_name.to_string(), CommandName::from(...
code_fim
medium
{ "lang": "rust", "repo": "sblackshear/libra", "path": "/config/management/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Item for Repository {} impl Item for CommitRepository {} #[async_trait] pub trait Search<T: GitHubRequest, R: Item> { async fn search(&self) -> Result<SearchResponse<R>, Box<dyn Error>>; }<|fim_prefix|>// repo: Nojpg/GitHubDrainer path: /src/search/mod.rs use std::error::Error; use async_trai...
code_fim
hard
{ "lang": "rust", "repo": "Nojpg/GitHubDrainer", "path": "/src/search/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nojpg/GitHubDrainer path: /src/search/mod.rs use std::error::Error; use async_trait::async_trait; use serde::Deserialize; use crate::entities::{Repository, CommitRepository}; <|fim_suffix|>#[async_trait] pub trait Search<T: GitHubRequest, R: Item> { async fn search(&self) -> Result<SearchR...
code_fim
hard
{ "lang": "rust", "repo": "Nojpg/GitHubDrainer", "path": "/src/search/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexPikalov/cdrs-async path: /src/frame_channel.rs use std::{ io, pin::Pin, task::{Context, Poll}, }; use async_std::{ io::{IoSlice, Write}, prelude::*, }; use cassandra_proto::frame::{parser_async::parse_frame_async, Frame, IntoBytes}; use futures::{sink::Sink, stream::Stream}; use l...
code_fim
hard
{ "lang": "rust", "repo": "AlexPikalov/cdrs-async", "path": "/src/frame_channel.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: CDRSTransport> Write for FrameChannel<T> { fn poll_write( mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<io::Result<usize>> { Pin::new(&mut self.transport).poll_write(cx, buf) } fn poll_write_vectored( mut self: Pin<&mut Self>, cx: &mut Conte...
code_fim
hard
{ "lang": "rust", "repo": "AlexPikalov/cdrs-async", "path": "/src/frame_channel.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (flags, parens) = extract_pioneers(bits); PioneerFamily { nnd: From::from(flags), parens: Parens::new(parens), } } } impl<N> ExternalByteSize for PioneerFamily<N> where N: ExternalByteSize { fn external_byte_size(&self) -> u64 { self....
code_fim
hard
{ "lang": "rust", "repo": "sile/succ", "path": "/src/tree/balanced_parens/parentheses.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/succ path: /src/tree/balanced_parens/parentheses.rs use bitwise; use bitwise::Bit; use bitwise::Index; use bitwise::fixnum::Fixnum; use bitwise::fixnum::FixnumLike; use bitwise::ops::NndOne; use bitwise::ops::GetClose; use bitwise::ops::ExternalByteSize; pub type Block = u64; pub type Bit...
code_fim
hard
{ "lang": "rust", "repo": "sile/succ", "path": "/src/tree/balanced_parens/parentheses.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut diff = HashMap::new(); let mut word = first_word; let mut best_move = get_best_move(&word.clone()); while !best_move.is_none() { let best_move_word = best_move.unwrap(); solution.push(best_move_word); diff = word.get_occurrence_diff(best_move_word); ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/desafio-letras", "path": "/src/solution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/desafio-letras path: /src/solution.rs use std::collections::HashMap; use crate::word::Word; use crate::WORD_BANK; pub fn get_best_move(word: &Word) -> Option<&'static Word> { for entry in WORD_BANK.iter() { if word.contains(&entry) { return Some(entry); ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/desafio-letras", "path": "/src/solution.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[actix_web::main] async fn main() -> io::Result<()> { env::set_var("RUST_LOG", "info"); env_logger::init(); HttpServer::new(|| { App::new() .wrap(middleware::Logger::default()) .service(web::resource("/on").wrap(AddMsg::enabled()).to(index)) .servi...
code_fim
hard
{ "lang": "rust", "repo": "sjbwylbs/examples", "path": "/basics/middleware-ext-mut/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sjbwylbs/examples path: /basics/middleware-ext-mut/src/main.rs use std::{env, io}; use actix_web::{ middleware, web::{self, ReqData}, App, HttpResponse, HttpServer, }; mod add_msg; use crate::add_msg::{AddMsg, Msg}; <|fim_suffix|> HttpServer::new(|| { App::new() ...
code_fim
hard
{ "lang": "rust", "repo": "sjbwylbs/examples", "path": "/basics/middleware-ext-mut/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> CityInfo { country_name: if buff.len() > 0 { buff[0] } else { "" }, region_name: if buff.len() > 1 { buff[1] } else { "" }, city_name: if buff.len() > 2 { buff[2] } else { "" }, owner_domain: if buff.len() > 3 { buff[3] } else { "" }, isp...
code_fim
medium
{ "lang": "rust", "repo": "luyikk/ipdb", "path": "/src/reader/city.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luyikk/ipdb path: /src/reader/city.rs use serde::Serialize; #[derive(Debug, Serialize)] pub struct CityInfo<'a>{ pub country_name:&'a str, pub region_name:&'a str, pub city_name:&'a str, pub owner_domain:&'a str, pub isp_domain:&'a str, pub latitude:&'a str, pub long...
code_fim
medium
{ "lang": "rust", "repo": "luyikk/ipdb", "path": "/src/reader/city.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn take_opt_unchecked( &self, indices: impl Iterator<Item = Option<usize>>, capacity: Option<usize>, ) -> Self where Self: std::marker::Sized, { let ca: CategoricalChunked = self.deref().take_opt_unchecked(indices, capacity).into(); ca...
code_fim
hard
{ "lang": "rust", "repo": "vaaaaanquish/polars", "path": "/polars/polars-core/src/chunked_array/ops/take.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vaaaaanquish/polars path: /polars/polars-core/src/chunked_array/ops/take.rs unwrap_or($indices.size_hint().0); let mut builder = $builder::new($self.name(), capacity); let taker = $self.take_rand(); for opt_idx in $indices { match opt_idx { So...
code_fim
hard
{ "lang": "rust", "repo": "vaaaaanquish/polars", "path": "/polars/polars-core/src/chunked_array/ops/take.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let capacity = capacity.unwrap_or(indices.size_hint().0); let fact = capacity as f32 / self.len() as f32 * 1.2; let values_cap = (capacity as f32 * fact) as usize; let mut builder = Utf8ChunkedBuilder::new(self.name(), capacity, values_cap); let taker = self.take_r...
code_fim
hard
{ "lang": "rust", "repo": "vaaaaanquish/polars", "path": "/polars/polars-core/src/chunked_array/ops/take.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// True, if users joining the chat via the link need to be approved by chat administrators. /// If True, member_limit can't be specified pub fn creates_join_request(mut self, value: bool) -> Self { self.creates_join_request = Some(value); self } } impl Method for CreateCh...
code_fim
hard
{ "lang": "rust", "repo": "tg-rs/tgbot", "path": "/src/methods/chat/invite_link/create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let request = CreateChatInviteLink::new(1) .name("test") .expire_date(0) .member_limit(1) .creates_join_request(false) .into_request(); assert_eq!(request.get_method(), RequestMethod::Post); assert_eq!( request...
code_fim
hard
{ "lang": "rust", "repo": "tg-rs/tgbot", "path": "/src/methods/chat/invite_link/create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tg-rs/tgbot path: /src/methods/chat/invite_link/create.rs use crate::{ methods::Method, request::Request, types::{ChatId, ChatInviteLink, Integer}, }; use serde::Serialize; /// Create an additional invite link for a chat /// /// The bot must be an administrator in the chat for this ...
code_fim
hard
{ "lang": "rust", "repo": "tg-rs/tgbot", "path": "/src/methods/chat/invite_link/create.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tokens = Arc::new(RwLock::new(MruHashmap::with_capacity(250))); let mut handlebars = Handlebars::new(); handlebars .register_template_file( "top_artists", format!("{}/top_artists.hbs", CONFIG.template_dir), ) ...
code_fim
hard
{ "lang": "rust", "repo": "lperson/spotifytops", "path": "/src/lib/app/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut handlebars = Handlebars::new(); handlebars .register_template_file( "top_artists", format!("{}/top_artists.hbs", CONFIG.template_dir), ) .unwrap(); handlebars .register_template_file( ...
code_fim
hard
{ "lang": "rust", "repo": "lperson/spotifytops", "path": "/src/lib/app/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lperson/spotifytops path: /src/lib/app/state.rs use super::super::CONFIG; use handlebars::Handlebars; use hyper::{client::HttpConnector, Client}; use hyper_tls::HttpsConnector; use std::sync::{Arc, RwLock}; use super::super::mru_hashmap::MruHashmap; lazy_static! { pub static ref STATE: St...
code_fim
hard
{ "lang": "rust", "repo": "lperson/spotifytops", "path": "/src/lib/app/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pstiasny/notml path: /compiler/src/sem.rs xprs.iter().map(f).collect(); Seq(exprsm?) }, }; Ok(node) } } impl<A> GFun<A> { pub fn signature(&self) -> &AFunSig { &self.0 } pub fn signature_rc(&self) -> Rc<AFunSig> { Rc::clone(&self.0) } ...
code_fim
hard
{ "lang": "rust", "repo": "pstiasny/notml", "path": "/compiler/src/sem.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn nullary() { let p = Program::new() .define("f", vec!["x", "z"], Expr::call("f", vec![Expr::var("y"), Expr::var("x")])) .define("y", vec![], Expr::number(1)) .define("main", vec![], Expr::number(1)); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "pstiasny/notml", "path": "/compiler/src/sem.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( program_to_sem( &Program::new() .define("f", vec!["x", "y"], Expr::call("f", vec![Expr::var("y"), Expr::var("x")])) .define("main", vec![], Expr::number(1)), &get_rt(), ), ...
code_fim
hard
{ "lang": "rust", "repo": "pstiasny/notml", "path": "/compiler/src/sem.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(result, expected) } #[test] fn exec_no_output() { let result = internal_exec_cmd("true", &[]); let expected = Some(CommandOutput { stdout: String::from(""), stderr: String::from(""), }); assert_eq!(result, expected) ...
code_fim
hard
{ "lang": "rust", "repo": "youssefhabri/starship", "path": "/src/utils.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: youssefhabri/starship path: /src/utils.rs use std::fs::File; use std::io::{Read, Result}; use std::path::Path; use std::process::Command; /// Return the string contents of a file pub fn read_file<P: AsRef<Path>>(file_name: P) -> Result<String> { let mut file = File::open(file_name)?; le...
code_fim
hard
{ "lang": "rust", "repo": "youssefhabri/starship", "path": "/src/utils.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/gitoxide path: /git-actor/src/signature/mod.rs mod _ref { use crate::{signature::decode, Signature, SignatureRef}; impl<'a> SignatureRef<'a> { /// Deserialize a signature from the given `data`. pub fn from_bytes<E>(data: &'a [u8]) -> Result<SignatureRef<'a>, n...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/gitoxide", "path": "/git-actor/src/signature/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use bstr::{BStr, ByteSlice}; use quick_error::quick_error; use crate::{Signature, SignatureRef, SPACE}; quick_error! { /// The Error produced by [`Signature::write_to()`]. #[derive(Debug)] #[allow(missing_docs)] enum Error { IllegalCharacter { ...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/gitoxide", "path": "/git-actor/src/signature/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } ::core::mem::transmute(CreateMDIWindowW( lpclassname.into_param().abi(), lpwindowname.into_param().abi(), ::core::mem::transmute(dwstyle), ::core::mem::transmute(x), ::core::mem::transmute(y), ::core::mem::transmute(...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } ::core::mem::transmute(LookupIconIdFromDirectory(::core::mem::transmute(presbits), ficon.into_param().abi())) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(feature = "Win32_Foundation")] #[inline] pub unsafe fn LookupIconIdFromDirectoryEx<'a, Param1:...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/UI/WindowsAndMessaging/mod.rs const STATE_SYSTEM_SELFVOICING: u32 = 524288u32; pub const STATE_SYSTEM_SIZEABLE: u32 = 131072u32; pub const STATE_SYSTEM_TRAVERSED: u32 = 8388608u32; pub const STATE_SYSTEM_VALID: u32 = 1073741823u32; pub const S...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for r in 0..rows_out { let (row, data) = rx.recv().expect("Error receiving data from thread."); output.set_row_data(row, data); if verbose { progress = (100.0_f64 * r as f64 / (rows_out - 1) as f64) as usiz...
code_fim
hard
{ "lang": "rust", "repo": "jblindsay/whitebox-tools", "path": "/whitebox-tools-app/src/tools/gis_analysis/aggregate_raster.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-tools-app/src/tools/gis_analysis/aggregate_raster.rs ut_file = String::new(); let mut output_file = String::new(); let mut agg_factor = 2isize; let mut agg_type = String::from("mean"); if args.len() == 0 { retu...
code_fim
hard
{ "lang": "rust", "repo": "jblindsay/whitebox-tools", "path": "/whitebox-tools-app/src/tools/gis_analysis/aggregate_raster.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jblindsay/whitebox-tools path: /whitebox-tools-app/src/tools/gis_analysis/aggregate_raster.rs description: description, toolbox: toolbox, parameters: parameters, example_usage: usage, } } } impl WhiteboxTool for AggregateRaster { fn get_source...
code_fim
hard
{ "lang": "rust", "repo": "jblindsay/whitebox-tools", "path": "/whitebox-tools-app/src/tools/gis_analysis/aggregate_raster.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<V: VectorTrait> BBall<V> { pub fn new(verts: &[V], pos: V) -> Self { let radius = verts .iter() .map(|v| v.norm_sq()) .fold(Field::NAN, Field::max) .sqrt(); Self { pos, radius } } }<|fim_prefix|>// repo: akuczala/4d-game path: /...
code_fim
medium
{ "lang": "rust", "repo": "akuczala/4d-game", "path": "/src/draw/clipping/bball.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akuczala/4d-game path: /src/draw/clipping/bball.rs use crate::vector::{Field, VectorTrait}; <|fim_suffix|>impl<V: VectorTrait> BBall<V> { pub fn new(verts: &[V], pos: V) -> Self { let radius = verts .iter() .map(|v| v.norm_sq()) .fold(Field::NAN, ...
code_fim
medium
{ "lang": "rust", "repo": "akuczala/4d-game", "path": "/src/draw/clipping/bball.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Floor-Gang/auto-slowdown path: /src/bot/commands.rs use crate::bot::utils::*; use crate::bot::Config; use crate::bot::DataBase; // use crate::config::Config; use serenity::{ framework::standard::{ macros::{command, group}, Args, CommandResult, }, model::prelude::*, ...
code_fim
hard
{ "lang": "rust", "repo": "Floor-Gang/auto-slowdown", "path": "/src/bot/commands.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } // WIP #[command] async fn toggle(ctx: &Context, _msg: &Message) -> CommandResult { let toggle_value; { let data_read = ctx.data.read().await; let db_lock = Arc::clone(&data_read.get::<Config>().unwrap()); let mut config = db_lock.write().await; confi...
code_fim
hard
{ "lang": "rust", "repo": "Floor-Gang/auto-slowdown", "path": "/src/bot/commands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nixpulvis/hell path: /8/dealer/evolution/src/interact/observe/feed_observation/wire.rs use evolution_wire as wire; use game::*; use interact::*; use object::*; impl wire::ToWire<wire::remote::State> for FeedObservation { fn to_wire(&self) -> wire::remote::State { wire::remote::St...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/8/dealer/evolution/src/interact/observe/feed_observation/wire.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(1, *feeding.current_player.id); assert_eq!(2, *feeding.opponents[0].id); assert_eq!(3, *feeding.opponents[1].id); assert_eq!(25, *feeding.watering_hole); let observed = FeedObservation::from_wire(feeding).unwrap(); assert_eq!(2, observed.opponen...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/8/dealer/evolution/src/interact/observe/feed_observation/wire.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use evolution_wire::{self as wire, FromWire}; use interact::*; #[test] fn observed_from_wire_feeding() { let feeding = wire::Feeding { current_player: wire::Player { id: wire::NaturalPlus::new(1).unwrap(), specie...
code_fim
hard
{ "lang": "rust", "repo": "nixpulvis/hell", "path": "/8/dealer/evolution/src/interact/observe/feed_observation/wire.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nusic-fm/mirror-contracts path: /contracts/mirror_gov/src/testing/tests.rs _eq!(res, StdError::generic_err("Nothing to withdraw")); // voting info has been deleted assert!(poll_voter_read(&deps.storage, 1u64) .load( deps.api .addr_canonicalize(&TEST_V...
code_fim
hard
{ "lang": "rust", "repo": "nusic-fm/mirror-contracts", "path": "/contracts/mirror_gov/src/testing/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nusic-fm/mirror-contracts path: /contracts/mirror_gov/src/testing/tests.rs e_info.locked_balance, vec![]); } // helper to confirm the expected create_poll response fn assert_create_poll_result( poll_id: u64, end_time: u64, creator: &str, execute_res: Response, deps: Deps, ) ...
code_fim
hard
{ "lang": "rust", "repo": "nusic-fm/mirror-contracts", "path": "/contracts/mirror_gov/src/testing/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut deps = mock_dependencies(&[]); mock_instantiate(deps.as_mut()); let voter_0_addr_raw = CanonicalAddr::from(vec![ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
code_fim
hard
{ "lang": "rust", "repo": "nusic-fm/mirror-contracts", "path": "/contracts/mirror_gov/src/testing/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/hackc/ir/ir_core/type_const.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <|fim_suffix|>use crate::TypedValue; #[derive...
code_fim
easy
{ "lang": "rust", "repo": "facebook/hhvm", "path": "/hphp/hack/src/hackc/ir/ir_core/type_const.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct TypeConstant<'a> { pub name: Str<'a>, pub initializer: Option<TypedValue>, pub is_abstract: bool, }<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/hackc/ir/ir_core/type_const.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is...
code_fim
easy
{ "lang": "rust", "repo": "facebook/hhvm", "path": "/hphp/hack/src/hackc/ir/ir_core/type_const.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MartenCatcher/mongo-rust-driver path: /src/bson/encoder/mod.rs //! Encoder mod error; mod serde; pub use self::{ error::{EncoderError, EncoderResult}, serde::Encoder, }; use std::{io::Write, iter::IntoIterator, mem}; use byteorder::{LittleEndian, WriteBytesExt}; use chrono::Timelike;...
code_fim
hard
{ "lang": "rust", "repo": "MartenCatcher/mongo-rust-driver", "path": "/src/bson/encoder/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] fn write_f64<W: Write + ?Sized>(writer: &mut W, val: f64) -> EncoderResult<()> { writer.write_f64::<LittleEndian>(val).map_err(From::from) } #[cfg(feature = "decimal128")] #[inline] fn write_f128<W: Write + ?Sized>(writer: &mut W, val: Decimal128) -> EncoderResult<()> { let raw = val.to...
code_fim
hard
{ "lang": "rust", "repo": "MartenCatcher/mongo-rust-driver", "path": "/src/bson/encoder/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let raw = val.to_raw_bytes_le(); writer.write_all(&raw).map_err(From::from) } fn encode_array<W: Write + ?Sized>(writer: &mut W, arr: &[Bson]) -> EncoderResult<()> { let mut buf = Vec::new(); for (key, val) in arr.iter().enumerate() { encode_bson(&mut buf, &key.to_string(), val)?;...
code_fim
hard
{ "lang": "rust", "repo": "MartenCatcher/mongo-rust-driver", "path": "/src/bson/encoder/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tmp = it.next().expect("unexpected EOF"); if let InterpolPart::Literal(astn) = tmp { assert_eq!(astn.syntax().text(), x); } else { unreachable!("unexpected interpol {:?}", tmp); } } let inp = r#"./a/b/${"c...
code_fim
hard
{ "lang": "rust", "repo": "nix-community/rnix-parser", "path": "/src/ast/path_util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nix-community/rnix-parser path: /src/ast/path_util.rs use crate::{ast::AstToken, kinds::SyntaxKind::*}; use rowan::{ast::AstNode as OtherAstNode, NodeOrToken}; use crate::ast; use super::{InterpolPart, PathContent}; impl ast::nodes::Path { pub fn parts(&self) -> impl Iterator<Item = Inter...
code_fim
hard
{ "lang": "rust", "repo": "nix-community/rnix-parser", "path": "/src/ast/path_util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub trait EuclideanSpace: Copy + Clone where Self: Array<Elem=<Self as EuclideanSpace>::Scalar>, Self: Add<<Self as EuclideanSpace>::Diff, Output=Self>, Self: Sub<<Self as EuclideanSpace>::Diff, Output=Self>, Self: Sub<Self, Output=<Self as EuclideanSpace>::Diff>, ...
code_fim
hard
{ "lang": "rust", "repo": "Shirataki2/competitive_submissions", "path": "/abc189/src/bin/e.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shirataki2/competitive_submissions path: /abc189/src/bin/e.rs orSpace>::Scalar> for $Name<T> { type Output = Self; fn mul(self, rhs: <Self as VectorSpace>::Scalar) -> Self::Output { let mut res = self; for i in 0...
code_fim
hard
{ "lang": "rust", "repo": "Shirataki2/competitive_submissions", "path": "/abc189/src/bin/e.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self[0][0] } fn len_row() -> usize { Self::Row::len() } fn len_col() -> usize { Self::Column::len() } fn get_row(self, r: usize) -> Self::Row; fn transpose(self) -> Self::Transpose; } pub trait SqMatrix where Self::Scalar: F...
code_fim
hard
{ "lang": "rust", "repo": "Shirataki2/competitive_submissions", "path": "/abc189/src/bin/e.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FreddyWordingham/cartograph path: /src/input/settings.rs //! Mapping simulation settings structure. use crate::parts::{Caster, SuperSample}; use arctk::{access, clone}; use arctk_attr::input; /// Loadable input cartography settings structure. #[input] pub struct Settings { /// Number of sa...
code_fim
medium
{ "lang": "rust", "repo": "FreddyWordingham/cartograph", "path": "/src/input/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { block_size, bump_dist, super_sampling, caster, } } }<|fim_prefix|>// repo: FreddyWordingham/cartograph path: /src/input/settings.rs //! Mapping simulation settings structure. use crate::parts::{Caster, SuperSample}; use arctk::{a...
code_fim
hard
{ "lang": "rust", "repo": "FreddyWordingham/cartograph", "path": "/src/input/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run<'a>(reader: Box<dyn BufRead + 'a>) { let mut max_time = std::usize::MAX; let mut max_bus_num = None; let mut lines = reader.lines(); let start = lines.next().unwrap().unwrap(); let start = start.trim().parse::<usize>().unwrap(); let line = lines.next().unwrap().unwrap();...
code_fim
hard
{ "lang": "rust", "repo": "sak96/Advent2020", "path": "/src/day13/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sak96/Advent2020 path: /src/day13/mod.rs use std::io::BufRead; pub fn gcd(a: usize, b: usize) -> usize { if b == 0 { a } else { gcd(b, a % b) } } pub fn inverse_modulo(a: usize, c: usize, b: usize) -> usize { for i in 0..=b { if (i * a) % b == c { ...
code_fim
hard
{ "lang": "rust", "repo": "sak96/Advent2020", "path": "/src/day13/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hpuyang7942/rustos path: /lib/fat32/src/vfat/file.rs use alloc::string::String; use shim::io::{self, SeekFrom}; use crate::traits; use crate::vfat::{Cluster, Metadata, VFatHandle, FatEntry}; #[derive(Debug)] pub struct File<HANDLE: VFatHandle> { // FIXME: Fill me in. pub short_name: S...
code_fim
hard
{ "lang": "rust", "repo": "hpuyang7942/rustos", "path": "/lib/fat32/src/vfat/file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.size as u64 } } impl<HANDLE: VFatHandle> io::Read for File<HANDLE> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { let read_size = ::core::cmp::min(buf.len(), self.size as usize - self.offset as usize); let mut rest_size = read_size; let bytes_per_...
code_fim
hard
{ "lang": "rust", "repo": "hpuyang7942/rustos", "path": "/lib/fat32/src/vfat/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } fn flush(&mut self) -> io::Result<()> { unimplemented!() } } impl<HANDLE: VFatHandle> io::Seek for File<HANDLE> { /// Seek to offset `pos` in the file. /// /// A seek to the end of the file is allowed. A seek _beyond_ the end of the /// fil...
code_fim
hard
{ "lang": "rust", "repo": "hpuyang7942/rustos", "path": "/lib/fat32/src/vfat/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/overloaded/overloaded-autoderef-xcrate.rs // run-pass // aux-build:overloaded_autoderef_xc.rs <|fim_suffix|> assert!(overloaded_autoderef_xc::check(5, 5)); }<|fim_middle|> extern crate overloaded_autoderef_xc; fn main() {
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/overloaded/overloaded-autoderef-xcrate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { assert!(overloaded_autoderef_xc::check(5, 5)); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/overloaded/overloaded-autoderef-xcrate.rs // run-pass // aux-build:overloaded_autoderef_xc.rs <|fim_middle|> extern crate overloaded_autoderef_xc;
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/overloaded/overloaded-autoderef-xcrate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyomaiva/a-tour-of-rust path: /ownership/src/main.rs fn uppercase(mut input: String) { input = input.to_uppercase(); } <|fim_suffix|> let mut output = String::from("hello world."); uppercase(output); print!("{}", output); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "tyomaiva/a-tour-of-rust", "path": "/ownership/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyomaiva/a-tour-of-rust path: /ownership/src/main.rs fn uppercase(mut input: String) { <|fim_suffix|> let mut output = String::from("hello world."); uppercase(output); print!("{}", output); }<|fim_middle|> input = input.to_uppercase(); } fn main() {
code_fim
easy
{ "lang": "rust", "repo": "tyomaiva/a-tour-of-rust", "path": "/ownership/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut output = String::from("hello world."); uppercase(output); print!("{}", output); }<|fim_prefix|>// repo: tyomaiva/a-tour-of-rust path: /ownership/src/main.rs fn uppercase(mut input: String) { <|fim_middle|> input = input.to_uppercase(); } fn main() {
code_fim
easy
{ "lang": "rust", "repo": "tyomaiva/a-tour-of-rust", "path": "/ownership/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("\n | | "); println!("-------|-------|-------"); } } fn show_free_positions(&self) { let free = self.board.free_positions(); print!("The available positions are: "); for pos in 0..free.len() { if let Some(free_pos) = free.get(pos) { ...
code_fim
hard
{ "lang": "rust", "repo": "dibenso/tic_tac_toe", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for index in 0..self.positions.len() { if self.free_position(index) { free.push(index) } } free } fn check_winner(&self) -> Player { let three_in_a_rows = [[0, 1, 2], [0, 3, 6], [0, 4, 8], [1, 4, 7], [2, 5, 8], [2, 4, 6], [3, 4, 5], [6, ...
code_fim
hard
{ "lang": "rust", "repo": "dibenso/tic_tac_toe", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dibenso/tic_tac_toe path: /src/main.rs use std::io; #[derive(Clone, Debug)] enum Player { XPlayer, CirclePlayer, Empty } #[derive(Debug)] struct Game { board: Board, current_player: Player } impl Game { fn new() -> Game { Game { board: Board::new(), current_player:...
code_fim
hard
{ "lang": "rust", "repo": "dibenso/tic_tac_toe", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: praveenperera/rust_playground path: /combining_strs/src/lib.rs use itertools::Itertools; #[inline] pub fn std_join() -> String { vec!["a", "b", "c", "d", "e", "f"].into_iter().join(" ") } #[inline] pub fn join_iter_with_intersperse() -> String { let strs = vec!["a", "b", "c", "d", "e",...
code_fim
hard
{ "lang": "rust", "repo": "praveenperera/rust_playground", "path": "/combining_strs/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> s } #[inline] pub fn prefix_collect(string: String) -> String { let mut s: Vec<char> = "abcdef".chars().collect(); s.push('-'); for char in "prefix".chars() { s.push(char) } for char in string.chars() { s.push(char) } s.iter().collect() } #[inline] pub...
code_fim
hard
{ "lang": "rust", "repo": "praveenperera/rust_playground", "path": "/combining_strs/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let options = options.unwrap(); _itself.draw(DrawCommand::Arc { depth: options.get_num("depth").unwrap_or(1.0), color: options.get_as::<ColorData>("color") .map(|c| c.into()) .unwrap_or([1.0, 1.0, 1.0, 1.0]), radius: optio...
code_fim
hard
{ "lang": "rust", "repo": "BrianMWest/dathos-game-engine", "path": "/src/modules/draw/ruby.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BrianMWest/dathos-game-engine path: /src/modules/draw/ruby.rs use super::{DrawCommand, ObjectGeometry, SpritesheetLoadRequest, SpritesheetSlice}; use crate::ext::{AnyNumber, HashExt, RotationExt}; use crate::modules::core::{ColorData, VectorData}; use glyph_brush::{HorizontalAlign, VerticalAlign...
code_fim
hard
{ "lang": "rust", "repo": "BrianMWest/dathos-game-engine", "path": "/src/modules/draw/ruby.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // This is a property based test, see QuickCheck for more information. use rand::{thread_rng, Rng}; let mut rng = thread_rng(); for _ in 0..10000 { // Ensure that all positions returned by the Subset iterator are // contained in the Subset. let subset = game::Subs...
code_fim
hard
{ "lang": "rust", "repo": "roSievers/sogo", "path": "/src/tests/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }