text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> #[cfg(test)] mod tests { //const PUBKEY:&[u8] = hex!("038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508"); use crate::utils::h2b; lazy_static! { static ref HASH:Box<[u8]> = h2b("1018853670f9f3b0582c5b9ee8ce93764ac32b93").unwrap(); static ref PK_SCRIPT:Box<[u8]> =...
code_fim
hard
{ "lang": "rust", "repo": "dai1975/fiatproof", "path": "/src/bitcoin/p2pkh/compiler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dai1975/fiatproof path: /src/bitcoin/p2pkh/compiler.rs use crate::bitcoin::script::error; use crate::bitcoin::script::opcode::*; use super::P2PKH; pub struct Compiler(); impl Compiler { pub fn compile_to(p2pkh: &P2PKH, pk_script: &mut [u8; 25]) { pk_script[0] = OP_DUP; pk_script...
code_fim
hard
{ "lang": "rust", "repo": "dai1975/fiatproof", "path": "/src/bitcoin/p2pkh/compiler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { //const PUBKEY:&[u8] = hex!("038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508"); use crate::utils::h2b; lazy_static! { static ref HASH:Box<[u8]> = h2b("1018853670f9f3b0582c5b9ee8ce93764ac32b93").unwrap(); static ref PK_SCRIPT:Box<[u8]> = ...
code_fim
hard
{ "lang": "rust", "repo": "dai1975/fiatproof", "path": "/src/bitcoin/p2pkh/compiler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: malkia/rust-open-hardware-monitor-sys path: /build.rs use std::{env, path::PathBuf}; fn main() { let target = env::var("TARGET").unwrap(); let out_dir = env::var("OUT_DIR").unwrap(); // build OpenHardwareMonitorLib.dll so that we can do // #using <OpenHardwareMonitorLib.dll> let mut ...
code_fim
hard
{ "lang": "rust", "repo": "malkia/rust-open-hardware-monitor-sys", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("cargo:rerun-if-changed=src/interface.hpp"); // The bindgen::Builder is the main entry point // to bindgen, and lets you build up options for // the resulting bindings. let bindings = bindgen::Builder::default() .disable_name_namespacing() .default_enum_style(bindgen::EnumVaria...
code_fim
medium
{ "lang": "rust", "repo": "malkia/rust-open-hardware-monitor-sys", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/rs-breakout path: /src/components/mod.rs pub mod com_transform2d; pub mod com_draw2d; pub mod com_move; pub mod com_controll_ball; pub mod com_collide; pub mod com_control_block; pub mod com_control_paddle; pub mod com_shake; pub mod com_fade; <|fim_suffix|>pub enum Has { Transfor...
code_fim
medium
{ "lang": "rust", "repo": "risooonho/rs-breakout", "path": "/src/components/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub enum Has { Transform2d = 1 << Component::Transform2d as u32, Draw2d = 1 << Component::Draw2d as u32, Move = 1 << Component::Move as u32, ControlBall = 1 << Component::ControlBall as u32, Collide = 1 << Component::Collide as u32, ControlBlock = 1 << Component::ControlBlock as u3...
code_fim
medium
{ "lang": "rust", "repo": "risooonho/rs-breakout", "path": "/src/components/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> json::Serializer::new(writer) } fn into_inner(self) -> W { self.into_inner() } } impl<R: Read> ReadAdapter<R> for json::Deserializer<io::Bytes<R>> { fn wrap(reader: R) -> Self { json::Deserializer::new(reader.bytes()) } ...
code_fim
hard
{ "lang": "rust", "repo": "withoutboats/io-adapter", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: withoutboats/io-adapter path: /src/lib.rs use std::io::{Read, Write, IntoInnerError}; /// Any type which can be adapted over a Read type. pub trait ReadAdapter<R: Read> { /// Wrap a Read type in this adapter. fn wrap(reader: R) -> Self; /// Unwrap this type to get its inner Read. I...
code_fim
hard
{ "lang": "rust", "repo": "withoutboats/io-adapter", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Array<T: JoinSemiLattice, const N: usize>(pub [T; N]); impl<T: JoinSemiLattice, const N: usize> Deref for Array<T, N> { type Target = [T; N]; fn deref(&self) -> &Self::Target { &self.0 } } impl<T: JoinSemiLattice, const N: usiz...
code_fim
hard
{ "lang": "rust", "repo": "Xazax-hun/domains-oxide", "path": "/analysis/src/domains/transformers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xazax-hun/domains-oxide path: /analysis/src/domains/transformers.rs iden<T>(pub T); impl<T> AsRef<T> for UnrollWiden<T> { fn as_ref(&self) -> &T { &self.0 } } impl<T> Deref for UnrollWiden<T> { type Target = T; fn deref(&self) -> &Self::Target { &self.0 } }...
code_fim
hard
{ "lang": "rust", "repo": "Xazax-hun/domains-oxide", "path": "/analysis/src/domains/transformers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xazax-hun/domains-oxide path: /analysis/src/domains/transformers.rs ) .map_or_else(|| inner.clone(), |prev| inner.widen(prev, ctx, iteration)) }) } } impl<T: Lattice> Lattice for Option<T> { fn top(ctx: &Self::LatticeContext) -> Self { Some(T::top(ctx)) ...
code_fim
hard
{ "lang": "rust", "repo": "Xazax-hun/domains-oxide", "path": "/analysis/src/domains/transformers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajunlonglive/ntex-amqp path: /src/dispatcher.rs use std::{cell, fmt, future::Future, marker, pin::Pin, task::Context, task::Poll}; use ntex::framed::DispatchItem; use ntex::service::Service; use ntex::time::{sleep, Millis, Sleep}; use ntex::util::{Either, Ready}; use crate::codec::protocol::Fr...
code_fim
hard
{ "lang": "rust", "repo": "ajunlonglive/ntex-amqp", "path": "/src/dispatcher.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // check readiness let res1 = self.service.poll_ready(cx).map_err(|err| { error!("Publish service readiness check failed: {:?}", err); let _ = self.sink.close_with_error(&err); DispatcherError::Service })?; let res2 = self.ctl_service.pol...
code_fim
hard
{ "lang": "rust", "repo": "ajunlonglive/ntex-amqp", "path": "/src/dispatcher.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn decrypt(key: &AesKey, rounds: usize, block: AesBlock) -> AesBlock { let expanded_key = key_schedule(key, rounds); let mut state = block; add_key(&mut state, expanded_key[rounds]); inv_shift_rows(&mut state); inv_sub_bytes(&mut state); for i in (1..rounds).rev() { ...
code_fim
medium
{ "lang": "rust", "repo": "n-ari/crypto_rs", "path": "/aes/src/decrypt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n-ari/crypto_rs path: /aes/src/decrypt.rs use crate::ops::{add_key, inv_mix_columns, inv_shift_rows, inv_sub_bytes, key_schedule}; use crate::{AesBlock, AesKey}; fn _debug_state(state: AesBlock) { <|fim_suffix|>pub(crate) fn decrypt(key: &AesKey, rounds: usize, block: AesBlock) -> AesBlock { ...
code_fim
medium
{ "lang": "rust", "repo": "n-ari/crypto_rs", "path": "/aes/src/decrypt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..4 { for j in 0..4 { print!("{:02x} ", state.data[4 * j + i]); } print!("\n"); } print!("\n"); } pub(crate) fn decrypt(key: &AesKey, rounds: usize, block: AesBlock) -> AesBlock { let expanded_key = key_schedule(key, rounds); let mut state...
code_fim
medium
{ "lang": "rust", "repo": "n-ari/crypto_rs", "path": "/aes/src/decrypt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/mspi0/padoveren.rs #[doc = "Reader of register PADOVEREN"] pub type R = crate::R<u32, super::PADOVEREN>; #[doc = "Writer for register PADOVEREN"] pub type W = crate::W<u32, super::PADOVEREN>; #[doc = "Register PADOVEREN `reset()`'s with value 0"] impl crate:...
code_fim
hard
{ "lang": "rust", "repo": "trembel/ambiq-apollo3p-pac", "path": "/src/mspi0/padoveren.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>x03ff); self.w } } impl R { #[doc = "Bits 0:9 - Output pad override enable. Bit mask for pad outputs. When set to 1, the values in the OVERRIDE field are driven on the pad (output enable is implicitly set in this mode). \\[7:0\\]=data \\[8\\]=clock \\[9\\]=DM"] #[inline(always)] pu...
code_fim
hard
{ "lang": "rust", "repo": "trembel/ambiq-apollo3p-pac", "path": "/src/mspi0/padoveren.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guoyahao/unique_id_generator path: /src/service/id_generator/id_generator_options.rs #[derive(Debug)] pub struct IdGeneratorOptions { /// 雪花计算方法,(1-漂移算法|2-传统算法),默认1 pub method: u8, /// 基础时间(ms单位),不能超过当前系统时间 pub base_time: i64, /// 机器码,与 WorkerIdBitLength 有关系 pub worker_id...
code_fim
hard
{ "lang": "rust", "repo": "guoyahao/unique_id_generator", "path": "/src/service/id_generator/id_generator_options.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>eq_number: u32, /// 最大漂移次数(含),默认2000,推荐范围 500-20000(与计算能力有关) pub top_over_cost_count: u32, } impl IdGeneratorOptions { pub fn new(worker_id: u32) -> IdGeneratorOptions { return IdGeneratorOptions { method: 1, worker_id, base_time: 1582136402000, ...
code_fim
hard
{ "lang": "rust", "repo": "guoyahao/unique_id_generator", "path": "/src/service/id_generator/id_generator_options.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn clear_overflow(&mut self) { self.overflow = false; } pub fn set_negative(&mut self) { self.negative = true; } pub fn clear_negative(&mut self) { self.negative = false; } }<|fim_prefix|>// repo: dogue/rustbucket path: /src/cpu/flags.rs #[derive(Debu...
code_fim
hard
{ "lang": "rust", "repo": "dogue/rustbucket", "path": "/src/cpu/flags.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dogue/rustbucket path: /src/cpu/flags.rs #[derive(Debug, Default)] pub struct Flags { pub carry: bool, pub zero: bool, pub interrupt_disable: bool, pub decimal: bool, pub bit0: bool, pub bit1: bool, pub overflow: bool, pub negative: bool, } impl Flags { pub f...
code_fim
hard
{ "lang": "rust", "repo": "dogue/rustbucket", "path": "/src/cpu/flags.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NamsooCho/TcpDump_2 path: /net/src/lib.rs use core::convert::TryInto; //use std::fmt::Debug::fmt; pub enum PacketInfoErr { SizeErrEther, ConvertErrEther, } #[allow(dead_code)] pub struct PacketInfo { pub caplen: u32, pub ip_ver: u32, pub protocol: u32, pub srcip: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "NamsooCho/TcpDump_2", "path": "/net/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ether = u16::from_be_bytes(ether); match ether { 0x0008 => self.ip_ver = 4, 0xdd86 => self.ip_ver = 6, _ => self.ip_ver = 0, } Ok(self) } pub fn print(&self) { print!("{} {}.{} > {}.{}, length {}", self.ip_ver, self...
code_fim
hard
{ "lang": "rust", "repo": "NamsooCho/TcpDump_2", "path": "/net/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn print(&self) { print!("{} {}.{} > {}.{}, length {}", self.ip_ver, self.srcip, self.sport, self.dstip, self.dport, self.caplen); } } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }<|fim_prefix|>// repo: NamsooCho/TcpDump_2 path: /net/s...
code_fim
hard
{ "lang": "rust", "repo": "NamsooCho/TcpDump_2", "path": "/net/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// acc += b * c fn mac3(acc: &mut [u8], b: &[u8], c: &[u8]) { let (x, y) = if b.len() < c.len() { (b, c) } else { (c, b) }; for (i, xi) in x.iter().enumerate() { mac_digit(&mut acc[i..], y, *xi); } } fn shl(n: &mut [u8], bits: u8) { let mut carry = 0u8; for byte in n { ...
code_fim
hard
{ "lang": "rust", "repo": "fmckeogh/littlebigint", "path": "/core/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fmckeogh/littlebigint path: /core/src/lib.rs #![no_std] #[cfg(test)] #[macro_use] extern crate std; use core::{ cmp::{self, PartialEq}, fmt, ops::{Add, AddAssign, Shl, ShlAssign, Sub, SubAssign}, }; #[derive(Debug)] pub struct BigUint<'a>(&'a mut [u8]); impl<'a, 'b> fmt::Display ...
code_fim
hard
{ "lang": "rust", "repo": "fmckeogh/littlebigint", "path": "/core/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( dsl, json! { { "nested": { "path": "path_test", "query":{ "query_string":{ "query": "test" }}, "score_mode": "avg", ...
code_fim
hard
{ "lang": "rust", "repo": "zombodb/zombodb", "path": "/src/query_dsl/nested.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zombodb/zombodb path: /src/query_dsl/nested.rs #[pgrx::pg_schema] pub mod pg_catalog { use pgrx::*; use serde::*; #[allow(non_camel_case_types)] #[derive(Clone, Copy, Debug, PostgresEnum, Serialize, Deserialize)] pub enum ScoreMode { avg, sum, min, ...
code_fim
hard
{ "lang": "rust", "repo": "zombodb/zombodb", "path": "/src/query_dsl/nested.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kstrohbeck/aoc-2020 path: /src/day_18.rs use crate::utils::u64_; use nom::{ branch::alt, bytes::complete::tag, character::complete::space0, combinator::{map, value}, multi::many0, IResult, }; pub fn star_1(data: String) { let exprs = parse(&data); let sum = exprs...
code_fim
hard
{ "lang": "rust", "repo": "kstrohbeck/aoc-2020", "path": "/src/day_18.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn bin_op_tail(input: &str) -> IResult<&str, (BinOp, Expr)> { let (input, _) = space0(input)?; let (input, op) = bin_op(input)?; let (input, _) = space0(input)?; let (input, ex) = simple_expr(input)?; Ok((input, (op, ex))) } #[cfg(test)] mod tests { use super::{expr, BinOp, Expr};...
code_fim
hard
{ "lang": "rust", "repo": "kstrohbeck/aoc-2020", "path": "/src/day_18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Error Handling/Error Handling/Propagating Errors Limitations/src/main.rs use std::error::Error; use std::fs::File; <|fim_suffix|>fn main() -> Result<(), Box<dyn Error>> { let f = File::open("hello.txt")?; Ok(()) }<|fim_middle|>// !!! ERROR: the...
code_fim
medium
{ "lang": "rust", "repo": "jetbrains-academy/rustlings-course", "path": "/Error Handling/Error Handling/Propagating Errors Limitations/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<(), Box<dyn Error>> { let f = File::open("hello.txt")?; Ok(()) }<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Error Handling/Error Handling/Propagating Errors Limitations/src/main.rs use std::error::Error; use std::fs::File; <|fim_middle|>// !!! ERROR: the...
code_fim
medium
{ "lang": "rust", "repo": "jetbrains-academy/rustlings-course", "path": "/Error Handling/Error Handling/Propagating Errors Limitations/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ousttrue/frame_factory path: /renderer/src/resource/buffer_array.rs use std::{collections::HashMap}; use com_ptr_util::ComCreate; use com_ptr_util::ComError; use crate::scene::AccessorBytes; use com_ptr::ComPtr; use winapi::{ ctypes::c_void, shared::dxgiformat, um::{d3d11...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/renderer/src/resource/buffer_array.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(buffer_array) } pub fn prepare(&self, d3d_context: &d3d11::ID3D11DeviceContext) { let buffers: Vec<*mut d3d11::ID3D11Buffer> = self.vertex_buffers.iter().map(|p| p.as_ptr()).collect(); unsafe { d3d_context.IASetVertexBuffers( ...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/renderer/src/resource/buffer_array.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/svgcard path: /src/text.rs use anyhow::Result; use regex::Regex; use serde::Deserialize; use std::collections::HashMap; use std::io::Write; use xml::writer::{EventWriter, XmlEvent}; #[derive(Deserialize, Debug)] pub struct TextElement { text: Text, fontset: String, fontsize:...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/svgcard", "path": "/src/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> writer: &mut EventWriter<W>, class: &str, x: usize, y: usize, fontsize: f64, align: &Option<Align>, ) -> Result<()> { let (x, y) = (format!("{}", x), format!("{}", y)); let fontsize = format!("{}", fontsize); let start: XmlEvent = XmlEvent::start_element("text") ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/svgcard", "path": "/src/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> PascalsTriangle(rows) } pub fn rows(&self) -> Vec<Vec<u32>> { self.0.clone() } }<|fim_prefix|>// repo: baurine/leetcode path: /exercism/rust/pascals-triangle/src/lib.rs pub struct PascalsTriangle(Vec<Vec<u32>>); impl PascalsTriangle { pub fn new(row_count: u32) -> Self {...
code_fim
hard
{ "lang": "rust", "repo": "baurine/leetcode", "path": "/exercism/rust/pascals-triangle/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baurine/leetcode path: /exercism/rust/pascals-triangle/src/lib.rs pub struct PascalsTriangle(Vec<Vec<u32>>); impl PascalsTriangle { pub fn new(row_count: u32) -> Self { let mut rows: Vec<Vec<u32>> = vec![]; <|fim_suffix|> PascalsTriangle(rows) } pub fn rows(&self) -...
code_fim
hard
{ "lang": "rust", "repo": "baurine/leetcode", "path": "/exercism/rust/pascals-triangle/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SaadAhmed-96/Rust-Programmes path: /Struct, Methods, Associated Functions/Struct.rs #[derive(Debug)] struct Book { name: String, author: String, price: u16; availability: bool, }//template <|fim_suffix|> println!("{:#?}",book_1); println!("{:#?}",book_2); println!("{...
code_fim
hard
{ "lang": "rust", "repo": "SaadAhmed-96/Rust-Programmes", "path": "/Struct, Methods, Associated Functions/Struct.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let book_3 = Book { name:String::from("Book C"), author:String::from("Author C"), ..book_1 } ; println!("{:#?}",book_1); println!("{:#?}",book_2); println!("{:#?}",book_3); }<|fim_prefix|>// repo: SaadAhmed-96/Rust-Programmes path: /Struct, Methods, Associated...
code_fim
medium
{ "lang": "rust", "repo": "SaadAhmed-96/Rust-Programmes", "path": "/Struct, Methods, Associated Functions/Struct.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ole-thoeb/SysProg2019 path: /Blatt_3/Nr9/src/main.rs use std::env; use std::vec::Vec; type Matrix = Vec<Vec<i64>>; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 4 { exit_with_error(&format!("ERROR: expecting 3 arguments. <Matrix1> <Operator> <Matrix2>. Got {}...
code_fim
hard
{ "lang": "rust", "repo": "ole-thoeb/SysProg2019", "path": "/Blatt_3/Nr9/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> eprintln!("{}", error_msg); ::std::process::exit(1); } fn pars_matrix(matrix_string: &String) -> Matrix { if matrix_string.is_empty() { return Vec::new(); } let matrix: Matrix = matrix_string.split(";").map(|row: &str| { row.split(",").map(|cell: &str| { match cell.parse::<i64>() { Ok(n...
code_fim
hard
{ "lang": "rust", "repo": "ole-thoeb/SysProg2019", "path": "/Blatt_3/Nr9/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wycats/language-reporting path: /crates/render-tree/src/component.rs use crate::{Document, Render}; pub trait BlockComponent: Sized { fn with<F: FnOnce(Document) -> Document>( component: Self, block: F, ) -> CurriedBlockComponent<Self, F> { CurriedBlockComponent ...
code_fim
hard
{ "lang": "rust", "repo": "wycats/language-reporting", "path": "/crates/render-tree/src/component.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(document.to_string()?, "1: Something went wrong"); Ok(()) } #[test] fn test_block_component() -> ::std::io::Result<()> { struct Message { code: usize, message: &'static str, trailing: &'static str, } impl...
code_fim
hard
{ "lang": "rust", "repo": "wycats/language-reporting", "path": "/crates/render-tree/src/component.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arnaucube/poseidon-rs path: /benches/bench_poseidon_hash.rs use criterion::{criterion_group, criterion_main, Criterion}; #[macro_use] extern crate ff; use ff::*; use poseidon_rs::{Fr, Poseidon}; <|fim_suffix|> let b1: Fr = Fr::from_str( "12242166908188651009877250812424843524687801...
code_fim
medium
{ "lang": "rust", "repo": "arnaucube/poseidon-rs", "path": "/benches/bench_poseidon_hash.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> c.bench_function("hash", |b| { b.iter(|| poseidon.hash(big_arr.clone()).unwrap()) }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: arnaucube/poseidon-rs path: /benches/bench_poseidon_hash.rs use criterion::{criterion_group, criterion_m...
code_fim
hard
{ "lang": "rust", "repo": "arnaucube/poseidon-rs", "path": "/benches/bench_poseidon_hash.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blackmesalab/fireguard path: /src/cmd/daemon.rs use std::time::Duration; use std::{env, process}; use clap::Clap; use color_eyre::eyre::{bail, Result}; use futures::stream::StreamExt; use nix::sys::signal; use nix::unistd::Pid; use signal_hook::consts::signal::*; use signal_hook_tokio::Signals;...
code_fim
hard
{ "lang": "rust", "repo": "blackmesalab/fireguard", "path": "/src/cmd/daemon.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl Command for Stop {} impl Stop { pub async fn exec(&self, fg: &Fireguard, repository: &str) -> Result<()> { info!("Stopping foreground Fireguard daemon"); let config = self.load_config(repository, &fg.config_dir, &fg.config_file).await?; let pid = fs::read_to_string(&config...
code_fim
hard
{ "lang": "rust", "repo": "blackmesalab/fireguard", "path": "/src/cmd/daemon.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>/// Stop Fireguard daemon #[derive(Clap, Debug)] pub struct Status {} impl Command for Status {} impl Status { pub async fn exec(&self, fg: &Fireguard, repository: &str) -> Result<()> { let config = self.load_config(repository, &fg.config_dir, &fg.config_file).await?; match fs::read_t...
code_fim
hard
{ "lang": "rust", "repo": "blackmesalab/fireguard", "path": "/src/cmd/daemon.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn read_sprite_tile_pixel(&self, tile: &SpriteTile, x_offset: u8) -> Option<SnesRgb> { debug_assert!(x_offset < 8); let rel_color = self.read_chr_entry(4, // 16 colors tile.chr_addr, 8, // 8x8 til...
code_fim
hard
{ "lang": "rust", "repo": "hellow554/breeze-emu", "path": "/src/breeze_core/ppu/sprites.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hellow554/breeze-emu path: /src/breeze_core/ppu/sprites.rs //! Sprite rendering use super::{Ppu, SnesRgb}; use super::oam::OamEntry; use slicevec::SliceVec; /// Information saved about individual sprite layer pixels. Prerendered into the scanline cache. #[derive(Copy, Clone)] struct SpritePix...
code_fim
hard
{ "lang": "rust", "repo": "hellow554/breeze-emu", "path": "/src/breeze_core/ppu/sprites.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timvermeulen/try-iterator path: /src/adaptors/filter_map.rs use super::*; #[derive(Clone, Debug)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct FilterMap<I, F> { iter: I, f: F, } impl<I, F> FilterMap<I, F> { pub(crate) fn new(iter: I, f: F) -> Self { ...
code_fim
medium
{ "lang": "rust", "repo": "timvermeulen/try-iterator", "path": "/src/adaptors/filter_map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where G: FnMut(Acc, Self::Item) -> Q, Q: Try<Ok = Acc>, Q::Error: From<Self::Error>, { let f = &mut self.f; self.iter.map_err_mut(From::from).try_rfold(acc, |acc, x| match f(x)? { None => Try::from_ok(acc), Some(x) => g(acc, x), ...
code_fim
medium
{ "lang": "rust", "repo": "timvermeulen/try-iterator", "path": "/src/adaptors/filter_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bpzj/tex-rs path: /src/section_0113.rs //! @ The reader should study the following definitions closely: //! @^system dependencies@> // @d sc==int {|scaled| data is equivalent to |integer|} /// We add `sc` directly as another variant in memory_word here. const _: () = (); // // @<Types...@>= /...
code_fim
hard
{ "lang": "rust", "repo": "bpzj/tex-rs", "path": "/src/section_0113.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IndexMut<MEMORY_WORD_HH_LH> for memory_word { fn index_mut(&mut self, _: MEMORY_WORD_HH_LH) -> &mut halfword { unsafe { &mut self.hh.lh_or_b01.lh } } } pub(crate) struct MEMORY_WORD_HH_B1; impl Index<MEMORY_WORD_HH_B1> for memory_word { type Output = quarterword; fn index(&s...
code_fim
hard
{ "lang": "rust", "repo": "bpzj/tex-rs", "path": "/src/section_0113.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[no_sanitize(kcfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo // CHECK: Function Attrs: {{.*}} // CHECK-LABEL: define{{.*}}foo{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} // CHECK: start: // ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs // Verifies that KCFI operand bundles are omitted. // // revisions: aarch64 x86_64 // [aarch64] compile-flags: --target aarch64-unknown-none // [aarch64] needs-llvm-components: aarch64 // [x86_64] com...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wangminqi/litentry-pallets path: /pallets/account-linker/src/util_eth.rs use codec::Encode; use sp_std::prelude::*; pub fn addr_from_sig(msg: [u8; 32], sig: [u8; 65]) -> Result<[u8; 20], sp_io::EcdsaVerifyError> { let pubkey = sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg)?; let hashed_pk...
code_fim
hard
{ "lang": "rust", "repo": "wangminqi/litentry-pallets", "path": "/pallets/account-linker/src/util_eth.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let addr = addr_from_sig(msg, sig).ok().unwrap(); assert_ne!(addr, addr_expected); } #[test] fn msg_with_unexpected_length() { let msg = b"Link Litentry: 0123456789abcdef0123456789abcdef999".encode(); assert_eq!(Err("Unexpected ethereum message length!"), eth_data_hash(msg)); } #[test] fn ...
code_fim
hard
{ "lang": "rust", "repo": "wangminqi/litentry-pallets", "path": "/pallets/account-linker/src/util_eth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let msg = decode("61626364656667").unwrap(); let msg = eth_data_hash_test_helper(msg); let sig_bytes = decode("a4543cd17d07a9b5207bbf4ccf3c9d47e0a292a6ce461427ebc50de24387887b14584651c3bc11376ba9fe662df325ced20f5c30dd782b6bee15cb474c206a341b").unwrap(); let mut sig = [0u8; 65]; sig[0..65].copy_...
code_fim
hard
{ "lang": "rust", "repo": "wangminqi/litentry-pallets", "path": "/pallets/account-linker/src/util_eth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/alloc-compose path: /src/region.rs /// assert!(region.owns(memory)); /// # Ok::<(), core::alloc::AllocErr>(()) /// ``` /// It's possible to deallocate the latest memory block allocated: /// /// ```rust /// #![feature(slice_ptr_get)] /// # #![feature(allocator_api)] /// # use alloc_compos...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/alloc-compose", "path": "/src/region.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { region.dealloc(memory.as_non_null_ptr(), layout); } assert_eq!(region.capacity_left(), 32); assert!(!region.owns(memory)); let memory = region.alloc(layout).expect("Could not allocate 8 bytes"); assert!(region.owns(memory)); reg...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/alloc-compose", "path": "/src/region.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> region .alloc_zeroed(Layout::new::<[u8; 16]>()) .expect("Could not allocated 16 bytes"); assert_eq!(region.capacity_left(), 16); unsafe { assert_eq!(MaybeUninit::slice_get_ref(&data[0..16]), &[1; 16][..]); assert_eq!(MaybeUninit::sli...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/alloc-compose", "path": "/src/region.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shafferchance/Rust-ECS path: /src/modules/entity/entity_map.rs use std::vec::Vec; use std::cmp::max; use std::mem::replace; /// Attempting to use Generational Index to implement the backbone of the SoA for Systems to query /// /// Each Element has a "Generation" and Index /// Whenever an alloc...
code_fim
hard
{ "lang": "rust", "repo": "shafferchance/Rust-ECS", "path": "/src/modules/entity/entity_map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn try_alloc_next_index(&mut self) -> Option<Entity> { match self.free_list_head { None => None, Some(i) => match self.items[i] { EntityEntry::Occupied { .. } => panic!("corrupt free list"), EntityEntry::Free { next_free...
code_fim
hard
{ "lang": "rust", "repo": "shafferchance/Rust-ECS", "path": "/src/modules/entity/entity_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn print(&self) { println!("Index: {} | Generation: {}", self.index, self.generational_index) } } const DEFAULT_CAPACITY: usize = 4; impl<T> Default for EntityMap<T> { fn default() -> EntityMap<T> { EntityMap::new() } } impl<T> EntityMap<T> { pub fn new() -> Enti...
code_fim
hard
{ "lang": "rust", "repo": "shafferchance/Rust-ECS", "path": "/src/modules/entity/entity_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn include_in_all() -> Option<bool> { Some(true) } fn index() -> Option<bool> { Some(false) } fn store() -> Option<bool> { Some(true) } fn null_value() -> Option<f64> { Some(-0.00002) } }...
code_fim
hard
{ "lang": "rust", "repo": "elastic-rs/elastic-types", "path": "/types/benches/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Some(true) } fn include_in_all() -> Option<bool> { Some(true) } fn index() -> Option<bool> { Some(false) } fn store() -> Option<bool> { Some(true) } fn null_value() -> Option<i64> { ...
code_fim
hard
{ "lang": "rust", "repo": "elastic-rs/elastic-types", "path": "/types/benches/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elastic-rs/elastic-types path: /types/benches/mod.rs #![feature(plugin, test)] #![plugin(json_str)] extern crate serde; extern crate serde_json; pub extern crate chrono; extern crate geo as georust; extern crate geojson; extern crate test; extern crate elastic_types; pub mod date_fixtures { ...
code_fim
hard
{ "lang": "rust", "repo": "elastic-rs/elastic-types", "path": "/types/benches/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let temperature_value : f32 = temperature_value.trim().parse().unwrap(); if temperature_type.trim().parse::<char>().unwrap() == 'c' { let fahreneit = convert_celcius_to_fahreneit(temperature_value); println!("{} celcius is equals {} fahreneit", temperature_value, fahreneit); ...
code_fim
medium
{ "lang": "rust", "repo": "sercandumansiz/rust-practices", "path": "/temperature_converter/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("input is not valid"); temperature_type.clear(); read_line_temperature_type(temperature_type); } } fn convert_celcius_to_fahreneit(celcius: f32) -> f32 { (celcius * 9. / 5.) + 32. } fn convert_fahreneit_to_celcius(fahreneit: f32) -> f32 { (fahreneit - 32.) * (...
code_fim
hard
{ "lang": "rust", "repo": "sercandumansiz/rust-practices", "path": "/temperature_converter/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sercandumansiz/rust-practices path: /temperature_converter/src/main.rs use std::io; fn main() { let mut temperature_type = String::new(); read_line_temperature_type(&mut temperature_type); println!("please input temperature value"); let mut temperature_value = String::new(); ...
code_fim
medium
{ "lang": "rust", "repo": "sercandumansiz/rust-practices", "path": "/temperature_converter/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// }}} // {{{ problem 5 fn gcd(a : u64, b: u64) -> u64 { if b == 0 { return a; } gcd(b, a % b) } fn lcm(a : u64, b: u64) -> u64 { (a / gcd(a,b)) * b } fn lcm_iter<I>(mut iter: I) -> u64 where I: Iterator<Item = u64> { let mut ans = iter.next().unwrap(); for x in it...
code_fim
hard
{ "lang": "rust", "repo": "alexcoplan/euler-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexcoplan/euler-rust path: /src/main.rs // Solutions to some Project Euler problems in Rust. // Primarily a learning exercise to help learn me a Rust. // {{{ problem 1 fn fizzbuzz_sum(n : u64) -> u64 { let mut sum = 0; for i in 0..n { if i % 3 == 0 || i % 5 == 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "alexcoplan/euler-rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let id = HYPERLINK_ID.load(Ordering::Relaxed); HYPERLINK_ID.store(id.wrapping_add(1), Ordering::Relaxed); id } #[cfg(test)] pub fn generate_hyperlink_id() -> usize { 123 } pub fn create_hyperlink_rid(id: usize) -> String { format!("rIdHyperlink{}", id) }<|fim_prefix|>// repo: bokuweb...
code_fim
medium
{ "lang": "rust", "repo": "bokuweb/docx-rs", "path": "/docx-core/src/documents/hyperlink_id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bokuweb/docx-rs path: /docx-core/src/documents/hyperlink_id.rs #[cfg(not(test))] use std::sync::atomic::AtomicUsize; #[cfg(not(test))] static HYPERLINK_ID: AtomicUsize = AtomicUsize::new(1); #[cfg(not(test))] pub fn generate_hyperlink_id() -> usize { use std::sync::atomic::Ordering; <|fim_...
code_fim
medium
{ "lang": "rust", "repo": "bokuweb/docx-rs", "path": "/docx-core/src/documents/hyperlink_id.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_hyperlink_rid(id: usize) -> String { format!("rIdHyperlink{}", id) }<|fim_prefix|>// repo: bokuweb/docx-rs path: /docx-core/src/documents/hyperlink_id.rs #[cfg(not(test))] use std::sync::atomic::AtomicUsize; #[cfg(not(test))] static HYPERLINK_ID: AtomicUsize = AtomicUsize::new(1); <|fi...
code_fim
hard
{ "lang": "rust", "repo": "bokuweb/docx-rs", "path": "/docx-core/src/documents/hyperlink_id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forgerpl/nanomsg-multi path: /nanomsg-multi-server/src/config.rs use crate::consts::{DEFAULT_GC_INTERVAL, DEFAULT_SESSION_TIMEOUT, MAIN_SOCKET_URL}; use std::time::Duration; pub type Uid = ::libc::uid_t; pub type Gid = ::libc::gid_t; pub type FileMode = u32; #[inline] pub fn default_client_so...
code_fim
medium
{ "lang": "rust", "repo": "forgerpl/nanomsg-multi", "path": "/nanomsg-multi-server/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for GcInterval { fn default() -> GcInterval { GcInterval(Duration::from_secs(DEFAULT_GC_INTERVAL)) } } impl From<Duration> for GcInterval { fn from(source: Duration) -> GcInterval { GcInterval(source) } } impl From<GcInterval> for Duration { fn from(sourc...
code_fim
medium
{ "lang": "rust", "repo": "forgerpl/nanomsg-multi", "path": "/nanomsg-multi-server/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Copy, Clone, PartialEq)] pub struct GcInterval(Duration); impl Default for GcInterval { fn default() -> GcInterval { GcInterval(Duration::from_secs(DEFAULT_GC_INTERVAL)) } } impl From<Duration> for GcInterval { fn from(source: Duration) -> GcInterval { GcInter...
code_fim
hard
{ "lang": "rust", "repo": "forgerpl/nanomsg-multi", "path": "/nanomsg-multi-server/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samford/various-tests path: /actix-notfound-handler-tests/actix-test-wrap-fn/src/main.rs extern crate actix_files; extern crate actix_service; extern crate actix_web; extern crate futures; use actix_files as fs; use actix_service::Service; use actix_web::{http, App, HttpResponse, HttpServer}; u...
code_fim
hard
{ "lang": "rust", "repo": "samford/various-tests", "path": "/actix-notfound-handler-tests/actix-test-wrap-fn/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sys = actix_rt::System::new("actix-test-wrap-fn"); HttpServer::new(move || { App::new() .wrap_fn(|req, srv| { srv.call(req).map(|mut res| { if res.status() != http::StatusCode::NOT_FOUND { return res; ...
code_fim
hard
{ "lang": "rust", "repo": "samford/various-tests", "path": "/actix-notfound-handler-tests/actix-test-wrap-fn/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // NOTE: output_dir is normally determined at runtime but it's hardcoded // here for simplicity let output_dir = "public"; let static_root = Path::new(output_dir).to_path_buf(); let sys = actix_rt::System::new("actix-test-wrap-fn"); HttpServer::new(move || { App::new() ...
code_fim
hard
{ "lang": "rust", "repo": "samford/various-tests", "path": "/actix-notfound-handler-tests/actix-test-wrap-fn/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lasagnaphil/gengine-rs path: /src/shader.rs use std::ffi::CString; use std::ptr; use std::str; use std::fs::File; use std::io::prelude::*; use gl; use gl::types::*; use cgmath::{Matrix4, Vector3}; use cgmath::prelude::*; use serde::{Serialize, Deserialize}; use path::*; #[derive(Serialize, ...
code_fim
hard
{ "lang": "rust", "repo": "lasagnaphil/gengine-rs", "path": "/src/shader.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> pub fn use_shader(&self) { unsafe { gl::UseProgram(self.program); } } pub fn set_bool(&self, name: &str, value: bool) { unsafe { gl::Uniform1i(gl::GetUniformLocation(self.program, to_cstring(name).as_ptr()), value as GLint); } } ...
code_fim
hard
{ "lang": "rust", "repo": "lasagnaphil/gengine-rs", "path": "/src/shader.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> // topological sort let mut topo: Vec<String> = Vec::new(); toposort("FUEL", &requirements, &mut topo); for ingr in requirements.keys() { toposort(ingr, &requirements, &mut topo); } topo.reverse(); println!("{:?}", topo); let mut lower_bound: i128 = 0; let mut ...
code_fim
hard
{ "lang": "rust", "repo": "owenl131/aoc2019", "path": "/src/day14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut lower_bound: i128 = 0; let mut upper_bound: i128 = 1000000000000000; while lower_bound < upper_bound { let mid = (lower_bound + upper_bound + 1) / 2; if can_support(mid, &requirements, &topo) { lower_bound = mid; } else { upper_bound = m...
code_fim
hard
{ "lang": "rust", "repo": "owenl131/aoc2019", "path": "/src/day14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: owenl131/aoc2019 path: /src/day14.rs use std::fs; use std::collections::HashMap; use std::collections::HashSet; fn split_space(x: &str) -> (i128, &str) { if let [qty, ingr] = x.split(" ").collect::<Vec<&str>>()[..] { (qty.parse().unwrap(), ingr) } else { panic!("Invalid ...
code_fim
hard
{ "lang": "rust", "repo": "owenl131/aoc2019", "path": "/src/day14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eigth", "ninth", "tenth", "eleventh", "twelfth" ]; for i in 1..13 { println!("On the {} day of Christmas my true love...
code_fim
medium
{ "lang": "rust", "repo": "flores-jacob/Rust-Book-Notes", "path": "/chapter_3/twelve_days/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flores-jacob/Rust-Book-Notes path: /chapter_3/twelve_days/src/main.rs fn main() { let verses = [ "A Partridge in a Pear Tree", "Two Turtle Doves and", "Three French Hens", "Four Calling Birds", "Five Golden Rings", "Six Geese a Laying", ...
code_fim
hard
{ "lang": "rust", "repo": "flores-jacob/Rust-Book-Notes", "path": "/chapter_3/twelve_days/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Units Enumeration pub enum Units { /// Represent temperatures in ADC Counts Count, /// Represent temperatures in Celsius Celsius, /// Represent temperatures in Fahrenheit Fahrenheit, /// Represent temperatures in Kelvin Kelvin, } /// Sensor Types Enumeration enum Senso...
code_fim
hard
{ "lang": "rust", "repo": "mbacch/max31855", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbacch/max31855 path: /src/lib.rs //! A platform agnostic driver to interface with the MAX31855 //! //! //! //! This driver was built using [`embedded-hal`] traits. //! //! //! //! [`embedded-hal`]: https://docs.rs/embedded-hal/~0.1 //! //! #![deny(missing_docs)] #![deny(warnings)] #![no_std] ...
code_fim
hard
{ "lang": "rust", "repo": "mbacch/max31855", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok( Measurement { temperature: self.calibrate_thermocouple(raw.temperature, &unit), cold_reference: self.calibrate_reference(raw.cold_reference, &unit), fault: raw.fault, scv: raw.scv, scg: raw.scg, ...
code_fim
hard
{ "lang": "rust", "repo": "mbacch/max31855", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/tezedge path: /shell/tests/context_listener_test.rs // Copyright (c) SimpleStaking and Tezedge Contributors // SPDX-License-Identifier: MIT #![feature(test)] extern crate test; use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use std::thread; use jsonpath::Sele...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/tezedge", "path": "/shell/tests/context_listener_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn test_storage_dir_path(dir_name: &str) -> PathBuf { let out_dir = env::var("OUT_DIR").expect("OUT_DIR is not defined"); let path = Path::new(out_dir.as_str()) .join(Path::new(dir_name)) .to_path_buf(); path } pub fn is_ocaml_log_enabled() ...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/tezedge", "path": "/shell/tests/context_listener_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SOF3/just path: /src/config_error.rs use crate::common::*; pub(crate) enum ConfigError { Internal { message: String }, } impl Display for ConfigError { fn fmt(&self, f: &mut Formatter) -> fmt::Result { <|fim_suffix|> match self { Internal { message } => write!( f, ...
code_fim
easy
{ "lang": "rust", "repo": "SOF3/just", "path": "/src/config_error.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Internal { message } => write!( f, "Internal config error, this may indicate a bug in just: {} \ consider filing an issue: https://github.com/casey/just/issues/new", message ), } } }<|fim_prefix|>// repo: SOF3/just path: /src/config_erro...
code_fim
easy
{ "lang": "rust", "repo": "SOF3/just", "path": "/src/config_error.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/structs-enums/namespaced-enum-emulate-flat.rs // run-pass #![allow(dead_code)] // pretty-expanded FIXME #23616 pub use Foo::*; use nest::{Bar, D, E, F}; pub enum Foo { A, B(isize), C { a: isize }, } impl Foo { pub fn foo() {} ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/structs-enums/namespaced-enum-emulate-flat.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }