text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> result } } fn main() { assert_eq!( Solution::matrix_reshape(vec![vec![1, 2], vec![3, 4]], 1, 4), vec![vec![1, 2, 3, 4]] ); assert_eq!( Solution::matrix_reshape(vec![vec![1, 2], vec![3, 4], vec![5, 6], vec![7, 8]], 2, 4), vec![vec![1, 2, 3, 4], vec![...
code_fim
hard
{ "lang": "rust", "repo": "ytakhs/leetcode-rs", "path": "/examples/archives/matrix_reshape.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ytakhs/leetcode-rs path: /examples/archives/matrix_reshape.rs struct Solution {} impl Solution { pub fn matrix_reshape(nums: Vec<Vec<i32>>, r: i32, c: i32) -> Vec<Vec<i32>> { if nums.is_empty() { return nums; } let total = nums.len() * nums[0].len(); ...
code_fim
hard
{ "lang": "rust", "repo": "ytakhs/leetcode-rs", "path": "/examples/archives/matrix_reshape.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn gather() -> Result<Vec<Metric>, ()> { todo!() }<|fim_prefix|>// repo: arnohub/vertex path: /src/sources/node/protocols.rs /// Expose metrics from /proc/net/protocols /// /// https://github.com/prometheus/node_exporter/pull/1921 <|fim_middle|>use event::Metric;
code_fim
easy
{ "lang": "rust", "repo": "arnohub/vertex", "path": "/src/sources/node/protocols.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arnohub/vertex path: /src/sources/node/protocols.rs /// Expose metrics from /proc/net/protocols /// /// https://github.com/prometheus/node_exporter/pull/1921 <|fim_suffix|>pub async fn gather() -> Result<Vec<Metric>, ()> { todo!() }<|fim_middle|>use event::Metric;
code_fim
easy
{ "lang": "rust", "repo": "arnohub/vertex", "path": "/src/sources/node/protocols.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: btcmacroecon/subwasm path: /lib/src/metadata_wrapper.rs use frame_metadata::RuntimeMetadata; use log::debug; use crate::{convert::convert, display_module}; pub struct MetadataWrapper<'a>(pub &'a RuntimeMetadata); <|fim_suffix|> match &self.0 { RuntimeMetadata::V12(v12) => { display_mod...
code_fim
hard
{ "lang": "rust", "repo": "btcmacroecon/subwasm", "path": "/lib/src/metadata_wrapper.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Display a single module pub fn display_single_module(&self, filter: &str) { debug!("metadata_wapper::display_module with filter: {:?}", filter); match &self.0 { RuntimeMetadata::V12(v12) => { display_module!(convert(&v12.modules), filter); } RuntimeMetadata::V13(v13) => { displ...
code_fim
hard
{ "lang": "rust", "repo": "btcmacroecon/subwasm", "path": "/lib/src/metadata_wrapper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SymbioticLab/Kayak path: /net/framework/src/operators/composition_batch.rs use super::Batch; use super::act::Act; use super::iterator::{BatchIterator, PacketDescriptor}; use super::packet_batch::PacketBatch; use common::*; use headers::EndOffset; use headers::NullHeader; use interface::PacketTx;...
code_fim
medium
{ "lang": "rust", "repo": "SymbioticLab/Kayak", "path": "/net/framework/src/operators/composition_batch.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_check_return_values_2() { let (y, err) = returns_tuple(); match err { MyErr::None => { trace!("tuple: Is OK: {:?}", y); }, MyErr::Fail => { trace!("tuple: Failed one"); } } }<|fim_prefix|>// repo: shadowmint/rust-blah path: /src/tuples.rs #[derive(Debug)] enum MyErr { None...
code_fim
hard
{ "lang": "rust", "repo": "shadowmint/rust-blah", "path": "/src/tuples.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shadowmint/rust-blah path: /src/tuples.rs #[derive(Debug)] enum MyErr { None, Fail, } fn returns_tuple() -> (isize, MyErr) { // return (1, None); return (0, MyErr::Fail); } fn returns_result() -> Result<isize, MyErr> { <|fim_suffix|> let x = returns_result(); if x.is_ok() { trac...
code_fim
medium
{ "lang": "rust", "repo": "shadowmint/rust-blah", "path": "/src/tuples.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: equation314/simple-polygon path: /core/src/tri/mono_partition.rs me(Ordering::Equal) } else { self.x().partial_cmp(&other.x()) } } } impl PartialEq for TrapezoidKey { fn eq(&self, other: &Self) -> bool { (self.x() - other.x()).abs() < Point::EPS }...
code_fim
hard
{ "lang": "rust", "repo": "equation314/simple-polygon", "path": "/core/src/tri/mono_partition.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: equation314/simple-polygon path: /core/src/tri/mono_partition.rs t_edge_end: &Point) -> Self { let k = (left_edge_end.x - left_edge_start.x) / (left_edge_end.y - left_edge_start.y); Self { k, b: left_edge_end.x - k * left_edge_end.y, } } f...
code_fim
hard
{ "lang": "rust", "repo": "equation314/simple-polygon", "path": "/core/src/tri/mono_partition.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // triangulate a monotone polygon using a stack. let pts = &self.poly.points; let mut stack = vec![sorted_chains[0], sorted_chains[1]]; for &(idx, side) in &sorted_chains[2..] { let &(top_idx, top_side) = stack.last().unwrap(); let mut sp = stack.len...
code_fim
hard
{ "lang": "rust", "repo": "equation314/simple-polygon", "path": "/core/src/tri/mono_partition.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } impl R { #[doc = "Bits 0:7 - Number of Errors"] #[inline(always)] pub fn nb_errors(&self) -> NB_ERRORS_R { NB_ERRORS_R::new((self.bits & 0xff) as u8) } } #[doc = "Number of Errors Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [AP...
code_fim
hard
{ "lang": "rust", "repo": "ehaskins/sam3x8e", "path": "/src/usart3/ner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehaskins/sam3x8e path: /src/usart3/ner.rs #[doc = "Register `NER` reader"] pub struct R(crate::R<NER_SPEC>); impl core::ops::Deref for R { type Target = crate::R<NER_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { <|fim_suffix|> &self.0 } } impl R { #[doc =...
code_fim
hard
{ "lang": "rust", "repo": "ehaskins/sam3x8e", "path": "/src/usart3/ner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn case() { assert_eq!(Solution::two_sum(vec![2, 7, 11, 15], 9), vec![0, 1]); assert_eq!(Solution2::two_sum(vec![2, 7, 11, 15], 9), vec![0, 1]); } }<|fim_prefix|>// repo: bugcai/-algorithm015 path: /Week_01/src/two_sum.rs use std::collections::HashMap; struct Solution...
code_fim
medium
{ "lang": "rust", "repo": "bugcai/-algorithm015", "path": "/Week_01/src/two_sum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bugcai/-algorithm015 path: /Week_01/src/two_sum.rs use std::collections::HashMap; struct Solution; // 一遍哈希表 impl Solution { pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { let mut map = HashMap::new(); for (i, n) in nums.iter().enumerate() { if let Som...
code_fim
medium
{ "lang": "rust", "repo": "bugcai/-algorithm015", "path": "/Week_01/src/two_sum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kazagistar/advent2017 path: /src/day2.rs fn mapsum_lines(input: &str, map: impl Fn(&[i32]) -> i32) -> i32 { input .lines() .map(|line| { map(&line.split_whitespace() .map(|word| word.parse().unwrap()) .collect::<Vec<_>>()) }...
code_fim
hard
{ "lang": "rust", "repo": "kazagistar/advent2017", "path": "/src/day2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sheet1 = "5 1 9 5 7 5 3 2 4 6 8"; assert_eq!(18, part1(sheet1)); let sheet2 = "5 9 2 8 9 4 7 3 3 8 6 5"; assert_eq!(9, part2(sheet2)); }<|fim_prefix|>// repo: kazagistar/advent2017 path: /src/day2.rs fn mapsum_li...
code_fim
hard
{ "lang": "rust", "repo": "kazagistar/advent2017", "path": "/src/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = Vec::new(); while let Some(x) = iter.next() { for y in iter.clone() { result.push((x, y)); } } result } pub fn part2(input: &str) -> i32 { mapsum_lines(input, |v| { combinations(v.iter().cloned()) .iter() .ma...
code_fim
hard
{ "lang": "rust", "repo": "kazagistar/advent2017", "path": "/src/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trevorsm7/advent_of_code_2017 path: /src/day8.rs use std::fs; use std::env; use std::io; use std::ops::{Add, Sub}; use std::cmp::max; use std::collections::HashMap; fn dewit(input: &str) -> (i32, i32) { let mut regs = HashMap::new(); let mut max_value = 0; // Parse the input line-b...
code_fim
hard
{ "lang": "rust", "repo": "trevorsm7/advent_of_code_2017", "path": "/src/day8.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Return the current largest value and the largest value seen (*regs.values().max().unwrap(), max_value) } #[test] fn test_day8() { let input = "b inc 5 if a > 1 a inc 1 if b < 5 c dec -10 if a >= 1 c inc -20 if c == 10"; assert_eq!(dewit(&input), (1, 10)); } pub fn day8(args: &mut env:...
code_fim
hard
{ "lang": "rust", "repo": "trevorsm7/advent_of_code_2017", "path": "/src/day8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Evaluate the instruction if cond(&left, &right) { // Update the register value let mut value = *regs.get(name).unwrap_or(&0); value = op(value, amount); regs.insert(name, value); // Record the max value seen max_va...
code_fim
hard
{ "lang": "rust", "repo": "trevorsm7/advent_of_code_2017", "path": "/src/day8.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Feature `os-util` enabled, or one of the features that need `os-util`. #[cfg(unix)] macro_rules! cfg_any_os_util { ($($item:item)*) => { $( #[cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "uds"))] #[cfg_attr(docsrs, doc(cfg(any(feature = "...
code_fim
hard
{ "lang": "rust", "repo": "peterjoel/mio", "path": "/src/macros/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterjoel/mio path: /src/macros/mod.rs //! Macros to ease conditional code based on enabled features. // Depending on the features not all macros are used. #![allow(unused_macros)] /// Feature `os-poll` enabled. macro_rules! cfg_os_poll { ($($item:item)*) => { $( #[cfg(...
code_fim
hard
{ "lang": "rust", "repo": "peterjoel/mio", "path": "/src/macros/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init() { unsafe { // enable timer interrupt sie::set_stimer(); } clock_set_next_event(); println!("++++ setup timer! ++++"); } pub fn clock_set_next_event() { set_timer(get_cycle() + TICK_INTERVAL); } fn get_cycle() -> u64 { time::read() as u64 } /// G...
code_fim
medium
{ "lang": "rust", "repo": "chyyuu/rCore_tutorial", "path": "/os/src/timer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chyyuu/rCore_tutorial path: /os/src/timer.rs use crate::sbi::set_timer; use core::time::Duration; use riscv::register::{sie, time}; const TICK_INTERVAL: u64 = 100000; <|fim_suffix|>fn get_cycle() -> u64 { time::read() as u64 } /// Get current time (duration from start). pub fn now() -> Du...
code_fim
hard
{ "lang": "rust", "repo": "chyyuu/rCore_tutorial", "path": "/os/src/timer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Get current time (duration from start). pub fn now() -> Duration { Duration::from_micros(get_cycle() / 10) }<|fim_prefix|>// repo: chyyuu/rCore_tutorial path: /os/src/timer.rs use crate::sbi::set_timer; use core::time::Duration; use riscv::register::{sie, time}; const TICK_INTERVAL: u64 = 100000...
code_fim
hard
{ "lang": "rust", "repo": "chyyuu/rCore_tutorial", "path": "/os/src/timer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl stderror::Error for Error { fn source(&self) -> Option<&(dyn stderror::Error + 'static)> { match self { Error::Backend(e) => Some(e.as_ref()), Error::Executor(e) => Some(e.as_ref()), Error::IsGenesis | Error::ParentNotFound => None, } } }<|fim_prefix|>// repo: Atul9/blockchain path: /...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/blockchain", "path": "/src/chain/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Error::Backend(_) => "Backend failure".fmt(f)?, Error::Executor(_) => "Executor failure".fmt(f)?, Error::IsGenesis => "Block is genesis block and cannot be imported".fmt(f)?, Error::ParentNotFound => "Parent block cannot be found".fmt(f)?, } Ok(()) } } impl stderror::Erro...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/blockchain", "path": "/src/chain/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/blockchain path: /src/chain/mod.rs //! Chain importer and block builder. mod importer; mod block_builder; pub use self::importer::{SharedBackend, Importer}; pub use self::block_builder::BlockBuilder; <|fim_suffix|> match self { Error::Backend(_) => "Backend failure".fmt(f)?, Erro...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/blockchain", "path": "/src/chain/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: storyfeet/gob_sh path: /src/main.rs mod args; mod channel; mod cursor; mod data; mod exec; mod expr; mod guess_manager; mod highlight; mod parser; mod partial; mod prompt; mod shell; mod statement; mod store; mod str_util; mod tab_complete; mod ui; use bogobble::traits::*; use clap::*; use err_...
code_fim
hard
{ "lang": "rust", "repo": "storyfeet/gob_sh", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match termion::is_tty(&stdin()) { true => run_interactive(), false => run_stream_out(&mut stdin(), &mut Store::new()).map(|_| ()), } } pub fn run_interactive() -> anyhow::Result<()> { ctrlc::set_handler(move || println!("Kill Signal")).ok(); let mut shell = Shell::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "storyfeet/gob_sh", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/9484 - Maximum Triangle, Minimum Triangle.rs use io::Write; use std::{io, str}; pub struct UnsafeScanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitAsciiWhitespace<'static>, } impl<R: io::BufRead> UnsafeScanner<R> { pub fn new(reader: R) -...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/9484 - Maximum Triangle, Minimum Triangle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n { for j in i + 1..n { lines.push(Line::new(i, j, points[i], points[j])); } } lines.sort_by(|p, q| { let left = p.dy * q.dx; let right = q.dy * p.dx; if left > right { std::cm...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/9484 - Maximum Triangle, Minimum Triangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (addr, rx) = Addr::new(); let read = self.read.take().unwrap(); tokio::spawn(self.run(rx)); tokio::spawn(Self::read(addr.clone(), read)); addr.upcast() } }<|fim_prefix|>// repo: semio-ai/drydoc path: /crates/drydoc-gen/src/generator/ipc.rs use crate::actor::{Actor, Addr, Receive...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/generator/ipc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: semio-ai/drydoc path: /crates/drydoc-gen/src/generator/ipc.rs use crate::actor::{Actor, Addr, Receiver}; use bytes::{Bytes, BytesMut}; use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt}; use super::GeneratorMsg; use drydoc_ipc::MessageProcessor; enum IpcGeneratorMsg { Genera...
code_fim
hard
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/generator/ipc.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>enum IpcGeneratorMsg { GeneratorMsg(GeneratorMsg), } impl From<GeneratorMsg> for IpcGeneratorMsg { fn from(value: GeneratorMsg) -> Self { Self::GeneratorMsg(value) } } pub struct IpcGenerator<R, W> where R: 'static + AsyncRead + Send, W: 'static + AsyncWrite + Send { write: W, read: O...
code_fim
medium
{ "lang": "rust", "repo": "semio-ai/drydoc", "path": "/crates/drydoc-gen/src/generator/ipc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greenMT/daly path: /src/tracerunner.rs use boolinator::Boolinator; use kaktus::PushPop; use super::{TraceInstruction, Comp, Value, Interpreter, CallFrame, Trace}; use recovery::Guard; use traits::vec::ConvertingStack; use repr::InstrPtr; pub struct Runner<'a, 'b: 'a> { pub trace: &'a [Tra...
code_fim
hard
{ "lang": "rust", "repo": "greenMT/daly", "path": "/src/tracerunner.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (a, b) = self.stack.pop_2_into::<usize>(); self.stack.push_from(a + b) } fn cmp(&mut self, how: Comp) { let (left, right) = self.stack.pop_2_into::<usize>(); let b = match how { Comp::Lt => left < right, Comp::Le => left <= right, ...
code_fim
hard
{ "lang": "rust", "repo": "greenMT/daly", "path": "/src/tracerunner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // since callframes depend on each other, we start with the one which // was created first (least-recent frame) `.rev()` ensures that for frame_info in frames.iter().rev() { // 1. create a new callframe to push let mut frame = CallFrame::for_fn( ...
code_fim
hard
{ "lang": "rust", "repo": "greenMT/daly", "path": "/src/tracerunner.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Write the challenge bytes to a target fn write_challenge_bytes(&self, writer: &mut dyn WriteBuffer) -> Result<(), Error>; }<|fim_prefix|>// repo: simnic/aries-askar path: /askar-bbs/src/challenge.rs use askar_crypto::buffer::WriteBuffer; use crate::{hash::HashScalar, util::Nonce, Error}; im...
code_fim
hard
{ "lang": "rust", "repo": "simnic/aries-askar", "path": "/askar-bbs/src/challenge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simnic/aries-askar path: /askar-bbs/src/challenge.rs use askar_crypto::buffer::WriteBuffer; use crate::{hash::HashScalar, util::Nonce, Error}; impl_scalar_type!(ProofChallenge, "Fiat-Shamir proof challenge value"); impl ProofChallenge { /// Create a new proof challenge value from a set of...
code_fim
hard
{ "lang": "rust", "repo": "simnic/aries-askar", "path": "/askar-bbs/src/challenge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_css_minifier/src/util.rs use std::mem::take; use swc_common::EqIgnoreSpan; pub(crate) fn dedup<T>(v: &mut Vec<T>) where T: EqIgnoreSpan, { let mut remove_list = vec![]; <|fim_suffix|> // Fast path. We don't face real duplicates in most cases. i...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_css_minifier/src/util.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // Fast path. We don't face real duplicates in most cases. if remove_list.is_empty() { return; } let new = take(v) .into_iter() .enumerate() .filter_map(|(idx, value)| { if remove_list.contains(&idx) { None } else { ...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_css_minifier/src/util.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/perf/src/lib.rs extern crate sys; #[macro_use] extern crate parsing; extern crate elf; <|fim_suffix|>pub use cycles::CPUCycleTracker; pub use profile::profile_self;<|fim_middle|>mod busy; mod cycles; mod memory; mod profile;
code_fim
easy
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/perf/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use cycles::CPUCycleTracker; pub use profile::profile_self;<|fim_prefix|>// repo: dennisss/dacha path: /pkg/perf/src/lib.rs extern crate sys; #[macro_use] extern crate parsing; extern crate elf; <|fim_middle|>mod busy; mod cycles; mod memory; mod profile;
code_fim
easy
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/perf/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanmckay/ib-rs path: /src/models/scannerresult_contracts_contract.rs /* * Client Portal Web API * * Client Poral Web API * * OpenAPI spec version: 1.0.0 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ #[allow(unused_imports)] use serde_json::Value; #[derive...
code_fim
hard
{ "lang": "rust", "repo": "dylanmckay/ib-rs", "path": "/src/models/scannerresult_contracts_contract.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn distance(&self) -> Option<&i32> { self.distance.as_ref() } pub fn reset_distance(&mut self) { self.distance = None; } pub fn set_in_scan_time(&mut self, in_scan_time: String) { self.in_scan_time = Some(in_scan_time); } pub fn with_in_scan_time(mut self, in_scan_time: St...
code_fim
hard
{ "lang": "rust", "repo": "dylanmckay/ib-rs", "path": "/src/models/scannerresult_contracts_contract.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let selected_app_id = String::from("kafka"); siv.set_user_data(UiState { ui_events, selected_app_id, }); siv .load_toml(include_str!("../../assets/style.toml")) .unwrap(); let panel = LinearLayout::vertical() .child(apps_view(&ui.apps_config)) .chil...
code_fim
hard
{ "lang": "rust", "repo": "sheelc/soleil", "path": "/src/ui/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sheelc/soleil path: /src/ui/mod.rs use cursive::backends::curses::n::Backend; use cursive::view::{Nameable, SizeConstraint, View}; use cursive::views::{ LinearLayout, PaddedView, Panel, ResizedView, ScrollView, SelectView, TextArea, }; use cursive::{Cursive, CursiveRunner}; use std::sync::mps...
code_fim
hard
{ "lang": "rust", "repo": "sheelc/soleil", "path": "/src/ui/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tykel/retrogram path: /src/cli/scan.rs //! CLI command: scan use std::{io, fs, fmt}; use std::collections::HashSet; use num_traits::{Zero, One}; use crate::{project, platform, arch, ast, input, analysis, database, memory, cli, maths, reg}; /// Scan a specific starting PC and add the results of...
code_fim
hard
{ "lang": "rust", "repo": "tykel/retrogram", "path": "/src/cli/scan.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> failed_analysis.insert(target_pc); } } } } } if !more_analysis_done { break; } } eprintln!("Scan complete, writing database"); pjdb.write(prog.as_database_...
code_fim
hard
{ "lang": "rust", "repo": "tykel/retrogram", "path": "/src/cli/scan.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let start_pc = input::parse_ptr(start_spec, db, bus, architectural_ctxt_parse).expect("Must specify a valid address to analyze"); eprintln!("Starting scan from {:X}", start_pc); match scan_pc_for_arch(&mut db, &start_pc, &disassembler, bus) { Ok(_) => {}, Err(e) => { ...
code_fim
hard
{ "lang": "rust", "repo": "tykel/retrogram", "path": "/src/cli/scan.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caklimas/rust-nes path: /src/display.rs use sdl2::Sdl; use sdl2::pixels::Color; use sdl2::render::{Canvas, Texture, TextureCreator}; use sdl2::video::{Window, WindowContext}; pub const PIXEL_SIZE: usize = 3; pub const SCREEN_WIDTH: usize = 256; pub const SCREEN_HEIGHT: usize = 240; pub const BY...
code_fim
hard
{ "lang": "rust", "repo": "caklimas/rust-nes", "path": "/src/display.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut canvas = window.into_canvas().build().expect("Error building canvas"); let texture_creator = canvas.texture_creator(); canvas.set_draw_color(Color::RGB(0, 0, 0)); canvas.clear(); canvas.present(); (canvas, texture_creator) } pub fn draw_frame(texture: &mut Texture, canvas:...
code_fim
hard
{ "lang": "rust", "repo": "caklimas/rust-nes", "path": "/src/display.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krzkaczor/rusty-lisp path: /src/parser.rs extern crate regex; use regex::Regex; use std::option::Option; use std::iter::*; use ast::*; use std::rc::Rc; #[derive(Debug, PartialEq)] pub enum Token<'a> { Char(char), String(&'a str), SpecialChars(&'a str) } //@todo refactor. Regex shou...
code_fim
hard
{ "lang": "rust", "repo": "krzkaczor/rusty-lisp", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tokens } fn read_list<'a, 'b, I>(reader: &'a mut Peekable<I>) -> Option<Syntax> where I: Iterator<Item = &'b Token<'b>> { let mut list: Vec<Syntax> = Vec::new(); loop { let should_end: bool = Some(&&Token::Char(')')) == reader.peek() || Some(&&Token::Char(']')) == reader.peek(); ...
code_fim
hard
{ "lang": "rust", "repo": "krzkaczor/rusty-lisp", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PistonDevelopers/rust-sdl2 path: /src/sdl2/cpuinfo.rs use sys::cpuinfo as ll; pub const CACHELINESIZE: u8 = 128; pub fn get_cpu_count() -> i32 { unsafe { ll::SDL_GetCPUCount() } } pub fn get_cpu_cache_line_size() -> i32 { unsafe { ll::SDL_GetCPUCacheLineSize() } } pub fn has_rdtsc() ...
code_fim
medium
{ "lang": "rust", "repo": "PistonDevelopers/rust-sdl2", "path": "/src/sdl2/cpuinfo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn has_sse42() -> bool { unsafe { ll::SDL_HasSSE42() == 1 } } pub fn has_avx() -> bool { unsafe { ll::SDL_HasAVX() == 1 } } pub fn get_system_ram() -> i32 { unsafe { ll::SDL_GetSystemRAM() } }<|fim_prefix|>// repo: PistonDevelopers/rust-sdl2 path: /src/sdl2/cpuinfo.rs use sys::cpuinfo a...
code_fim
hard
{ "lang": "rust", "repo": "PistonDevelopers/rust-sdl2", "path": "/src/sdl2/cpuinfo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvanbem/decompiler path: /gamecube-disc/src/header_reader.rs /// The size in bytes of a GameCube disc header. pub const HEADER_SIZE: usize = 8; #[derive(Clone, Copy, Debug)] pub struct HeaderReader<'data> { data: &'data [u8], } impl<'data> HeaderReader<'data> { /// # Panics /// ...
code_fim
hard
{ "lang": "rust", "repo": "mvanbem/decompiler", "path": "/gamecube-disc/src/header_reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> const DATA: &'static [u8] = &[0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x01, 0x02]; let header = HeaderReader::new(DATA); assert_eq!(header.game_code(), "ABCD"); assert_eq!(header.maker_code(), "EF"); assert_eq!(header.disc_id(), 1); assert_eq!(header.version(), ...
code_fim
hard
{ "lang": "rust", "repo": "mvanbem/decompiler", "path": "/gamecube-disc/src/header_reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[must_use] pub fn try_alloc_pixels_flags(&mut self, image_info: &ImageInfo, flags: BitmapAllocFlags) -> bool { unsafe { self.native_mut().tryAllocPixelsFlags(image_info.native(), flags.bits()) } } pub fn alloc_pixels_flags(&mut self, image_info: &ImageInfo, flags: BitmapAllo...
code_fim
hard
{ "lang": "rust", "repo": "bugsbunny1101/rust-skia", "path": "/skia-safe/src/core/bitmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub unsafe fn get_addr(&self, p: IPoint) -> *const ffi::c_void { self.native().getAddr(p.x, p.y) } pub fn extract_subset<IR: AsRef<IRect>>(&self, dst: &mut Self, subset: IR) -> bool { unsafe { self.native().extractSubset(dst.native_mut(), subset.as_ref().na...
code_fim
hard
{ "lang": "rust", "repo": "bugsbunny1101/rust-skia", "path": "/skia-safe/src/core/bitmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bugsbunny1101/rust-skia path: /skia-safe/src/core/bitmap.rs use crate::prelude::*; use std::{ffi, mem, ptr}; use crate::core::{ Paint, Color, ColorType, AlphaType, ColorSpace, IRect, ImageInfo, ISize, IPoint, }; use skia_bindings::{ SkPaint, ...
code_fim
hard
{ "lang": "rust", "repo": "bugsbunny1101/rust-skia", "path": "/skia-safe/src/core/bitmap.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unreachable!() } fn main() { println!("{}", puzzle_a(INPUT)); println!("{}", puzzle_b(INPUT)); } benchtest! { puzzle_a_test: puzzle_a(INPUT) => 3654868, puzzle_b_test: puzzle_b(INPUT) => 7014 }<|fim_prefix|>// repo: scullionw/aoc2019 path: /src/bin/day2.rs #![feature(test)] use aoc...
code_fim
hard
{ "lang": "rust", "repo": "scullionw/aoc2019", "path": "/src/bin/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scullionw/aoc2019 path: /src/bin/day2.rs #![feature(test)] use aoc2019::machine::{Cell, IntCodeMachine}; use benchtest::benchtest; const INPUT: &str = include_str!("data/day2.txt"); <|fim_suffix|> IntCodeMachine::default().run(&mut intcodes) } fn puzzle_b(input: &str) -> i64 { let int...
code_fim
medium
{ "lang": "rust", "repo": "scullionw/aoc2019", "path": "/src/bin/day2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", puzzle_a(INPUT)); println!("{}", puzzle_b(INPUT)); } benchtest! { puzzle_a_test: puzzle_a(INPUT) => 3654868, puzzle_b_test: puzzle_b(INPUT) => 7014 }<|fim_prefix|>// repo: scullionw/aoc2019 path: /src/bin/day2.rs #![feature(test)] use aoc2019::machine::{Cell, IntCodeMachi...
code_fim
hard
{ "lang": "rust", "repo": "scullionw/aoc2019", "path": "/src/bin/day2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dobrakmato/renderer path: /bf/src/material.rs //! Materials, their properties and blend mode. use serde::{Deserialize, Serialize}; use uuid::Uuid; /// Represents a mode in which the material is blended with content /// that is already rendered. #[derive(Hash, Eq, PartialEq, Copy, Clone, Debug,...
code_fim
hard
{ "lang": "rust", "repo": "dobrakmato/renderer", "path": "/bf/src/material.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { blend_mode: BlendMode::Opaque, albedo_color: [86.0 / 255.0, 93.0 / 255.0, 110.0 / 255.0], roughness: 0.5, metallic: 0.0, alpha_cutoff: 0.0, opacity: 1.0, ior: 1.0, albedo_map: None, n...
code_fim
hard
{ "lang": "rust", "repo": "dobrakmato/renderer", "path": "/bf/src/material.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: konkers/pollendina path: /src/engine/expression.rs use std::collections::HashMap; use failure::{format_err, Error}; use nom::{ branch::alt, bytes::complete::{tag, take_while, take_while_m_n}, combinator::{map, opt, recognize}, multi::many0, sequence::{pair, preceded}, IR...
code_fim
hard
{ "lang": "rust", "repo": "konkers/pollendina", "path": "/src/engine/expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> test_expression("a", Expression::Objective("a".into())); test_expression("aa", Expression::Objective("aa".into())); test_expression("a0", Expression::Objective("a0".into())); test_expression("a0-b1-2", Expression::Objective("a0-b1-2".into())); test_expression("a0-b1...
code_fim
hard
{ "lang": "rust", "repo": "konkers/pollendina", "path": "/src/engine/expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VladADragos/yew-testing path: /src/components/cellular_automata/cellular_automata.rs use super::rules::Rule; use super::visual_buffer::VisualBuffer; #[derive(Clone)] pub enum CellStates{ dead = 0, alive = 1 } impl CellStates{ pub fn from_int(int:u8)->CellStates{ match int{ ...
code_fim
medium
{ "lang": "rust", "repo": "VladADragos/yew-testing", "path": "/src/components/cellular_automata/cellular_automata.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl CellularAutomata{ pub fn next_state(&mut self){ for x in 0..self.line_buffer.len(){ let current = & self.line_buffer[x]; let left = & self.line_buffer[(x+(self.width-1 ) as usize)%self.width as usize]; let right = & self.line_buffer[(x+1)%self.width as ...
code_fim
hard
{ "lang": "rust", "repo": "VladADragos/yew-testing", "path": "/src/components/cellular_automata/cellular_automata.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn notifySet(&mut self,from:usize,to:usize,new_state: CellStates){ self.observer.onSet(from,to,new_state); } fn notifySpawn(&mut self,spawn_location:usize){ self.observer.onSpawn(spawn_location); } }<|fim_prefix|>// repo: VladADragos/yew-testing path: /src/components/cell...
code_fim
hard
{ "lang": "rust", "repo": "VladADragos/yew-testing", "path": "/src/components/cellular_automata/cellular_automata.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_money_addassign() { // Given let mut m = Money(10); let n = Money(5); // When m += n; // Expect assert_eq!(m, Money(15)); } #[test] fn test_is_cmp() { // Given let m = Money(10); let n = Mo...
code_fim
hard
{ "lang": "rust", "repo": "leonardoarcari/rust-hexagonal-architecture", "path": "/src/domain/money.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Given let mut m = Money(10); let n = Money(5); // When m += n; // Expect assert_eq!(m, Money(15)); } #[test] fn test_is_cmp() { // Given let m = Money(10); let n = Money(5); // Expect assert!(m...
code_fim
medium
{ "lang": "rust", "repo": "leonardoarcari/rust-hexagonal-architecture", "path": "/src/domain/money.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leonardoarcari/rust-hexagonal-architecture path: /src/domain/money.rs use derive_more::{Add, AddAssign, Neg, Sub, SubAssign}; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Add, AddAssign, Neg, Sub, SubAssign, )] pub struct Money(pub i64); <|fim_suffix|> #[test] fn t...
code_fim
hard
{ "lang": "rust", "repo": "leonardoarcari/rust-hexagonal-architecture", "path": "/src/domain/money.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! multi_conflict { () => {} } #[allow(non_camel_case_types)] pub struct multi_conflict {} pub fn multi_conflict() {} pub mod type_and_value {} pub const type_and_value: i32 = 0; pub mod foo { pub enum bar {} pub fn bar() {} } /// [`ambiguous`] is ambiguous. //~ERR...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/rustdoc-ui/intra-links-ambiguity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/rustdoc-ui/intra-links-ambiguity.rs #![deny(intra_doc_link_resolution_failure)] #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] <|fim_suffix|>pub fn multi_conflict() {} pub mod type_and_value {} pub const type_and_value: i32 = ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/rustdoc-ui/intra-links-ambiguity.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn bar() {} } /// [`ambiguous`] is ambiguous. //~ERROR `ambiguous` /// /// [ambiguous] is ambiguous. //~ERROR ambiguous /// /// [`multi_conflict`] is a three-way conflict. //~ERROR `multi_conflict` /// /// Ambiguous [type_and_value]. //~ERROR type_and_value /// /// Ambiguous non-implied shortcut ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/rustdoc-ui/intra-links-ambiguity.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pikajude/jude-rs path: /src/highlighting.rs use std::borrow::Cow; use syntect::parsing::{SyntaxSet,ParseState}; use syntect::html::{ClassStyle,tokens_to_classed_html}; use pulldown_cmark::html::push_html; use pulldown_cmark::*; pub fn highlighted_markdown(text: String) -> String { let mut i...
code_fim
hard
{ "lang": "rust", "repo": "pikajude/jude-rs", "path": "/src/highlighting.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> </td> </tr> </table> </figure>"#, line_numbers, html_str)))) }, Event::Text(_) => { if in_block { if let Event::Text(mut text...
code_fim
hard
{ "lang": "rust", "repo": "pikajude/jude-rs", "path": "/src/highlighting.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmrath/pure_decimal path: /src/error.rs use std::fmt; /// Error returned by this create #[derive(Debug)] pub struct Error { details: String, } <|fim_suffix|>impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.details) } ...
code_fim
medium
{ "lang": "rust", "repo": "mmrath/pure_decimal", "path": "/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ::std::error::Error for Error { fn description(&self) -> &str { &self.details } }<|fim_prefix|>// repo: mmrath/pure_decimal path: /src/error.rs use std::fmt; /// Error returned by this create #[derive(Debug)] pub struct Error { details: String, } <|fim_middle|>impl Error { ...
code_fim
hard
{ "lang": "rust", "repo": "mmrath/pure_decimal", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nascheinkman/chord2key path: /src/mapping/maps/mouse_map.rs use crate::constants::*; use crate::events::*; use crate::input::events::*; use crate::mapping::actions::*; use crate::mapping::thresholds::*; use crate::output::actions::*; use serde::{Deserialize, Serialize}; use std::collections::Has...
code_fim
hard
{ "lang": "rust", "repo": "nascheinkman/chord2key", "path": "/src/mapping/maps/mouse_map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MouseProfile { pub fn map_state_to_action(&self, state: AxisState) -> Action { let mouse_state: AxisState = (self.slope * (state as f64) + self.offset) as AxisState; StateChange::new(None, Some(vec![(self.code, mouse_state)].into())).into() } pub fn zeroed(&self) -> Action...
code_fim
hard
{ "lang": "rust", "repo": "nascheinkman/chord2key", "path": "/src/mapping/maps/mouse_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Dev-Owl/rPlayGround path: /sieve_of_eratosthenes/src/main.rs use std::io; fn main() { println!("Input max number:"); let mut max_number = String::new(); io::stdin().read_line(&mut max_number) .ok() .expect("failed to read line"); <|fim_suffix|> let mut lis...
code_fim
medium
{ "lang": "rust", "repo": "Dev-Owl/rPlayGround", "path": "/sieve_of_eratosthenes/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 2..10 { list.retain( |&n| n%i !=0 || n==i); } println!("Prime numbers:"); let mut index = 0; for i in list.iter() { if index % 10 == 0{ println!(""); index = 0; } print!("{} ",*i); index+=1; } println!(""); }<|fim_prefix|>// repo: Dev-Owl/rPlayGround path: /sieve_of_...
code_fim
medium
{ "lang": "rust", "repo": "Dev-Owl/rPlayGround", "path": "/sieve_of_eratosthenes/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Convert to .png eprintln!("\rConverting to .png"); let img = ImageReader::open(&ppm_path)?.decode()?; let png_path = ppm_path.replace(".ppm", ".png"); img.save_with_format(png_path, image::ImageFormat::Png)?; eprintln!("\rDone."); Ok(()) }<|fim_prefix|>// repo: rcmehta/r...
code_fim
hard
{ "lang": "rust", "repo": "rcmehta/raytracer", "path": "/src/bin/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcmehta/raytracer path: /src/bin/main.rs extern crate image; extern crate rand; extern crate rayon; use image::io::Reader as ImageReader; use rayon::prelude::*; use std::{error::Error, fs, io::Write}; <|fim_suffix|>fn main() -> Result<(), Box<dyn Error>> { // Camera, World let (camera...
code_fim
medium
{ "lang": "rust", "repo": "rcmehta/raytracer", "path": "/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: M-J-Hooper/cymbal path: /src/expr.rs use crate::literal::*; #[derive(PartialEq, Clone, Debug)] pub enum Expr { Var(char), Lit(Num), Pow(Power), Group(Group), } pub struct Statement { pub kind: StatementKind, pub left: Box<Expr>, pub right: Box<Expr>, } pub enum Sta...
code_fim
hard
{ "lang": "rust", "repo": "M-J-Hooper/cymbal", "path": "/src/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Expr::Var(c) } } impl From<Group> for Expr { fn from(g: Group) -> Self { Expr::Group(g) } } impl From<Power> for Expr { fn from(p: Power) -> Self { Expr::Pow(p) } }<|fim_prefix|>// repo: M-J-Hooper/cymbal path: /src/expr.rs use crate::literal::*; #[derive(Pa...
code_fim
hard
{ "lang": "rust", "repo": "M-J-Hooper/cymbal", "path": "/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<Group> for Expr { fn from(g: Group) -> Self { Expr::Group(g) } } impl From<Power> for Expr { fn from(p: Power) -> Self { Expr::Pow(p) } }<|fim_prefix|>// repo: M-J-Hooper/cymbal path: /src/expr.rs use crate::literal::*; #[derive(PartialEq, Clone, Debug)] pub en...
code_fim
hard
{ "lang": "rust", "repo": "M-J-Hooper/cymbal", "path": "/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gunjunlee/ps path: /baekjoon/src/bin/1920.rs macro_rules! parse_line { ($($t: ty),+) => ({ let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$t>().unwrap()),+) })} macro_rules! pa...
code_fim
hard
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/1920.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let _n = parse_line!(usize); let mut nums = parse_list!(i32); nums.sort(); let _m = parse_line!(usize); let queries = parse_list!(i32); let stdout = std::io::stdout(); let mut out = std::io::BufWriter::new(stdout.lock()); for q in queries.iter() { matc...
code_fim
hard
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/1920.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _n = parse_line!(usize); let mut nums = parse_list!(i32); nums.sort(); let _m = parse_line!(usize); let queries = parse_list!(i32); let stdout = std::io::stdout(); let mut out = std::io::BufWriter::new(stdout.lock()); for q in queries.iter() { match nums.binar...
code_fim
medium
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/1920.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Our data mostly consists of float32s hopefully, but in case we have other ones //just read the data as a double for simplicity. This works with all other data types //except the complex ones. let (width, height) = dataset.size(); let data: Vec<f64> = dataset .read_full_raster...
code_fim
hard
{ "lang": "rust", "repo": "LAPS-Group/laps", "path": "/laps_convert/src/lib.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LAPS-Group/laps path: /laps_convert/src/lib.rs //laps_convert/lib.rs: Entry point for the laps_convert library. //Author: Håkon Jordet //Copyright (c) 2020 LAPS Group //Distributed under the zlib licence, see LICENCE. #![warn(missing_debug_implementations)] #![warn(missing_docs)] //!Library fo...
code_fim
hard
{ "lang": "rust", "repo": "LAPS-Group/laps", "path": "/laps_convert/src/lib.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> //pre-allocate buffer for grayscale data for output image. let mut out_data = vec![0u8; data.len()]; //Normalize the data let one_part = (max - min) / u8::MAX as f64; debug!("One part is: {}, max_min: {}", one_part, max - min); for (index, point) in data.into_iter().enumerate() { ...
code_fim
hard
{ "lang": "rust", "repo": "LAPS-Group/laps", "path": "/laps_convert/src/lib.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/tools/runk/libcontainer/src/lib.rs // Copyright 2021-2022 Sony Group Corporation // // SPDX-<|fim_suffix|>lder; pub mod init_builder; pub mod status; pub mod utils;<|fim_middle|>License-Identifier: Apache-2.0 // pub mod activated_builder; pub mod cgrou...
code_fim
medium
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/tools/runk/libcontainer/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }