text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let gap = size - new_value; let first_side = if offset < 0_f32 { 0_f32 } else if offset > gap { gap } else { offset }; let mut second_side = offset + size / old_zoom - new_value; if second_side > gap { second_side = gap; } else if second_sid...
code_fim
hard
{ "lang": "rust", "repo": "allindier/pixel-canvas", "path": "/src/rust-utils/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allindier/pixel-canvas path: /src/rust-utils/src/lib.rs /// Calculates the new offset when panning. Will attempt to keep the field of view within the canvas. #[no_mangle] pub extern fn calculatePanOffset(coord: f32, offset: f32, zoom: f32, size: f32) -> f32 { let value = size / zoom; let ma...
code_fim
hard
{ "lang": "rust", "repo": "allindier/pixel-canvas", "path": "/src/rust-utils/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut new_offset = coord - new_value / 2_f32; if new_offset < first_side { new_offset = first_side; } else if new_offset > second_side { new_offset = second_side; } new_offset }<|fim_prefix|>// repo: allindier/pixel-canvas path: /src/rust-utils/src/lib.rs /// Calcul...
code_fim
hard
{ "lang": "rust", "repo": "allindier/pixel-canvas", "path": "/src/rust-utils/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: igor-akhmetov/contests path: /AdventOfCode/2018/src/day4.rs use std::collections::HashMap; fn calc_asleep() -> HashMap<i32, [i32; 60]> { let input = std::fs::read_to_string("data/day4.txt").unwrap(); let mut lines : Vec<&str> = input.lines().collect(); let mut asleep = HashMap::...
code_fim
hard
{ "lang": "rust", "repo": "igor-akhmetov/contests", "path": "/AdventOfCode/2018/src/day4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut best_guard : i32 = -1; let mut best_minute = 0; let mut best_cnt = -1; for (&id, sleep) in &asleep { for (minute, &cnt) in sleep.iter().enumerate() { if cnt > best_cnt { best_guard = id; best_minute = minute; best_...
code_fim
medium
{ "lang": "rust", "repo": "igor-akhmetov/contests", "path": "/AdventOfCode/2018/src/day4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn day4_2() -> i32 { let asleep = calc_asleep(); let mut best_guard : i32 = -1; let mut best_minute = 0; let mut best_cnt = -1; for (&id, sleep) in &asleep { for (minute, &cnt) in sleep.iter().enumerate() { if cnt > best_cnt { best_guard = id; ...
code_fim
hard
{ "lang": "rust", "repo": "igor-akhmetov/contests", "path": "/AdventOfCode/2018/src/day4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Default, Eq, PartialEq, Hash, Clone)] pub struct CellStyle { pub font: Option<Font>, pub fill: String, pub numfmt: String, pub border: BorderStyle, } impl<'a> CellStyle { pub fn new(list: ListIterator<'a>) -> NifResult<Self> { let map = crate::workbook::deco...
code_fim
hard
{ "lang": "rust", "repo": "zelixir/elixlsx_native", "path": "/native/elixlsx_native/src/wb_compiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zelixir/elixlsx_native path: /native/elixlsx_native/src/wb_compiler.rs use crate::error::ExcelResult; use rustler::types::ListIterator; use rustler::{Decoder, Error, NifResult, Term}; use std::cmp::Eq; use std::collections::HashMap; use std::hash::Hash; use crate::workbook::{Sheet, Workboo...
code_fim
hard
{ "lang": "rust", "repo": "zelixir/elixlsx_native", "path": "/native/elixlsx_native/src/wb_compiler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (a, b) in states_new .entry(registers) .or_insert(vec![HashSet::new(); 14]) .iter_mut() .zip(inputs) { a.extend(b); } ...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2021/src/day24/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_input(input: &str) -> Vec<Instructions> { input .lines() .map(|input| { let (operation, rest) = input.split_at(3); let operand1 = (rest.chars().nth(1).unwrap() as u8 - 'w' as u8) as usize; if operation == "inp" { return Inst...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2021/src/day24/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pavel1269/advent-of-code path: /2021/src/day24/mod.rs use std::collections::{HashMap, HashSet}; pub fn get_solution_part1() -> i64 { return find_solution().1; } pub fn get_solution_part2() -> i64 { return find_solution().0; } fn find_solution() -> (i64, i64) { // i[3] + 8 = i[4] ...
code_fim
hard
{ "lang": "rust", "repo": "pavel1269/advent-of-code", "path": "/2021/src/day24/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pop-os/libparted path: /src/constraint.rs use super::{cvt, get_optional, Alignment, Geometry}; use std::io; use std::marker::PhantomData; use libparted_sys::{ ped_constraint_destroy, ped_constraint_done, ped_constraint_duplicate, ped_constraint_init, ped_constraint_intersect, ped_constr...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/libparted", "path": "/src/constraint.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Find the largest region that satisfies a constraint.Alignment /// /// There might be more than one solution. This function makes no guarantees about which /// solutions it will choose in this case. pub fn solve_max(&self) -> Option<Geometry<'a>> { get_optional(unsafe { ped_...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/libparted", "path": "/src/constraint.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run(Command::new("sh") .current_dir(&native.out_dir) .arg(native.src_dir.join("autogen.sh").to_str().unwrap()) .arg(format!("--host={}", build_helper::gnu_target(target))) .arg(format!("--build={}", build_helper::gnu_target(host))) .env("CFLAGS", cflags)); ...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave-sgx-sdk", "path": "/sgx_no_tstd/build.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apache/incubator-teaclave-sgx-sdk path: /sgx_no_tstd/build.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave-sgx-sdk", "path": "/sgx_no_tstd/build.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ratijas/windows-rust-counters path: /win-high/src/reg.rs use std::mem::size_of; use crate::prelude::v1::*; const INITIAL_BUFFER_SIZE: usize = 8 * 1024; // Abort after 1 GB const MAX_BUFFER_SIZE: usize = 1024 * 1024 * 1024; /// Create new buffer and call `query_value_with_buffer`. pub fn query...
code_fim
hard
{ "lang": "rust", "repo": "ratijas/windows-rust-counters", "path": "/win-high/src/reg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// in cases when value size is known in advance, we may __try__ to use that as a size hint. /// but it won't work with dynamic values, such as counters data; and it must not be trusted /// as a final size, because anything could happen between two calls to RegQueryValueExW. /// /// it certainly can NOT b...
code_fim
hard
{ "lang": "rust", "repo": "ratijas/windows-rust-counters", "path": "/win-high/src/reg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // first argument is passed in RDI let location = func.arguments[0].location; match location { dwarf_x86::ArgumentLocation::Register(r) => { assert_eq!(r, dwarf_x86::X86Register::rdi); } _ => panic!("ar...
code_fim
hard
{ "lang": "rust", "repo": "ammaraskar/rust-dwarf-x86", "path": "/tests/functions_test.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ammaraskar/rust-dwarf-x86 path: /tests/functions_test.rs extern crate dwarf_x86; use std::path::Path; #[test] fn it_scrapes_functions() { let executable = dwarf_x86::load_executable(Path::new("./test_files/simple_executable")) .unwrap(); executable.get_functions(); } <|fim_su...
code_fim
hard
{ "lang": "rust", "repo": "ammaraskar/rust-dwarf-x86", "path": "/tests/functions_test.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(func.arguments[0].name, "a"); assert_eq!(func.arguments[1].name, "b"); assert_eq!(func.arguments[2].name, "c"); } else { println!("{:?}", func.name); panic!("Wrong function detected"); } } }<|fim_prefix|>// repo: am...
code_fim
hard
{ "lang": "rust", "repo": "ammaraskar/rust-dwarf-x86", "path": "/tests/functions_test.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with_nodes(mut self, nodes: &[Node]) -> Self { self.nodes = nodes.to_vec(); self } pub fn with_edges(mut self, edges: &[Edge]) -> Self { self.edges = edges.to_vec(); self } pub fn get_node(&self, name: &str) -> Option<&Node> { self.nodes...
code_fim
hard
{ "lang": "rust", "repo": "ozbe/exercisim", "path": "/rust/dot-dsl/src/graph/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ozbe/exercisim path: /rust/dot-dsl/src/graph/mod.rs pub mod graph_items; use graph_items::edge::Edge; use graph_items::node::Node; use std::borrow::Borrow; use std::collections::HashMap; #[derive(Debug)] pub struct Graph { pub attrs: HashMap<String, String>, pub nodes: Vec<Node>, p...
code_fim
hard
{ "lang": "rust", "repo": "ozbe/exercisim", "path": "/rust/dot-dsl/src/graph/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let native_call = text[native_call_range.start as usize..].as_ptr() as *mut _; let native_call = NonNull::new(native_call).unwrap(); let sig = engine.signatures().register(ft.as_wasm_func_type()); unsafe { Ok(VMArrayCallHostFuncContext::new( VMFuncRef { ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/wasmtime/src/trampoline/func.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/wasmtime/src/trampoline/func.rs //! Support for a calling of an imported function. use crate::{Engine, FuncType, ValRaw}; use anyhow::Result; use std::panic::{self, AssertUnwindSafe}; use std::ptr::NonNull; use wasmtime_jit::CodeMemory; use wasmtime_runti...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/crates/wasmtime/src/trampoline/func.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|><'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !0x0f) | ((value as u8) & 0x0f); self.w } } impl R { #[doc = "Bits 0:3"] #[inline(always)] pub fn o(&self) -> O_R { ...
code_fim
hard
{ "lang": "rust", "repo": "im-tomu/fomu-pac-rs", "path": "/src/touch/o.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: im-tomu/fomu-pac-rs path: /src/touch/o.rs #[doc = "Reader of register O"] pub type R = crate::R<u8, super::O>; #[doc = "Writer for register O"] pub type W = crate::W<u8, super::O>; #[doc = "Register O `reset()`'s with value 0"] impl crate::ResetValue for super::O { type Type = u8; #[inli...
code_fim
hard
{ "lang": "rust", "repo": "im-tomu/fomu-pac-rs", "path": "/src/touch/o.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Neuronic for Neuron { fn run_cycle(&self, cycle: ChargeCycle) -> Measure { let synapse_measures: Vec<Measure> = self .synapses .borrow() .iter() .map(|synapse| synapse.input.get_measure(cycle)) .collect(); let synapse_wei...
code_fim
hard
{ "lang": "rust", "repo": "DGeisz/peorth", "path": "/src/neuron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DGeisz/peorth path: /src/neuron.rs use std::cell::RefCell; use std::rc::Rc; #[derive(Copy, Clone)] pub enum ChargeCycle { Even, Odd, } impl ChargeCycle { // Note that prev_cycle and next_cycle // do the exact same thing pub fn next_cycle(&self) -> ChargeCycle { self...
code_fim
hard
{ "lang": "rust", "repo": "DGeisz/peorth", "path": "/src/neuron.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *self.synapses.borrow_mut() = synapses; *self.prediction_weights.borrow_mut() = initial_prediction_weights; } pub fn intake_internal_charge( &self, cycle: ChargeCycle, measure: Measure, prediction_quality: f32, ) { self.internal_charge ...
code_fim
hard
{ "lang": "rust", "repo": "DGeisz/peorth", "path": "/src/neuron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rustbox.lock().unwrap().present(); let clonebox = rustbox.clone(); thread::spawn(move || { thread::sleep(duration); if white { clonebox.lock().unwrap().print(pos as usize, 15, rustbox::RB_BOLD, Color::White, Color::White, "▒▒"); } else { clonebox...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/piano-rs", "path": "/src/game/screen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/piano-rs path: /src/game/screen.rs use rustbox::{Color, RustBox}; use std::sync::{Arc, Mutex}; use std::{thread, time}; /* █▒ */ pub mod pianokeys { use rustbox::{Color, RustBox}; use std::sync::{Arc, Mutex}; struct Point { x: u16, y: u16, } pub f...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/piano-rs", "path": "/src/game/screen.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/cargo path: /crates/mdman/src/format/md.rs //! Markdown formatter. use crate::util::unwrap; use crate::ManMap; use anyhow::{bail, format_err, Error}; use std::fmt::Write; pub struct MdFormatter { man_map: ManMap, } impl MdFormatter { pub fn new(man_map: ManMap) -> MdFormatte...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/crates/mdman/src/format/md.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = String::new(); fn unwrap_p(t: &str) -> &str { unwrap(t, "<p>", "</p>") } for param in params { let rendered = self.render_html(param)?; let no_p = unwrap_p(&rendered); // split out first term to use as the id...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/crates/mdman/src/format/md.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let mut receivers = Vec::with_capacity(NUM_THREADS); for _ in 0..NUM_THREADS { let thread = thread::spawn(move || { let mut counter = 0; while counter < AMOUNT { if let Some(i) = QUEUE.pop() { RECEIVED[...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/libs/mpmc_queue/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theseus-os/Theseus path: /libs/mpmc_queue/src/lib.rs //! A growable, first-in first-out, multi-producer, multi-consumer, queue. //! //! The implementation is **heavily** inspired by the [Tokio inject queue]. //! //! [Tokio inject queue]: https://github.com/tokio-rs/tokio/blob/master/tokio/src/ru...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/libs/mpmc_queue/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_spsc() { static QUEUE: Queue<Spin, i32> = Queue::new(); for i in 0..100 { QUEUE.push(i); } for i in 0..100 { assert_eq!(QUEUE.pop().unwrap(), i); } assert!(QUEUE.is_empty()); } /// Adapted from the ...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/libs/mpmc_queue/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<A> Invoke<A> for Identity { type Result = A; fn invoke(self, arg: A) -> A { arg } }<|fim_prefix|>// repo: paritytech/parity-wasm path: /src/builder/invoke.rs //! invoke helper /// Helper trait to allow chaining pub trait Invoke<A> { type Result; fn invoke(self, arg: A) -> Self::Result; } ...
code_fim
easy
{ "lang": "rust", "repo": "paritytech/parity-wasm", "path": "/src/builder/invoke.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>} /// Identity chain element pub struct Identity; impl<A> Invoke<A> for Identity { type Result = A; fn invoke(self, arg: A) -> A { arg } }<|fim_prefix|>// repo: paritytech/parity-wasm path: /src/builder/invoke.rs //! invoke helper /// Helper trait to allow chaining pub trait Invoke<A> { type Re...
code_fim
easy
{ "lang": "rust", "repo": "paritytech/parity-wasm", "path": "/src/builder/invoke.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/parity-wasm path: /src/builder/invoke.rs //! invoke helper /// Helper trait to allow chaining pub trait Invoke<A> { type Result; <|fim_suffix|>} /// Identity chain element pub struct Identity; impl<A> Invoke<A> for Identity { type Result = A; fn invoke(self, arg: A) -> A { a...
code_fim
easy
{ "lang": "rust", "repo": "paritytech/parity-wasm", "path": "/src/builder/invoke.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZN11QThreadPool14globalInstanceEv()}; let mut ret = unsafe {C_ZN11QThreadPool14globalInstanceEv()}; let mut ret1 = QThreadPool::inheritFrom(ret as u64); return ret1; // return 1; } } // proto: void QThreadPool::set...
code_fim
hard
{ "lang": "rust", "repo": "kitech/qt.rs", "path": "/src/core/qthreadpool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kitech/qt.rs path: /src/core/qthreadpool.rs / // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <= main block end // use block begin => use super::qobject::*; // 773 us...
code_fim
hard
{ "lang": "rust", "repo": "kitech/qt.rs", "path": "/src/core/qthreadpool.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // proto: void QThreadPool::clear(); impl<'a> /*trait*/ QThreadPool_clear<()> for () { fn clear(self , rsthis: & QThreadPool) -> () { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZN11QThreadPool5clearEv()}; unsafe {C_ZN11QThreadPool5clearEv(rsthis.qclsinst)}; // retu...
code_fim
hard
{ "lang": "rust", "repo": "kitech/qt.rs", "path": "/src/core/qthreadpool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/23483 - Construct Points.rs use io::Write; use std::io; fn main() { <|fim_suffix|> writeln!(out, "{} {}", 0, -1_000_000_000).unwrap(); writeln!(out, "{} {}", 1_000_000_000, 1).unwrap(); writeln!(out, "{} {}", -1_000_000_000, 0).unwrap(); writeln!(out, ...
code_fim
medium
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/23483 - Construct Points.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(out, "{} {}", 0, -1_000_000_000).unwrap(); writeln!(out, "{} {}", 1_000_000_000, 1).unwrap(); writeln!(out, "{} {}", -1_000_000_000, 0).unwrap(); writeln!(out, "{} {}", -1, 1_000_000_000).unwrap(); }<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/23483 - Construct Points.rs us...
code_fim
medium
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/23483 - Construct Points.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foresterre/sic path: /crates/sic_image_engine/src/operations/resize.rs use crate::errors::SicImageEngineError; use crate::helper; use crate::operations::ImageOperation; use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use sic_core::image::imageops; use sic_core::image::imageops::...
code_fim
hard
{ "lang": "rust", "repo": "foresterre/sic", "path": "/crates/sic_image_engine/src/operations/resize.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn resize_static(image: &mut DynamicImage, cfg: &Resize) { if cfg.preserve_aspect_ratio { resize_with_preserve_aspect_ratio(image, cfg.x, cfg.y, cfg.filter_type) } else { resize_regularly(image, cfg.x, cfg.y, cfg.filter_type) } } fn resize_regularly(image: &mut DynamicImage, x...
code_fim
hard
{ "lang": "rust", "repo": "foresterre/sic", "path": "/crates/sic_image_engine/src/operations/resize.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> use main::{main_twitch, main_youtube};<|fim_prefix|>// repo: loicngr/InfluencerApi path: /src/paranoi4k/mod.rs mod model; mod routes; mod controller;<|fim_middle|> mod main; pub use model::{Twitch, Youtube}; pub use routes::init_routes; pub
code_fim
medium
{ "lang": "rust", "repo": "loicngr/InfluencerApi", "path": "/src/paranoi4k/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loicngr/InfluencerApi path: /src/paranoi4k/mod.rs mod model; mod routes; mod controller;<|fim_suffix|>tube}; pub use routes::init_routes; pub use main::{main_twitch, main_youtube};<|fim_middle|> mod main; pub use model::{Twitch, You
code_fim
easy
{ "lang": "rust", "repo": "loicngr/InfluencerApi", "path": "/src/paranoi4k/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuizho/atcoder path: /rust/src/edpc/a.rs use std::io::Read; fn main() { let mut buf = String::new(); // 標準入力から全部bufに読み込む std::io::stdin().read_to_string(&mut buf).unwrap(); <|fim_suffix|> for step in 1..steps { if step == 1 { dp[step] = i32::abs(costs[step -...
code_fim
hard
{ "lang": "rust", "repo": "yuizho/atcoder", "path": "/rust/src/edpc/a.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for step in 1..steps { if step == 1 { dp[step] = i32::abs(costs[step - 1] - costs[step]); continue; } let one_step_cost = dp[step - 1] + i32::abs(costs[step - 1] - costs[step]); let tow_step_cost = dp[step - 2] + i32::abs(costs[step - 2] - costs[...
code_fim
hard
{ "lang": "rust", "repo": "yuizho/atcoder", "path": "/rust/src/edpc/a.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: regiontog/retreat path: /noser/src/noser.rs #![deny(clippy::all)] pub type Ptr = u32; mod implementation; pub mod traits; pub mod writer; pub use crate::implementation::*; #[derive(Debug)] pub enum NoserError { Undersized(usize, Vec<u8>), IntegerOverflow, Malformed, } <|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "regiontog/retreat", "path": "/noser/src/noser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let at = at as usize; if self.len() < at { return Err(crate::NoserError::Undersized(at, self.to_vec())); } Ok(self.split_at_mut(at)) } #[inline] fn noser_split_imut(&self, at: crate::Ptr) -> crate::Result<(&[u8], &[...
code_fim
medium
{ "lang": "rust", "repo": "regiontog/retreat", "path": "/noser/src/noser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" fn leave_task() -> ! { core_scheduler().exit(0); } extern "C" fn task_entry(func: extern "C" fn(usize), arg: usize) { // Check if the task (process or thread) uses Thread-Local-Storage. let tls_size = unsafe { &tls_end as *const u8 as usize - &tls_start as *const u8 as usize }; if tls_size...
code_fim
hard
{ "lang": "rust", "repo": "AiCaramba/libhermit-rs", "path": "/librs/src/arch/aarch64/scheduler.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AiCaramba/libhermit-rs path: /librs/src/arch/aarch64/scheduler.rs // Copyright (c) 2018 Stefan Lankes, RWTH Aachen University // 2018 Colin Finck, RWTH Aachen University // // MIT License // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this ...
code_fim
hard
{ "lang": "rust", "repo": "AiCaramba/libhermit-rs", "path": "/librs/src/arch/aarch64/scheduler.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(DICTIONARY.contains("MOTORCYCLE"), true); } #[test] fn dictionary_no_word() { assert_eq!(DICTIONARY.contains("BLAHBLAHBLAH"), false); } }<|fim_prefix|>// repo: Tyler-Zhang/words-with-coworkers path: /words-game/src/constants.rs use std::collections::HashSet; us...
code_fim
medium
{ "lang": "rust", "repo": "Tyler-Zhang/words-with-coworkers", "path": "/words-game/src/constants.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn dictionary_has_word() { assert_eq!(DICTIONARY.contains("MOTORCYCLE"), true); } #[test] fn dictionary_no_word() { assert_eq!(DICTIONARY.contains("BLAHBLAHBLAH"), false); } }<|fim_prefix|>// repo: Tyler-Zhang/words-with-coworkers path: /words-game/src/con...
code_fim
hard
{ "lang": "rust", "repo": "Tyler-Zhang/words-with-coworkers", "path": "/words-game/src/constants.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tyler-Zhang/words-with-coworkers path: /words-game/src/constants.rs use std::collections::HashSet; use std::str; pub static HAND_SIZE: usize = 10; /* The Map of the default board . - Empty piece 3 - Triple word 2 - Double word @ - Double letter # - Triple letter + - S...
code_fim
medium
{ "lang": "rust", "repo": "Tyler-Zhang/words-with-coworkers", "path": "/words-game/src/constants.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let w_id_usz: usize; let height: i32; let job_id: u64; let _nonce: u64; let edge_bits:...
code_fim
hard
{ "lang": "rust", "repo": "haobtc/grin-pool", "path": "/stratum/src/pool/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haobtc/grin-pool path: /stratum/src/pool/server.rs _ => { // XXX TODO: Unknown request type from the upstream stratum server - log it and continue debug!( L...
code_fim
hard
{ "lang": "rust", "repo": "haobtc/grin-pool", "path": "/stratum/src/pool/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haobtc/grin-pool path: /stratum/src/pool/server.rs ) + ":" + &self.config.grin_node.stratum_port.to_string(); warn!( LOGGER, "{} - Connecting to upstream stratum server at {}", self.id, grin_stratum_url.to_string() ...
code_fim
hard
{ "lang": "rust", "repo": "haobtc/grin-pool", "path": "/stratum/src/pool/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn loop_with_while(x : i32) { let mut number = x; while number != 0 { println!("{}", number); number -= 1; } println!("LiftOff"); } fn loop_with_for() { let a = [10, 20, 30, 40, 50]; for element in a.iter() { println!("the valeu is: {}", element); } }...
code_fim
hard
{ "lang": "rust", "repo": "ayaromenok/rustEvaluation", "path": "/general/ch3_3_functions/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ayaromenok/rustEvaluation path: /general/ch3_3_functions/src/main.rs fn main() { println!("ch3_3_functions"); another_function(5, -5); let x5 = five(); println!("value of fn five() is: {}", x5); let x6 = plus_one(5); println!("value of fn plus_one(5) is: {}", x6); if_...
code_fim
hard
{ "lang": "rust", "repo": "ayaromenok/rustEvaluation", "path": "/general/ch3_3_functions/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while number != 0 { println!("{}", number); number -= 1; } println!("LiftOff"); } fn loop_with_for() { let a = [10, 20, 30, 40, 50]; for element in a.iter() { println!("the valeu is: {}", element); } }<|fim_prefix|>// repo: ayaromenok/rustEvaluation path:...
code_fim
hard
{ "lang": "rust", "repo": "ayaromenok/rustEvaluation", "path": "/general/ch3_3_functions/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boblannon/learning-rust path: /the-book/09_error-handling/propagating/src/main.rs use std::io; use std::io::Read; use std::fs::File; fn read_username_from_file() -> Result<String, io::Error> { let f = File::open("hello.txt"); <|fim_suffix|> let mut s = String::new(); match f.read_t...
code_fim
medium
{ "lang": "rust", "repo": "boblannon/learning-rust", "path": "/the-book/09_error-handling/propagating/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { //read_username_from_file(); let output = shortcut(); let output = match output { Ok(file) => file, Err(e) => panic!("Oops! {:?}", e), }; // main doesn't return a result, so it can't use ? operator. This will not // compile: // let f = File::open("h...
code_fim
hard
{ "lang": "rust", "repo": "boblannon/learning-rust", "path": "/the-book/09_error-handling/propagating/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_file(dataset_file: &str) -> Result<Dataset, String> { if !metadata(dataset_file).expect("error: a problem occured with the file").is_file() { return Err(String::from("error: the file should be a file")); } let file = File::open(dataset_file).expect("error: file not found"); ...
code_fim
hard
{ "lang": "rust", "repo": "simongalasso/dslr", "path": "/src/describe/parsing/parse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simongalasso/dslr path: /src/describe/parsing/parse.rs use crate::data::data::{Data, Dataset}; use std::fs::File; use std::fs::metadata; use std::io::prelude::*; use std::io::BufReader; // pub const HOGWARTS_HOUSE: usize = 0; // pub const FIRST_NAME: usize = 1; // pub const LAST_NAME: usize = ...
code_fim
hard
{ "lang": "rust", "repo": "simongalasso/dslr", "path": "/src/describe/parsing/parse.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zdimension/parm_extended path: /code_rs/parm/src/tty.rs #[doc(inline)] pub use crate::__print__ as print; #[doc(inline)] pub use crate::__println__ as println; use crate::{keyb, mmio}; use crate::mmio::{RES, RESbcd}; #[doc(hidden)] #[macro_export] macro_rules! __print__ { (@p $c:literal) => ...
code_fim
hard
{ "lang": "rust", "repo": "zdimension/parm_extended", "path": "/code_rs/parm/src/tty.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut found = false; let max = match width { None => 8, Some(w) => w }; for _ in 0..max { let digit = bcd & 0xf; bcd >>= 4; if matches!(width, None) && !found { if digit != 0 { found = true; } else { continue; } } print_char(digit as u8 + b'0'); } }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "zdimension/parm_extended", "path": "/code_rs/parm/src/tty.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robertbrignull/rhythmical path: /src/api.rs extern crate regex; extern crate serde; extern crate serde_derive; extern crate serde_json; use regex::Regex; use rouille::{Request, Response}; use args::ServeArgs; use gsutil; use library::Library; #[derive(Serialize)] struct ApiSong { id: Stri...
code_fim
hard
{ "lang": "rust", "repo": "robertbrignull/rhythmical", "path": "/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let url = request.url(); return match self.songs_contents_regex.captures(url.as_str()) { Some(cap) => match cap[1].parse::<String>() { Ok(id) => self.song_contents(id), Err(_) => Response::text("Song id is not an integer").with_status_code(400), ...
code_fim
hard
{ "lang": "rust", "repo": "robertbrignull/rhythmical", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xdatcloud/firestarter path: /src/reloader.rs use crate::config::WorkerConfig; use std::{io, path, time}; fn is_modified(path: &path::PathBuf, current_mtime: &time::SystemTime) -> io::Result<bool> { <|fim_suffix|>pub fn cmd_path(config: &WorkerConfig) -> path::PathBuf { let cmd = &config.exe...
code_fim
medium
{ "lang": "rust", "repo": "xdatcloud/firestarter", "path": "/src/reloader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_modified_cmd( config: &WorkerConfig, current_path: &path::PathBuf, current_mtime: &time::SystemTime, ) -> io::Result<bool> { let path = cmd_path(config); if *current_path != path { return Ok(true); } is_modified(&path, current_mtime) }<|fim_prefix|>// repo: xd...
code_fim
hard
{ "lang": "rust", "repo": "xdatcloud/firestarter", "path": "/src/reloader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VillSnow/eaw-rs path: /src/tests.rs use crate::Width; use crate::*; #[test] fn test_solver() { assert_eq!(EastAsianWidth::Ambiguous, solve_eaw(0xA1)); assert_eq!(EastAsianWidth::Narrow, solve_eaw(0xA2)); assert_eq!(EastAsianWidth::Narrow, solve_eaw(0xA3)); assert_eq!(Eas...
code_fim
hard
{ "lang": "rust", "repo": "VillSnow/eaw-rs", "path": "/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let s6 = "AアあA*𓄿"; assert_eq!(8, s6.width(EastAsianContextCharWidthSelector)); assert_eq!(8, s6.width(NonEastAsianContextCharWidthSelector)); let s7 = "AアあA*α"; assert_eq!(9, s7.width(EastAsianContextCharWidthSelector)); assert_eq!(8, s7.width(NonEastAsianContextCharWidthSe...
code_fim
hard
{ "lang": "rust", "repo": "VillSnow/eaw-rs", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 255 << 24 | r << 16 | g << 8 | b } pub fn render(width: usize, height: usize, camera: Camera, world: HitableList) -> Vec<u32> { let pb = ProgressBar::new((width * height) as u64); pb.set_style(ProgressStyle::default_bar() .template("{spinner:.green} [{elapsed_precise}, {percent}%] [{b...
code_fim
hard
{ "lang": "rust", "repo": "pcolusso/rray", "path": "/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pcolusso/rray path: /src/renderer.rs use crate::camera::Camera; use crate::hitable::{Hitable, HitableList}; use crate::ray::Ray; use glm::{vec3, Vec3}; use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle}; use rand::prelude::*; use rayon::prelude::*; #[cfg(debug_assertions)] co...
code_fim
hard
{ "lang": "rust", "repo": "pcolusso/rray", "path": "/src/renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (0..width * height) .into_par_iter() .progress_with(pb) .map_init( || thread_rng(), |mut rng, screen_pos| { let mut c = vec3(0.0, 0.0, 0.0); let i = height - 1 - screen_pos / width; let j = screen_pos % wid...
code_fim
hard
{ "lang": "rust", "repo": "pcolusso/rray", "path": "/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update_metadata_changed_time<'a>( &self, inode: u64, builder: FlatBufferBuilder<'a>, ) -> ResultResponse<'a> { self.metadata_storage.update_metadata_changed_time(inode)?; return empty_response(builder); } pub fn hardlink_rollback<'a>( ...
code_fim
hard
{ "lang": "rust", "repo": "cberner/fleetfs", "path": "/src/storage/local/file_storage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_xattr<'a>( &self, inode: u64, key: &str, value: &[u8], context: UserContext, builder: FlatBufferBuilder<'a>, ) -> ResultResponse<'a> { self.metadata_storage .set_xattr(inode, key, value, context)?; return empty_...
code_fim
hard
{ "lang": "rust", "repo": "cberner/fleetfs", "path": "/src/storage/local/file_storage.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cberner/fleetfs path: /src/storage/local/file_storage.rs use flatbuffers::{FlatBufferBuilder, WIPOffset}; use log::info; use crate::base::{empty_response, node_id_from_address, FlatBufferWithResponse, ResultResponse}; use crate::client::TcpPeerClient; use crate::generated::*; use crate::storage...
code_fim
hard
{ "lang": "rust", "repo": "cberner/fleetfs", "path": "/src/storage/local/file_storage.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JeeZeh/advent-of-code path: /2022/src/day04.rs struct Pair(Zone, Zone); struct Zone { start: u32, end: u32, } pub fn solve(lines: Vec<String>) -> (usize, usize) { let pairs: Vec<Pair> = lines.iter().map(|s| parse_pair(s)).collect(); ( pairs.iter().filter(|p| p.overlaps_f...
code_fim
hard
{ "lang": "rust", "repo": "JeeZeh/advent-of-code", "path": "/2022/src/day04.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Pair(left, right) } fn parse_zone(s: &str) -> Zone { let mut parts = s.split('-'); let start = parts.next().unwrap().parse().unwrap(); let end = parts.next().unwrap().parse().unwrap(); Zone { start, end } }<|fim_prefix|>// repo: JeeZeh/advent-of-code path: /2022/src/day04.rs struct ...
code_fim
hard
{ "lang": "rust", "repo": "JeeZeh/advent-of-code", "path": "/2022/src/day04.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: filcloud/merkle_light path: /benches/hash512/hash512.rs use std::cmp::Ordering; use merkletree::merkle::Element; #[derive(Copy, Clone)] pub struct Hash512(pub [u8; 64]); impl std::fmt::Debug for Hash512 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "...
code_fim
hard
{ "lang": "rust", "repo": "filcloud/merkle_light", "path": "/benches/hash512/hash512.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> PartialOrd::lt(&&self.0[..], &&other.0[..]) } #[inline] fn le(&self, other: &Hash512) -> bool { PartialOrd::le(&&self.0[..], &&other.0[..]) } #[inline] fn ge(&self, other: &Hash512) -> bool { PartialOrd::ge(&&self.0[..], &&other.0[..]) } #[inline]...
code_fim
hard
{ "lang": "rust", "repo": "filcloud/merkle_light", "path": "/benches/hash512/hash512.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl Element for Hash512 { fn byte_len() -> usize { 64 } fn from_slice(bytes: &[u8]) -> Self { assert_eq!(bytes.len(), 64); let mut a = Self::default(); a.0.copy_from_slice(bytes); a } fn copy_to_slice(&self, bytes: &mut [u8]) { bytes[...
code_fim
hard
{ "lang": "rust", "repo": "filcloud/merkle_light", "path": "/benches/hash512/hash512.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Flux-Audio/vibe_machine path: /src/widgets.rs // third-party dependencies use vst::util::AtomicFloat; use femtovg::{renderer::OpenGl, Canvas, LineCap, Paint, Path, Solidity, Color, LineJoin}; use tuix::*; // stl dependencies use std::sync::Arc; use std::collections::HashMap; // internal depen...
code_fim
hard
{ "lang": "rust", "repo": "Flux-Audio/vibe_machine", "path": "/src/widgets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // end early if invisible, skips all rendering (near zero cost) if state.data.get_visibility(entity) == Visibility::Invisible { return; } let opacity = state.data.get_opacity(entity); // background color of the knob let mut back_col: Color = self.back_col.get_bac...
code_fim
hard
{ "lang": "rust", "repo": "Flux-Audio/vibe_machine", "path": "/src/widgets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Link<T> { #[inline(always)] pub fn take(&mut self) -> Link<T> { Link(self.0.take()) } #[inline(always)] pub fn replace(&mut self, mut other: Link<T>) -> Link<T> { self.swap(&mut other); other } #[inline(always)] pub fn swap(&mut self, other: &mut Link<T>) { swap(self,other)...
code_fim
hard
{ "lang": "rust", "repo": "irrustible/chonky", "path": "/src/owned/link.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: irrustible/chonky path: /src/owned/link.rs use core::mem::swap; use core::ptr::NonNull; pub struct Link<T>(pub(crate) Option<NonNull<T>>); impl<T> Clone for Link<T> { #[inline(always)] fn clone(&self) -> Self { Link(self.0) } } impl<T> Copy for Link<T> {} impl<T> From<Option<NonNull<...
code_fim
hard
{ "lang": "rust", "repo": "irrustible/chonky", "path": "/src/owned/link.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> fn is_sorted(vector: &Vec<T>) -> bool { for i in 1..vector.len() { if Self::less(&vector[i], &vector[i - 1]) { return false; } } true } }<|fim_prefix|>// repo: lazystitan/rust-learning-and-practice path: /algorithms/src/sort/sort_tra...
code_fim
medium
{ "lang": "rust", "repo": "lazystitan/rust-learning-and-practice", "path": "/algorithms/src/sort/sort_trait.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 1..vector.len() { if Self::less(&vector[i], &vector[i - 1]) { return false; } } true } }<|fim_prefix|>// repo: lazystitan/rust-learning-and-practice path: /algorithms/src/sort/sort_trait.rs pub trait SortTrait<T> where T: Pa...
code_fim
medium
{ "lang": "rust", "repo": "lazystitan/rust-learning-and-practice", "path": "/algorithms/src/sort/sort_trait.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lazystitan/rust-learning-and-practice path: /algorithms/src/sort/sort_trait.rs pub trait SortTrait<T> where T: PartialEq + PartialOrd, { fn sort(vector: &mut Vec<T>); <|fim_suffix|> fn is_sorted(vector: &Vec<T>) -> bool { for i in 1..vector.len() { if Self::less(&...
code_fim
medium
{ "lang": "rust", "repo": "lazystitan/rust-learning-and-practice", "path": "/algorithms/src/sort/sort_trait.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: segeljakt/braille path: /examples/example-1.rs use braille::*; fn main() { println!("{}", BRAILLE[1][0] [0][1] [1][0] [1][1]); <|fim_suffix|> println!("{}", BRAILLE_SINGLE[2][1]); println!("{}", BOX_SINGL...
code_fim
hard
{ "lang": "rust", "repo": "segeljakt/braille", "path": "/examples/example-1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", BRAILLE_SINGLE[2][1]); println!("{}", BOX_SINGLE[1][1]); for a in 0..2 { for b in 0..2 { for c in 0..2 { for d in 0..2 { for e in 0..2 { for f in 0..2 { for g in 0..2 { ...
code_fim
hard
{ "lang": "rust", "repo": "segeljakt/braille", "path": "/examples/example-1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndreOGodoy/snake_game path: /src/game/snake.rs use opengl_graphics::GlGraphics; use piston::input::*; use std::collections::LinkedList; use crate::coord::Coord; #[derive(PartialEq, Clone, Copy)] enum Direction { UP, DOWN, LEFT, RIGHT, HOLD, } pub struct Snake { pub h...
code_fim
hard
{ "lang": "rust", "repo": "AndreOGodoy/snake_game", "path": "/src/game/snake.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn eat(&mut self) { let head = self.head_coord; if self.body.is_empty() { self.body.push_back(head); } else { self.body.push_back(*self.body.back().unwrap()); } } pub fn register(&mut self, button: &Button) { let last_direct...
code_fim
hard
{ "lang": "rust", "repo": "AndreOGodoy/snake_game", "path": "/src/game/snake.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let item = if let NodeType::Leaf(ref item) = self.node_type { Some(item.clone()) } else { None }; let min = self.aabb.min; let max = self.aabb.max; let side_length = (max.x - min.x) / 2.0; // Change current NodeType to inter...
code_fim
hard
{ "lang": "rust", "repo": "CloneRob/Octree", "path": "/src/octree_node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CloneRob/Octree path: /src/octree_node.rs // Standard Library use std::fmt::Debug; use std::mem; // External Library use cgmath::Point3; use collision::{Frustum, Aabb, Aabb3}; use {Surround, MinVolume, OctreeItem}; impl Surround for Aabb3<f32> { fn surrounds(&self, other: &Self) -> bool {...
code_fim
hard
{ "lang": "rust", "repo": "CloneRob/Octree", "path": "/src/octree_node.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for node in iter { // only check nodes whose axis aligned bounding box is inside // the given box if vol.surrounds(&node.aabb) { match node.node_type { NodeType::Leaf(ref item) => { items.push(item); ...
code_fim
hard
{ "lang": "rust", "repo": "CloneRob/Octree", "path": "/src/octree_node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }