text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: sean-a-m/json-parser path: /src/parser.rs use value::{Json, JsonObject, JsonArray}; use token::{Enums, Token}; //type TokenIter<'a> = Iterator<Item = &'a Token<'a>>; fn parse_terminal(token: &Token) -> Box<Json> { Box::new(token.val.to_string()) } fn parse_array<'a, I>(tokens: &mut I) -> ...
code_fim
medium
{ "lang": "rust", "repo": "sean-a-m/json-parser", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: veasnama/rsmixer path: /src/entry/mod.rs mod entries; mod misc; pub use entries::Entries; pub use misc::{EntryIdentifier, EntrySpaceLvl, EntryType}; use crate::ui::{widgets::VolumeWidget, Rect}; #[derive(PartialEq, Clone, Debug)] pub struct PlayEntry { pub peak: f32, pub mute: bool, ...
code_fim
hard
{ "lang": "rust", "repo": "veasnama/rsmixer", "path": "/src/entry/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> area } pub fn monitor_source(&self, entries: &Entries) -> Option<u32> { match self.entry_type { EntryType::Card => None, EntryType::SinkInput => { if let Some(sink) = self.play_entry.as_ref().unwrap().sink { match entries...
code_fim
hard
{ "lang": "rust", "repo": "veasnama/rsmixer", "path": "/src/entry/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> area.x += amount; if amount < area.width { area.width -= amount; } else { area.width = 0; } area } pub fn monitor_source(&self, entries: &Entries) -> Option<u32> { match self.entry_type { EntryType::Card => None,...
code_fim
hard
{ "lang": "rust", "repo": "veasnama/rsmixer", "path": "/src/entry/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rust-SDL2/rust-sdl2 path: /src/sdl2/macros.rs macro_rules! impl_raw_accessors( ($(($t:ty, $raw:ty)),+) => ( $( impl $t { #[inline] // can prevent introducing UB until // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed ...
code_fim
medium
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pl $t { #[inline] pub const unsafe fn from_ll($($r:$rt),+) -> $t { $te { $($r: $r),+ } } } )+ ) );<|fim_prefix|>// repo: Rust-SDL2/rust-sdl2 path: /src/sdl2/macros.rs macro_rules! impl_raw_accessors( ($(($t:ty, $raw:ty)),+) => ( ...
code_fim
medium
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>f) -> $raw { self.raw } } )+ ) ); macro_rules! impl_raw_constructor( ($(($t:ty, $te:ident ($($r:ident:$rt:ty),+))),+) => ( $( impl $t { #[inline] pub const unsafe fn from_ll($($r:$rt),+) -> $t { $te { $($r: $r),+ } ...
code_fim
medium
{ "lang": "rust", "repo": "Rust-SDL2/rust-sdl2", "path": "/src/sdl2/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bartsmykla/codewars path: /src/katas/k8_even_or_odd.rs #![allow(unused)] /* Kata (8kyu): Even or Odd Url: https://www.codewars.com/kata/even-or-odd/train/rust Create a function (or write a script in Shell) that takes an integer as an argument and returns "Even" for even numbers...
code_fim
medium
{ "lang": "rust", "repo": "bartsmykla/codewars", "path": "/src/katas/k8_even_or_odd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn returns_expected() { assert_eq!(even_or_odd(0), "Even"); assert_eq!(even_or_odd(2), "Even"); assert_eq!(even_or_odd(1), "Odd"); assert_eq!(even_or_odd(7), "Odd"); assert_eq!(even_or_odd(-1), "Odd"); }<|fim_prefix|>// repo: bartsmykla/codewars path: /src/katas/k8_even_or_odd...
code_fim
medium
{ "lang": "rust", "repo": "bartsmykla/codewars", "path": "/src/katas/k8_even_or_odd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 1 word for checksum self.chksum += u16::from(bytes[8]) << 8; self.chksum += u16::from(bytes[9]); // 3 bytes for PC self.pc += usize::from(bytes[10]) << 16; self.pc += usize::from(bytes[11]) << 8; self.pc += usize::from(bytes[12]); } fn m...
code_fim
hard
{ "lang": "rust", "repo": "DeMille/encrusted", "path": "/src/rust/quetzal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bytes = [0; 13]; // ifhd body is always 13 bytes // 1 word for release bytes[0] = ((release & 0xFF00) >> 8) as u8; bytes[1] = (release & 0x00FF) as u8; // 6 bytes for serial number bytes[2] = serial[0]; bytes[3] = serial[1]; bytes[4...
code_fim
hard
{ "lang": "rust", "repo": "DeMille/encrusted", "path": "/src/rust/quetzal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DeMille/encrusted path: /src/rust/quetzal.rs use frame::Frame; use std::fmt; #[derive(Debug)] pub struct QuetzalSave { pub pc: usize, pub memory: Vec<u8>, pub frames: Vec<Frame>, pub chksum: u16, } impl QuetzalSave { fn empty() -> QuetzalSave { QuetzalSave { ...
code_fim
hard
{ "lang": "rust", "repo": "DeMille/encrusted", "path": "/src/rust/quetzal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MeiK2333/merge-dns path: /src/server/server.rs use crate::config::{Configs, Config}; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; use trust_dns::client::{Client, SyncClient}; use trust_dns::udp::UdpClientConnection; use trust_dns::proto::op::message::Message; use trust_dns::proto::op::qu...
code_fim
hard
{ "lang": "rust", "repo": "MeiK2333/merge-dns", "path": "/src/server/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let dns_server_address = match dns_server_address.parse() { Ok(a) => a, Err(_) => return Err("addr parse error".to_string()) }; let conn = match UdpClientConnection::new(dns_server_address) { Ok(c) => c, Err(e) => return Err(e.to_string()) }; let client ...
code_fim
hard
{ "lang": "rust", "repo": "MeiK2333/merge-dns", "path": "/src/server/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eirproject/eir path: /libeir_ir/src/function/location.rs use std::hash::{Hash, Hasher}; use libeir_util_datastructures::dedup_aux_primary_map::DedupPrimaryMap; use libeir_util_datastructures::{ aux_traits::{AuxEq, AuxHash}, dedup_aux_primary_map::DedupAuxPrimaryMap, }; use cranelift_en...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/libeir_ir/src/function/location.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> write!(&mut out, "[").unwrap(); for term in loc_inner.terminals.as_slice(&self.terminal_pool) { let term_inner = &self.terminals[*term]; if let Some(file) = &term_inner.file { write!(&mut out, "{:?}:", file).unwrap(); } else { ...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/libeir_ir/src/function/location.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl LocationContainer { pub fn new() -> Self { let locations = DedupAuxPrimaryMap::new(); let terminals = DedupPrimaryMap::new(); let terminal_pool = ListPool::new(); LocationContainer { locations, terminals, terminal_pool, ...
code_fim
hard
{ "lang": "rust", "repo": "eirproject/eir", "path": "/libeir_ir/src/function/location.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let socket = UdpBuilder::new_v4().unwrap(); let socket = socket .bind(SocketAddr::new( IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), DHCP_PORT_CLIENT, )) .unwrap(); let socket = UdpSocket::from_std(socket, &Handle::default()).unwrap(); socket.set_b...
code_fim
hard
{ "lang": "rust", "repo": "hedgar2017/dhcp", "path": "/client/examples/linux_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hedgar2017/dhcp path: /client/examples/linux_client.rs //! Run this with administrator privileges where it is required //! Works only under linux //! in order to bind the DHCP client socket to its port 68. #[macro_use] extern crate log; extern crate tokio; #[macro_use] extern crate futures; ext...
code_fim
hard
{ "lang": "rust", "repo": "hedgar2017/dhcp", "path": "/client/examples/linux_client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn select_spill(&mut self) { unimplemented!() } fn assign_color(&mut self) { let mut available = HashSet::with_capacity(A::K as usize); for &n in self.select_stack.iter().rev() { // pop all, need to traverse reversely available.clear(); for i in 0..A::K { available.insert(i)...
code_fim
hard
{ "lang": "rust", "repo": "decaf-lang/decaf-rs", "path": "/codegen/src/graph_alloc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: decaf-lang/decaf-rs path: /codegen/src/graph_alloc.rs // http://www.cse.iitm.ac.in/~krishna/cs6013/george.pdf use common::{HashSet, IndexSet}; use std::marker::PhantomData; use crate::Reg; pub trait AllocCtx: Sized { // number of registers to allocate const K: u32; // return (initial vi...
code_fim
hard
{ "lang": "rust", "repo": "decaf-lang/decaf-rs", "path": "/codegen/src/graph_alloc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } fn simplify(&mut self) { unimplemented!() } fn coalesce(&mut self) { unimplemented!() } fn get_alias(&self, mut _n: u32) -> u32 { unimplemented!() } fn freeze(&mut self) { unimplemented!() } fn select_spill(&mut self) { unimplemented!()...
code_fim
hard
{ "lang": "rust", "repo": "decaf-lang/decaf-rs", "path": "/codegen/src/graph_alloc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apogeeoak/os path: /src/interrupts/pic.rs use pic8259::ChainedPics; use spin::Mutex; #[derive(Clone, Copy, Debug)] #[repr(u8)] pub enum InterruptIndex { Timer = Offset::Pic1 as u8, Keyboard, } <|fim_suffix|> pub fn as_usize(self) -> usize { // Prevent lossy conversion. ...
code_fim
hard
{ "lang": "rust", "repo": "apogeeoak/os", "path": "/src/interrupts/pic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn as_usize(self) -> usize { // Prevent lossy conversion. usize::from(self.as_u8()) } }<|fim_prefix|>// repo: apogeeoak/os path: /src/interrupts/pic.rs use pic8259::ChainedPics; use spin::Mutex; #[derive(Clone, Copy, Debug)] #[repr(u8)] pub enum InterruptIndex { Timer = O...
code_fim
hard
{ "lang": "rust", "repo": "apogeeoak/os", "path": "/src/interrupts/pic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &INSTANCE } pub fn init() { unsafe { pic().lock().initialize() }; x86_64::instructions::interrupts::enable(); } pub fn end_of_interrupt(interrupt_index: InterruptIndex) { unsafe { pic().lock().notify_end_of_interrupt(interrupt_index as u8) }; } impl InterruptIndex { pub fn as_u8(sel...
code_fim
hard
{ "lang": "rust", "repo": "apogeeoak/os", "path": "/src/interrupts/pic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // keep track of whether a seed exists, and pause a bit if so is_seeding: bool, } #[allow(dead_code)] impl LocalServerContainerPool { pub fn new(config: LocalServerContainerPoolConfig) -> LocalServerContainerPool { (LocalServerContainerPool { next_api_port: config.base_api_port, next_p2p_port:...
code_fim
hard
{ "lang": "rust", "repo": "mimblewimble/grin-wallet", "path": "/integration/tests/framework.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mimblewimble/grin-wallet path: /integration/tests/framework.rs ervers as servers; use grin_util as util; use p2p::PeerAddr; use std::default::Default; use std::ops::Deref; use std::sync::Arc; use std::{fs, thread, time}; /// Just removes all results from previous runs pub fn clean_all_output(te...
code_fim
hard
{ "lang": "rust", "repo": "mimblewimble/grin-wallet", "path": "/integration/tests/framework.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // How long the servers in the pool are going to run pub run_length_in_seconds: u64, } /// Default server config /// impl Default for LocalServerContainerPoolConfig { fn default() -> LocalServerContainerPoolConfig { LocalServerContainerPoolConfig { base_name: String::from("test_pool"), base_ht...
code_fim
hard
{ "lang": "rust", "repo": "mimblewimble/grin-wallet", "path": "/integration/tests/framework.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w3f-grants-archive/yatima path: /web/src/repl.rs b fn replace_mode(term: &Terminal) { term.write(&terminal_sequences::reset_mode(vec![4])); } #[derive(Debug, Clone)] pub struct ShellState { cursor: GraphemeCursor, line: String, history_index: usize, } impl Default for ShellState { fn...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/yatima", "path": "/web/src/repl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn println(&self, s: String) -> Result<(), String> { // The term needs \r to move the cursor back to the start of the line let m = s.replace( terminal_sequences::LF, &(terminal_sequences::LF.to_owned() + terminal_sequences::CR), ); self.terminal.writeln(m.as_str()); Ok((...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/yatima", "path": "/web/src/repl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w3f-grants-archive/yatima path: /web/src/repl.rs vec![4])); } pub fn replace_mode(term: &Terminal) { term.write(&terminal_sequences::reset_mode(vec![4])); } #[derive(Debug, Clone)] pub struct ShellState { cursor: GraphemeCursor, line: String, history_index: usize, } impl Default for S...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/yatima", "path": "/web/src/repl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/tokio path: /tokio-util/src/sync/mod.rs //! Synchronization primitives mod cancellation_token; pub use cancellation_token::{ guard::DropGuard, CancellationToken, WaitForCancellationFuture, WaitForCancellationFutureOwned, }; <|fim_suffix|>mod poll_semaphore; pub use poll_semaphore:...
code_fim
easy
{ "lang": "rust", "repo": "tokio-rs/tokio", "path": "/tokio-util/src/sync/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod reusable_box; pub use reusable_box::ReusableBoxFuture;<|fim_prefix|>// repo: tokio-rs/tokio path: /tokio-util/src/sync/mod.rs //! Synchronization primitives mod cancellation_token; pub use cancellation_token::{ guard::DropGuard, CancellationToken, WaitForCancellationFuture, WaitForCancellationFu...
code_fim
medium
{ "lang": "rust", "repo": "tokio-rs/tokio", "path": "/tokio-util/src/sync/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tpayne84/proxide path: /src/decoders.rs use http::header::{HeaderName, HeaderValue}; use snafu::Snafu; use tui::widgets::Text; use crate::session::{MessageData, RequestData}; pub mod grpc; pub mod raw; #[derive(Debug, Snafu)] pub enum Error { #[snafu(display("Parameter {}: {}", option, ms...
code_fim
hard
{ "lang": "rust", "repo": "tpayne84/proxide", "path": "/src/decoders.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn index(&self, msg: &MessageData) -> Vec<String> { self.process(msg, |_| None, |k, v| format!("{}: {:?}", k, v)) } } impl HeaderDecoder { fn process<T>( &self, msg: &MessageData, title: fn(&'static str) -> Option<T>, ctor: fn(&HeaderName, &HeaderVa...
code_fim
hard
{ "lang": "rust", "repo": "tpayne84/proxide", "path": "/src/decoders.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sogapalag/contest path: /atcoder/code-festival-2015-relay/h.rs #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let...
code_fim
hard
{ "lang": "rust", "repo": "sogapalag/contest", "path": "/atcoder/code-festival-2015-relay/h.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/tests/io_poll_aio.rs # ! [ warn ( rust_2018_idioms ) ] # ! [ cfg ( all ( target_os = " freebsd " feature = " net " ) ) ] use mio_aio : : { AioCb AioFsyncMode LioCb } ; use std : : { future : : Future mem os : : unix : : io : : { AsRawFd R...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio/tests/io_poll_aio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Pin < & mut Self > cx : & mut Context < ' _ > ) - > Poll < Self : : Output > { let poll_result = self . 0 . poll_ready ( cx ) ; match poll_result { Poll : : Pending = > Poll : : Pending Poll : : Ready ( Err ( e ) ) = > Poll : : Ready ( Err ( e ) ) Poll : : Ready ( Ok ( ev ) ) = > { / / Since this future ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio/tests/io_poll_aio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChesleyTan/Advent-of-Code path: /2018/p14/src/main.rs use std::collections::vec_deque::VecDeque; use std::env; use std::error::Error; const INPUT: usize = 330121; fn a() -> Result<(), Box<dyn Error>> { let mut recipes = VecDeque::new(); recipes.push_back(3); recipes.push_back(7); ...
code_fim
hard
{ "lang": "rust", "repo": "ChesleyTan/Advent-of-Code", "path": "/2018/p14/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = a + b; if result >= 10 { vec![result / 10, result % 10] } else { vec![result] } } fn main() -> Result<(), Box<dyn Error>> { let part = env::args() .nth(1) .expect("Expected argument specifying problem part `a` or `b`"); if part == "a" {...
code_fim
hard
{ "lang": "rust", "repo": "ChesleyTan/Advent-of-Code", "path": "/2018/p14/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glalonde/spout path: /src/particles.rs wgpu::BindGroupLayoutEntry { binding: 1, visibility: wgpu::ShaderStages::COMPUTE, ty: wgpu::BindingType::Buffer { ty: wgpu::BufferBindingType::Storage { rea...
code_fim
hard
{ "lang": "rust", "repo": "glalonde/spout", "path": "/src/particles.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ParticleSystem { pub fn update_state(&mut self, dt: f32, viewport_offset: i32, motion: Option<EmitterMotion>) { if let Some(motion) = motion { self.emitter.emit_for_period(dt, motion); } self.uniform_values.dt = dt; self.uniform_values.viewport_offset ...
code_fim
hard
{ "lang": "rust", "repo": "glalonde/spout", "path": "/src/particles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn after_queue_submission(&mut self) { self.emitter.after_queue_submission(); self.staging_belt.recall(); } } #[repr(C)] #[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)] struct ParticleRendererUniforms { pub width: u32, pub height: u32, } struct Partic...
code_fim
hard
{ "lang": "rust", "repo": "glalonde/spout", "path": "/src/particles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[cfg(test)] quickcheck! { fn prop_select_rank(bit_vec: Vec<u8>, is_one: bool, x: usize) -> bool { let x = x % (bit_vec.len() * 8 + 1); // deliberately +1 let p = rank(&bit_vec, is_one, x); match select(&bit_v...
code_fim
hard
{ "lang": "rust", "repo": "gyk/TrivialSolutions", "path": "/SuccinctTrie/src/bitquery.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gyk/TrivialSolutions path: /SuccinctTrie/src/bitquery.rs //! Implements `rank` and `select`. // FIXME: `rank` and `select` can be greatly optimized using auxiliary arrays. This is important // because by definition of succinct data strucuture, it "uses an amount of space that is 'close' to // t...
code_fim
hard
{ "lang": "rust", "repo": "gyk/TrivialSolutions", "path": "/SuccinctTrie/src/bitquery.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> last_cnt == n_remaining }).expect("Cannot find position in the last byte.") - 1 // cardinal to 0-based ordinal }; Select::Position(i * 8 + i_remaining) } #[cfg(test)] mod tests { use super::*; #[cfg(test)] quickcheck! { fn prop_select_rank(bit_ve...
code_fim
hard
{ "lang": "rust", "repo": "gyk/TrivialSolutions", "path": "/SuccinctTrie/src/bitquery.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] pub(crate) fn read_haru_moc() -> Result<moc::Moc> { use std::env; use std::path::PathBuf; let samples_dir = env::var("LIVE2D_CUBISM").expect( "The environment variable `LIVE2D_CUBISM` is not set properly. \ `LIVE2D_CUBISM` should be set to the Live2D Cubism direct...
code_fim
hard
{ "lang": "rust", "repo": "orzogc/cubism-core", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orzogc/cubism-core path: /src/lib.rs //! Rust API for [Cubism Core native library](https://www.live2d.com/en/download/cubism-sdk/download-native/). #![warn(missing_docs)] pub mod drawable; pub mod log; pub mod model; pub mod parameter; pub mod part; mod error; mod flags; mod moc; mod version;...
code_fim
hard
{ "lang": "rust", "repo": "orzogc/cubism-core", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! impl_iter { ($iter:ty, $item:ty, $collect:ty) => { impl<'a> std::iter::Iterator for $iter { type Item = $item; #[inline] fn next(&mut self) -> Option<Self::Item> { if self.start < self.end { // SAFETY: the in...
code_fim
hard
{ "lang": "rust", "repo": "orzogc/cubism-core", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if riders_sorted.last().unwrap().1.orders.keys().len() >= 4 && val < self.best_difference { for r in riders_sorted.iter() { if !one_tree_bound { let nodes = &r.1.orders; let mut min_...
code_fim
hard
{ "lang": "rust", "repo": "MirkoCovizzi/FoodDelive-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut graph = Graph::<_, _>::new(); let t_range = (MIN_T as u32..MAX_T as u32).collect::<Vec<_>>(); for _ in 0..NUM_LOCATIONS + 1 { let x = *t_range.choose(&mut rng).unwrap() as f64; let y = *t_range.choose(&mut rng).unwrap() as f64; graph.add_node((x, y)); } ...
code_fim
hard
{ "lang": "rust", "repo": "MirkoCovizzi/FoodDelive-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MirkoCovizzi/FoodDelive-rs path: /src/main.rs extern crate simple_logger; use std::collections::HashMap; use log::*; use petgraph::algo::min_spanning_tree; use petgraph::data::FromElements; use petgraph::stable_graph::NodeIndex; use petgraph::visit::EdgeRef; use petgraph::Graph; use rand::seq:...
code_fim
hard
{ "lang": "rust", "repo": "MirkoCovizzi/FoodDelive-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duchainer/sea-query path: /tests/derive/mod.rs use sea_query::*; #[test] fn derive_1() { #[derive(Debug, Iden)] enum User { Table, Id, FirstName, LastName, Email, } println!("Default field names"); assert_eq!(Iden::to_string(&User::Ta...
code_fim
hard
{ "lang": "rust", "repo": "duchainer/sea-query", "path": "/tests/derive/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug, Iden)] #[iden = "another_name"] pub struct CustomName; println!("Unit structs"); assert_eq!(Iden::to_string(&SomeType), "some_type"); assert_eq!(Iden::to_string(&CustomName), "another_name"); }<|fim_prefix|>// repo: duchainer/sea-query path: /tests/derive/mod.rs u...
code_fim
hard
{ "lang": "rust", "repo": "duchainer/sea-query", "path": "/tests/derive/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> place } } impl<T: Widget> Button<T> { pub fn new(label: T) -> Self { Button { id: Id::unique(), click_area: ClickArea::new(), label } } pub fn clicked(&mut self) -> bool { self.click_area.clicked() } }<|fim_prefix|>/...
code_fim
hard
{ "lang": "rust", "repo": "kryptan/lithium", "path": "/lithium_core/src/widgets/button.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> gui.element(self.id, element_kind!("Button"), |gui| { let click_area_place = self.click_area.appear(gui); let label_place = self.label.appear(gui); layout::equal(gui, place, click_area_place); layout::center(gui, place, label_place); ...
code_fim
medium
{ "lang": "rust", "repo": "kryptan/lithium", "path": "/lithium_core/src/widgets/button.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kryptan/lithium path: /lithium_core/src/widgets/button.rs use {Id, Gui, Rect, Var}; use layout; use super::Widget; use super::ClickArea; pub struct Button<T: Widget> { id: Id, click_area: ClickArea, pub label: T, } impl<T: Widget> Widget for Button<T> { fn appear(&mut self, gu...
code_fim
medium
{ "lang": "rust", "repo": "kryptan/lithium", "path": "/lithium_core/src/widgets/button.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: germangb/imgui-ext path: /src/input.rs //! # Optional fields //! //! * `label` override widget label. //! * `step` //! * `step_fast` //! * `flags` path to a function that returns the input [flags]. //! * `size` size of the text box (multiline text input). //! * `catch` //! * `map` Applies a mapp...
code_fim
hard
{ "lang": "rust", "repo": "germangb/imgui-ext", "path": "/src/input.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>imgui_input_matrix! { (f32, f32, f32, f32, f32, f32, f32, f32), 8, 8, sys::ImGuiDataType_Float } imgui_input_matrix! { (f32, f32, f32, f32, f32, f32, f32, f32), 8, 7, sys::ImGuiDataType_Float } imgui_input_matrix! { (f32, f32, f32, f32, f32, f32, f32, f32), 8, 6, sys::ImGuiDataType_Float } imgui_input_mat...
code_fim
hard
{ "lang": "rust", "repo": "germangb/imgui-ext", "path": "/src/input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let file_pos = symbols.line_from_address(address) .map(|(line, _off)| { format!("{}:{}", line.file.to_string_lossy(), line.line) }) .unwrap_or(String::new()); ...
code_fim
hard
{ "lang": "rust", "repo": "team-worm/spice", "path": "/server/debug/examples/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> LoadDll { ref file, base } => { println!("load dll: {:#018x}", base); symbols.load_module(file.as_ref().unwrap(), base) .expect("failed to load module"); } UnloadDll { base } => { println!("unload dll...
code_fim
hard
{ "lang": "rust", "repo": "team-worm/spice", "path": "/server/debug/examples/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: team-worm/spice path: /server/debug/examples/trace.rs extern crate debug; extern crate winapi; use std::env; use std::collections::HashMap; fn main() { let child = debug::Command::new(env::args().nth(1).unwrap()) .env_clear() .debug() .expect("failed to launch proc...
code_fim
hard
{ "lang": "rust", "repo": "team-worm/spice", "path": "/server/debug/examples/trace.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcy/sseq path: /ext/src/yoneda.rs let orig_diff_dimension = differential_images[t].dimension(); if orig_diff_dimension == 0 { continue; } prev_differentials[t] = Some(differential_images[t].clone())...
code_fim
hard
{ "lang": "rust", "repo": "mcy/sseq", "path": "/ext/src/yoneda.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut generators: Vec<(i32, usize)> = Vec::new(); let mut target_degrees = Vec::new(); let mut padded_target_degrees: Vec<usize> = Vec::new(); let source_orig_dimension = source.module.dimension(t); let source_dimension = source.dimension(t); for op_deg in 1..=source.max_degree...
code_fim
hard
{ "lang": "rust", "repo": "mcy/sseq", "path": "/ext/src/yoneda.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcy/sseq path: /ext/src/yoneda.rs teenrodAlgebra, TargetComplex = TC, Module = FreeModule<SteenrodAlgebra>, ChainMap = FreeModuleHomomorphism<TCM>, >, { let p = cc.prime(); let target = FDModule::new(cc.algebra(), "".to_string(), BiVec::from_vec(0, vec![1]));...
code_fim
hard
{ "lang": "rust", "repo": "mcy/sseq", "path": "/ext/src/yoneda.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mayone-du/rust_practice_guessing_game path: /src/main.rs use rand::Rng; use std::cmp::Ordering; use std::io; // main()は実行時に呼ばれる特別な関数 fn main() { println!("数あてゲームスタート!"); // ランダムな整数値を1~100の値で生成 let secret_number = rand::thread_rng().gen_range(1..101); // breakするまでloop loop ...
code_fim
hard
{ "lang": "rust", "repo": "mayone-du/rust_practice_guessing_game", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("あなたが予想した数: {}", guess); // 答えと合うか判定 match guess.cmp(&secret_number) { Ordering::Less => println!("答えより小さいです!"), Ordering::Greater => println!("答えより大きいです!"), Ordering::Equal => { println!("正解! 答えは{}でした!", secret_number);...
code_fim
medium
{ "lang": "rust", "repo": "mayone-du/rust_practice_guessing_game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CosmWasm/terra-contracts path: /packages/mocks/src/querier.rs use cosmwasm_std::testing::{ mock_dependencies as std_dependencies, MockApi, MockQuerier, MockStorage, }; use cosmwasm_std::{ from_slice, Coin, Decimal, Extern, FullDelegation, HumanAddr, Querier, QuerierResult, QueryReque...
code_fim
hard
{ "lang": "rust", "repo": "CosmWasm/terra-contracts", "path": "/packages/mocks/src/querier.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // configure the stacking mock querier pub fn with_staking( &mut self, denom: &str, validators: &[Validator], delegations: &[FullDelegation], ) { self.base.with_staking(denom, validators, delegations) } pub fn with_market(&mut self, rates: &[(&s...
code_fim
hard
{ "lang": "rust", "repo": "CosmWasm/terra-contracts", "path": "/packages/mocks/src/querier.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, PartialEq, Clone, Copy)] pub enum BracketSide { Left(Bracket), Right(Bracket), } #[derive(Debug, PartialEq, Clone, Copy)] pub enum Bracket { Round, Curly, } pub struct Dictionary { terminal: Option<Token>, next: HashMap<char, Box<Dictionary>>, } impl Dictionary {...
code_fim
hard
{ "lang": "rust", "repo": "seiyab/rust-cc", "path": "/src/token/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seiyab/rust-cc path: /src/token/token.rs use std::collections::HashMap; use std::str::Chars; #[derive(Debug, PartialEq, Clone)] pub enum Token { Operator(Operator), ReservedWord(ReservedWord), Number(i64), Bracket(BracketSide), Identifier(String), LineBreak, Comma, }...
code_fim
hard
{ "lang": "rust", "repo": "seiyab/rust-cc", "path": "/src/token/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] struct Baz<'a> { s: &'a str } pub fn t() { println!("any"); test_typeid("Foo", &Foo {}); test_typeid("Foo", &Bar { s: "bar" }); test_typeid("Foo", &Baz { s: "baz" }); }<|fim_prefix|>// repo: dai1975/rusttest path: /basic/src/test_any.rs // write #![feature(get_type_id)] a...
code_fim
easy
{ "lang": "rust", "repo": "dai1975/rusttest", "path": "/basic/src/test_any.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] struct Foo; #[allow(dead_code)] struct Bar { s: &'static str } #[allow(dead_code)] struct Baz<'a> { s: &'a str } pub fn t() { println!("any"); test_typeid("Foo", &Foo {}); test_typeid("Foo", &Bar { s: "bar" }); test_typeid("Foo", &Baz { s: "baz" }); }<|fim_prefix|>// rep...
code_fim
medium
{ "lang": "rust", "repo": "dai1975/rusttest", "path": "/basic/src/test_any.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dai1975/rusttest path: /basic/src/test_any.rs // write #![feature(get_type_id)] at main.rs use std::any::{Any}; <|fim_suffix|>#[allow(dead_code)] struct Baz<'a> { s: &'a str } pub fn t() { println!("any"); test_typeid("Foo", &Foo {}); test_typeid("Foo", &Bar { s: "bar" }); test_typ...
code_fim
medium
{ "lang": "rust", "repo": "dai1975/rusttest", "path": "/basic/src/test_any.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> persona.saludo.push_str(&persona.nombre); persona.saludo.len() }<|fim_prefix|>// repo: rodframeh/dylib-tests path: /lib-hello-world/src/lib.rs extern crate libloading; use libloading::{Library}; pub struct Persona { nombre: String, edad: u8, saludo: String, } #[no_mangle] pub fn print_hello_wo...
code_fim
hard
{ "lang": "rust", "repo": "rodframeh/dylib-tests", "path": "/lib-hello-world/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodframeh/dylib-tests path: /lib-hello-world/src/lib.rs extern crate libloading; use libloading::{Library}; pub struct Persona { nombre: String, edad: u8, saludo: String, } <|fim_suffix|> persona.saludo.push_str(&persona.nombre); persona.saludo.len() }<|fim_middle|>#[no_mangle] pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "rodframeh/dylib-tests", "path": "/lib-hello-world/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lib = Library::new("c:/Users/Jimena/Desktop/dylib-tests/lib-suma-numeros/target/debug/lib_suma_numeros.dll").unwrap(); unsafe { match lib.get::<fn(i32,i32)->i32>(b"suma_numeros\0"){ Err(_error) => {println!("Error");} Ok(_funcion) => { println!("valor de la suma: {}",_funcion(6,...
code_fim
medium
{ "lang": "rust", "repo": "rodframeh/dylib-tests", "path": "/lib-hello-world/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.validators.get(pubkey).map(|f| { let (rpc, tpu) = LegacyContactInfo::try_from(&f.info.contact_info) .map(|node| { cluster_tests::get_client_facing_addr(self.connection_cache.protocol(), node) }) .unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/local-cluster/src/local_cluster.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/solana path: /local-cluster/src/local_cluster.rs age::FileTowerStorage, validator::{Validator, ValidatorConfig, ValidatorStartProgress}, }, solana_gossip::{ cluster_info::Node, contact_info::{ContactInfo, LegacyContactInfo, Protocol}, gossip_se...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/local-cluster/src/local_cluster.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.validators.insert(validator_pubkey, validator_info); validator_pubkey } pub fn ledger_path(&self, validator_pubkey: &Pubkey) -> PathBuf { self.validators .get(validator_pubkey) .unwrap() .info .ledger_path .c...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/local-cluster/src/local_cluster.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zentner-kyle/match-diagram path: /src/mutate.rs } Mutation::SetTarget { term: Term(node, term), register, } => { if let &mut Node::Match { ref mut terms, .. } = diagram.get_node_mut(node) { if term < terms.len() { ...
code_fim
hard
{ "lang": "rust", "repo": "zentner-kyle/match-diagram", "path": "/src/mutate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut diagram = diagram_literal( r#" root: @0(_ -> %0, _ -> %1) { output @1(%0, %1) } "#, 2, ); let root = diagram.get_root(); apply_mutation( &mut diagram, Mutation::SetTarget { ...
code_fim
hard
{ "lang": "rust", "repo": "zentner-kyle/match-diagram", "path": "/src/mutate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zentner-kyle/match-diagram path: /src/mutate.rs return changed_node(node); } }; return None; } Mutation::RemoveNode { node } => { let was_root = diagram .get_group(EdgeGroup::Roots) .iter() ...
code_fim
hard
{ "lang": "rust", "repo": "zentner-kyle/match-diagram", "path": "/src/mutate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/base64/src/encode.rs # [ cfg ( any ( feature = " alloc " feature = " std " test ) ) ] use alloc : : string : : String ; use core : : fmt ; # [ cfg ( any ( feature = " std " test ) ) ] use std : : error ; # [ cfg ( any ( feature = " alloc " feat...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/base64/src/encode.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>NO_PAD_ENGINE false ) ; assert_encoded_length ( 58 78 & URL_SAFE_NO_PAD_ENGINE false ) ; } # [ test ] fn encoded_size_overflow ( ) { assert_eq ! ( None encoded_len ( usize : : MAX true ) ) ; } # [ test ] fn encode_engine_string_into_nonempty_buffer_doesnt_clobber_prefix ( ) { let mut orig_data = Vec : : n...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/base64/src/encode.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "gaiku_amethyst")] pub use gaiku_amethyst::*; pub use gaiku_common as common;<|fim_prefix|>// repo: norman784/gaiku path: /src/lib.rs #[cfg(feature = "gaiku_baker_heightmap")] pub use gaiku_baker_heightmap::*; #[cfg(feature = "gaiku_baker_marching_cubes")] pub use gaiku_baker_marching_cu...
code_fim
medium
{ "lang": "rust", "repo": "norman784/gaiku", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: norman784/gaiku path: /src/lib.rs #[cfg(feature = "gaiku_baker_heightmap")] pub use gaiku_baker_heightmap::*; #[cfg(feature = "gaiku_baker_marching_cubes")] pub use gaiku_baker_marching_cubes::*; #[cfg(feature = "gaiku_baker_marching_cubes")] pub use gaiku_baker_modified_marching_cubes::*; #[cfg...
code_fim
medium
{ "lang": "rust", "repo": "norman784/gaiku", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let version = std::str::from_utf8(output.stdout.as_slice()).expect("`php`'s stdout to be valid utf8"); // Clean up surrounding whitespace for both printing and parsing. let version = version.trim(); let parsed_version: u8 = version.parse().expect("version string to fit in u8"); ...
code_fim
hard
{ "lang": "rust", "repo": "signalfx/signalfx-php-tracing", "path": "/profiling/build.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: signalfx/signalfx-php-tracing path: /profiling/build.rs use std::collections::HashSet; use std::env; use std::path::Path; use std::path::PathBuf; use std::process::Command; fn main() { let php_config_includes_output = Command::new("php-config") .arg("--includes") .output() ...
code_fim
hard
{ "lang": "rust", "repo": "signalfx/signalfx-php-tracing", "path": "/profiling/build.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let nodes: Vec<Node> = vec.par_iter().map(|i| { // (0..10).iter().collect().par_iter().map(|i| { let mut node = Node::new_root(); for _ in 0..20000 { node.run_sim(&mut self.clone(), 0, player, player); } return node })...
code_fim
hard
{ "lang": "rust", "repo": "superosku/five-in-a-row-gomoku-bot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return result } pub fn do_monte_carlo(&mut self, player: i8) -> (u32, u32) { let vec: Vec<i32> = (0..10).collect(); let nodes: Vec<Node> = vec.par_iter().map(|i| { // (0..10).iter().collect().par_iter().map(|i| { let mut node = Node::new_root(); ...
code_fim
hard
{ "lang": "rust", "repo": "superosku/five-in-a-row-gomoku-bot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: superosku/five-in-a-row-gomoku-bot path: /src/main.rs extern crate rand; use rand::seq::SliceRandom; use std::f32; use std::io::{self, BufRead}; use rayon::prelude::*; use rand::Rng; pub struct Node { nodes: Vec<Node>, x: u32, y: u32, plays: u32, wins: u32, leaf: boo...
code_fim
hard
{ "lang": "rust", "repo": "superosku/five-in-a-row-gomoku-bot", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tzuyichao/learning-rust path: /move_vs_copy/src/main.rs fn main() { let x = 5; let _y = x; println!("{}", x); let s1 = Str<|fim_suffix|>// compile error println!("{}", s1); }<|fim_middle|>ing::from("hello"); let _s2 = s1;
code_fim
easy
{ "lang": "rust", "repo": "tzuyichao/learning-rust", "path": "/move_vs_copy/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ing::from("hello"); let _s2 = s1; // compile error println!("{}", s1); }<|fim_prefix|>// repo: tzuyichao/learning-rust path: /move_vs_copy/src/main.rs fn main() { let x = 5; let _y = x<|fim_middle|>; println!("{}", x); let s1 = Str
code_fim
easy
{ "lang": "rust", "repo": "tzuyichao/learning-rust", "path": "/move_vs_copy/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(result) } pub fn shell_command_exists(command: &str) -> bool { shell_command(command, true).unwrap().success() } pub fn get_files_in_directory(directory: &Path, recursive: bool) -> Vec<PathBuf> { assert!(directory.is_dir()); let mut files = Vec::<PathBuf>::new(); // Read every e...
code_fim
hard
{ "lang": "rust", "repo": "fivemoreminix/maid", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fivemoreminix/maid path: /src/utils.rs use std::process::{Command, ExitStatus}; use std::path::{Path, PathBuf}; use std::fs; pub fn string_to_vec(string: &str) -> Vec<String> { string.split_whitespace().map(|s| s.to_owned()).collect() } /// Takes a String and turns all occurrences of '/' i...
code_fim
hard
{ "lang": "rust", "repo": "fivemoreminix/maid", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robo9k/chip8-rs path: /src/font.rs //! ROM built-in font sprites /// Number of rows for a font sprite pub(crate) const FONT_SPRITE_ROWS: usize = 5; /// Font sprite data for `0` /// /// ```plain /// ▓▓▓▓░░░░ /// ▓░░▓░░░░ /// ▓░░▓░░░░ /// ▓░░▓░░░░ /// ▓▓▓▓░░░░ /// ``` pub(crate) const SPRITE_DAT...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/font.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Font sprite data for `B` /// /// ```plain /// ▓▓▓░░░░░ /// ▓░░▓░░░░ /// ▓▓▓░░░░░ /// ▓░░▓░░░░ /// ▓▓▓░░░░░ /// ``` pub(crate) const SPRITE_DATA_B: [u8; FONT_SPRITE_ROWS] = [0b11100000, 0b10010000, 0b11100000, 0b10010000, 0b11100000]; /// Font sprite data for `C` /// /// ```plain /// ▓▓▓▓░░░░ /// ...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/font.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn font_as_bytes_iter() -> impl Iterator<Item = &'static u8> { SPRITE_DATA_0 .iter() .chain(SPRITE_DATA_1.iter()) .chain(SPRITE_DATA_2.iter()) .chain(SPRITE_DATA_3.iter()) .chain(SPRITE_DATA_4.iter()) .chain(SPRITE_DATA_5.iter()) .chai...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/font.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Find the best possible move in the current position // looking up to max_depth ahead pub fn find_best_move<B: Board<P>, P: Piece>(board: B, max_depth: i32) -> Move { // default: max_depth=8 let mut best_eval = f32::NEG_INFINITY; let mut best_move: Move = -1; let alpha = f32::NEG_INFINIT...
code_fim
hard
{ "lang": "rust", "repo": "davidssmith/classic", "path": "/src/minimax.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }