text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: Valentine-Mario/register-vm path: /src/assembler/mod.rs use crate::instruction::Opcode; pub mod opcode_parser; pub mod instruction_parsers; pub mod program_parser; pub mod register_parser; pub mod operand_parser; pub mod label_parser; pub mod directive_parser; use nom::types::CompleteStr; use cr...
code_fim
hard
{ "lang": "rust", "repo": "Valentine-Mario/register-vm", "path": "/src/assembler/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum SymbolType { Label, } #[derive(Debug)] pub struct SymbolTable { symbols: Vec<Symbol> } impl SymbolTable { pub fn new() -> SymbolTable { SymbolTable{ symbols: vec![] } } pub fn add_symbol(&mut self, s: Symbol) { self.symbo...
code_fim
hard
{ "lang": "rust", "repo": "Valentine-Mario/register-vm", "path": "/src/assembler/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if ends_with_test { // Expand the `test.rs` test by default. args.push("test".into()); } if ends_with_example { // Expand the `example.rs` example by default. args.push("example".into()); } if !has_color { let color = stderr_isatty(); l...
code_fim
hard
{ "lang": "rust", "repo": "willcrichton/cargo-expand", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: willcrichton/cargo-expand path: /src/main.rs use std::env; use std::ffi::{OsStr, OsString}; use std::io::{self, Write}; use std::path::PathBuf; use std::process::{self, Command}; #[cfg(unix)] use std::process::{Child, Stdio}; extern crate isatty; use isatty::{stderr_isatty, stdout_isatty}; #[...
code_fim
hard
{ "lang": "rust", "repo": "willcrichton/cargo-expand", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrew-d/autobind path: /tests/compile-fail/invalid-function-types.rs #![feature(phase)] #![allow(dead_code)] #[phase(plugin)] extern crate autobind; struct Foo; #[autobind] impl Foo { pub fn with_lifetime<'a>(&'a self) {} //~^ WARNING: autobind: cannot generate bindings for method wi...
code_fim
hard
{ "lang": "rust", "repo": "andrew-d/autobind", "path": "/tests/compile-fail/invalid-function-types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // No warning for items that aren't public. fn not_public_with_lifetime<'a>(&'a self) {} } // At least one error is needed so that compilation fails #[static_assert] static b: bool = false; //~ ERROR static assertion failed fn main() {}<|fim_prefix|>// repo: andrew-d/autobind path: /tests/compi...
code_fim
medium
{ "lang": "rust", "repo": "andrew-d/autobind", "path": "/tests/compile-fail/invalid-function-types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BatmanAoD/lia path: /lia-experimental/src/lib.rs #![feature(box_syntax, box_patterns, slice_patterns, plugin, rustc_private, quote, question_mark, try_from)] #![plugin(rabbot_plugin)] #[macro_use] extern crate rabbot; #[macro_use] extern crate lia_jit; extern crate rustlex_codegen as...
code_fim
hard
{ "lang": "rust", "repo": "BatmanAoD/lia", "path": "/lia-experimental/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::compile; use ast::term::{View, out}; macro_rules! test_pass { ($name:ident, $src:expr) => { #[test] fn $name () { compile($src.to_string()); } }; ($name:ident, $src:expr, $expected...
code_fim
hard
{ "lang": "rust", "repo": "BatmanAoD/lia", "path": "/lia-experimental/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spwndrtfct/rusty-boy path: /src/cpu/tests.rs #[cfg(test)] use super::constants::*; #[allow(unused_imports)] use cpu::*; macro_rules! test_op { ($func:ident, $method:ident, $input:expr, $output_reg:ident, $expected_output:expr, $flag_find_value:expr, $flag_expected_value:expr, $pre...
code_fim
hard
{ "lang": "rust", "repo": "spwndrtfct/rusty-boy", "path": "/src/cpu/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> test_op16!(addhl_test, add_hl, CpuRegister16::BC, CpuRegister16::HL, 0xFFFF, (0xFFFF + 0x14D) as u16, |flags| flags & 0x70, HL | CL); test_op16!(addhl_test1, add_hl, CpuRegister16::DE, CpuRegister16::HL, 0, (0 + 0x14D), |flags| flags & 0x70, 0); test_op16!(addhl_test2, add_hl, CpuRegister16::DE, CpuRegi...
code_fim
hard
{ "lang": "rust", "repo": "spwndrtfct/rusty-boy", "path": "/src/cpu/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } #[test] fn test_daa() { //! This instruction is very confusing so we need to test it carefully let mut cpu = Cpu::new(); println!("1"); cpu.a = 0x11; cpu.add(CpuRegister::Num(0x22)); cpu.daa(); assert_eq!(cpu.a, 0x33); assert_eq!(cpu.f & CL, 0); println!("2"...
code_fim
hard
{ "lang": "rust", "repo": "spwndrtfct/rusty-boy", "path": "/src/cpu/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: illicitonion/num_enum path: /num_enum/tests/try_build.rs use std::error::Error; use std::path::{Path, PathBuf}; use walkdir::WalkDir; #[test] fn trybuild() { let directory = PathBuf::from("tests/try_build"); let mut _renamer = None; let compile_fail_dir = directory.join("compile_f...
code_fim
hard
{ "lang": "rust", "repo": "illicitonion/num_enum", "path": "/num_enum/tests/try_build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for path in &self.0 { ignore_error(std::fs::rename( path.with_extension(Renamer::STDERR_EXTENSION), path.with_extension(Renamer::VERSION_SPECIFIC_EXTENSION), )); ignore_error(std::fs::rename( path.with_extension(Re...
code_fim
hard
{ "lang": "rust", "repo": "illicitonion/num_enum", "path": "/num_enum/tests/try_build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn rename(dir: PathBuf) -> anyhow::Result<Self> { let nightly_paths = WalkDir::new(dir) .max_depth(1) .into_iter() .filter_map(|dir_entry| { let dir_entry = match dir_entry { Ok(dir_entry) => dir_entry, ...
code_fim
hard
{ "lang": "rust", "repo": "illicitonion/num_enum", "path": "/num_enum/tests/try_build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut alice_csprng = OsRng::new().unwrap(); let alice_secret = generate_secret(&mut alice_csprng); let alice_public = generate_public(&alice_secret); let b32_secret = base32::encode(base32::Alphabet::RFC4648 { padding: false }, &alice_secret); let b32_public = ba...
code_fim
medium
{ "lang": "rust", "repo": "ppopth/torkeygen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let b32_secret = base32::encode(base32::Alphabet::RFC4648 { padding: false }, &alice_secret); let b32_public = base32::encode(base32::Alphabet::RFC4648 { padding: false }, alice_public.as_bytes()); println!("secret: {:?}", b32_secret); println!("public: {:?}", b32_public); }<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "ppopth/torkeygen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ppopth/torkeygen path: /src/main.rs extern crate x25519_dalek; extern crate rand; extern crate base32; <|fim_suffix|> let mut alice_csprng = OsRng::new().unwrap(); let alice_secret = generate_secret(&mut alice_csprng); let alice_public = generate_public(&alice_secret); l...
code_fim
medium
{ "lang": "rust", "repo": "ppopth/torkeygen", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-analyzer path: /crates/stdx/src/lib.rs //! Missing batteries for standard libraries. use std::{cell::Cell, fmt, time::Instant}; #[inline(always)] pub fn is_ci() -> bool { option_env!("CI").is_some() } #[macro_export] macro_rules! eprintln { ($($tt:tt)*) => {{ i...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/stdx/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> f.write_str(self.prefix)?; let mut first = true; for item in self.iter.take().unwrap() { if !first { f.write_str(self.sep)?; } first = false; fmt::Display::fmt(&item, f)?; } f.write_str(self.suffix)?; ...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-analyzer", "path": "/crates/stdx/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn attach_tentacle(&mut self, p: Point2D) { self.tentacles.push(self.orientation.unapply_to(p)); } pub fn detach_last_tentacle(&mut self) { self.tentacles.remove(self.tentacles.len() - 1); } pub fn next_attachment_point(&self) -> Point2D { let x = self.ten...
code_fim
hard
{ "lang": "rust", "repo": "coffeecup-winner/icfpc2019", "path": "/src/robot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coffeecup-winner/icfpc2019 path: /src/robot.rs use crate::geometry::Point2D; use crate::grid::Grid; #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum RotationDirection { CW, CCW, } #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum Orientation { Left, Up, Right, ...
code_fim
hard
{ "lang": "rust", "repo": "coffeecup-winner/icfpc2019", "path": "/src/robot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustyYato/double-buffer-v2 path: /src/base/raw_buffers.rs use core::cell::UnsafeCell; use crate::traits::RawDoubleBuffer; #[repr(transparent)] pub(crate) struct RawBuffers<R: ?Sized>(UnsafeCell<R>); <|fim_suffix|>impl<R> RawBuffers<R> { pub const fn new(buffers: R) -> Self { Self(UnsafeCe...
code_fim
medium
{ "lang": "rust", "repo": "RustyYato/double-buffer-v2", "path": "/src/base/raw_buffers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) unsafe fn split(&self, which: bool) -> (&R::Buffer, &R::Buffer) { let (writer, reader) = RawDoubleBuffer::split(self.0.get(), which); (&*writer, &*reader) } pub(crate) unsafe fn split_mut(&self, which: bool) -> (&mut R::Buffer, &R::Buffer) { let (writer, rea...
code_fim
hard
{ "lang": "rust", "repo": "RustyYato/double-buffer-v2", "path": "/src/base/raw_buffers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> serviceaccesscontrol: *mut ::libc::c_void) -> Result; pub fn SRVPM_UnregisterProcess(procid: u32_) -> Result; } use ::types::*;<|fim_prefix|>// repo: panicbit/ctru-rs path: /ctru-sys/src/services/srvpm.rs /* automatically generated by rust-bindgen */ #![allow(dead_code, ...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/ctru-rs", "path": "/ctru-sys/src/services/srvpm.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: panicbit/ctru-rs path: /ctru-sys/src/services/srvpm.rs /* automatically generated by rust-bindgen */ #![allow(dead_code, non_camel_case_types, non_upper_case_globals, non_snake_ca<|fim_suffix|> -> Result; pub fn SRVPM_PublishToAll(notificationId: u32_) -> Result;...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/ctru-rs", "path": "/ctru-sys/src/services/srvpm.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> -> Result; pub fn SRVPM_PublishToAll(notificationId: u32_) -> Result; pub fn SRVPM_RegisterProcess(procid: u32_, count: u32_, serviceaccesscontrol: *mut ::libc::c_void) -> Result; pub fn SRVPM_UnregisterProcess(procid: u32_) -> Result; } use ::types::*;<...
code_fim
medium
{ "lang": "rust", "repo": "panicbit/ctru-rs", "path": "/ctru-sys/src/services/srvpm.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinityb/yscloud path: /experiments/sdf-dns/src/main.rs use trust_dns_client::rr::LowerName; use trust_dns_proto::rr::dnssec::SupportedAlgorithms; use trust_dns_proto::rr::record_type::RecordType; use trust_dns_server::authority::Authority; use trust_dns_server::authority::AuthLookup; <|fim_su...
code_fim
medium
{ "lang": "rust", "repo": "infinityb/yscloud", "path": "/experiments/sdf-dns/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, name: &LowerName, rtype: RecordType, is_secure: bool, supported_algorithms: SupportedAlgorithms, ) -> Self::LookupFuture { // } }<|fim_prefix|>// repo: infinityb/yscloud path: /experiments/sdf-dns/src/main.rs use trust_dns_client::rr::LowerNa...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/yscloud", "path": "/experiments/sdf-dns/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/js/expressions/array_expression.rs use crate::formatter_traits::FormatTokenAndNode; use crate::{FormatElement, FormatResult, Formatter, ToFormatElement}; <|fim_suffix|> let JsArrayExpressionFields { l_brack_token, ...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/js/expressions/array_expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> formatter.format_delimited_soft_block_indent( &l_brack_token?, elements.format(formatter)?, &r_brack_token?, ) } }<|fim_prefix|>// repo: Tembocs/rome path: /crates/rome_js_formatter/src/js/expressions/array_expression.rs use crate::formatter_traits:...
code_fim
hard
{ "lang": "rust", "repo": "Tembocs/rome", "path": "/crates/rome_js_formatter/src/js/expressions/array_expression.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cc::Build::new().file("src/lib.s").compile("asm"); println!("cargo:rerun-if-changed=src/lib.s"); }<|fim_prefix|>// repo: jyotsna-penumaka/enarx path: /sallyport/build.rs // SPDX-License-Identifier: Apache-2.0 <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "jyotsna-penumaka/enarx", "path": "/sallyport/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jyotsna-penumaka/enarx path: /sallyport/build.rs // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|> cc::Build::new().file("src/lib.s").compile("asm"); println!("cargo:rerun-if-changed=src/lib.s"); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "jyotsna-penumaka/enarx", "path": "/sallyport/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.ptr = new_ptr as *mut u8; self.ptr } pub fn allocated(&self) -> usize { self.end as usize - self.ptr as usize } pub fn capacity(&self) -> usize { self.layout.size() } pub(crate) fn end(&self) -> *const u8 { self.end } pub(cra...
code_fim
hard
{ "lang": "rust", "repo": "anderslanglands/ustr", "path": "/src/bumpalloc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub fn allocated(&self) -> usize { self.end as usize - self.ptr as usize } pub fn capacity(&self) -> usize { self.layout.size() } pub(crate) fn end(&self) -> *const u8 { self.end } pub(crate) fn ptr(&self) -> *const u8 { self.ptr } }<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "anderslanglands/ustr", "path": "/src/bumpalloc.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anderslanglands/ustr path: /src/bumpalloc.rs use std::alloc::{GlobalAlloc, Layout, System}; // The world's dumbest allocator. Just keep bumping a pointer until we run out // of memory, in which case we abort. StringCache is responsible for creating // a new allocator when that's about to happen...
code_fim
hard
{ "lang": "rust", "repo": "anderslanglands/ustr", "path": "/src/bumpalloc.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucas3fonseca/rustaceos path: /crates/eosio_cdt/src/lib.rs #![feature(const_fn, const_if_match, const_loop, const_panic, const_mut_refs)] #![allow(non_camel_case_types)] <|fim_suffix|>pub use cdt::*; pub use eosio_cdt_macro::{abi, action}; pub type c_char = u8;<|fim_middle|>pub use core::ffi::...
code_fim
medium
{ "lang": "rust", "repo": "lucas3fonseca/rustaceos", "path": "/crates/eosio_cdt/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod cdt; pub mod eos; mod eosio_cdt_bindings; pub use cdt::*; pub use eosio_cdt_macro::{abi, action}; pub type c_char = u8;<|fim_prefix|>// repo: lucas3fonseca/rustaceos path: /crates/eosio_cdt/src/lib.rs #![feature(const_fn, const_if_match, const_loop, const_panic, const_mut_refs)] #![allow(non_ca...
code_fim
easy
{ "lang": "rust", "repo": "lucas3fonseca/rustaceos", "path": "/crates/eosio_cdt/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Byron/crates-io-cli path: /src/scmds/list/mod.rs //! If you are seeing this, than you see a very old way of doing things, prior //! to 'async' being a keyword, and while all async was in its infancy. //! Even though it would be nice to see how that code w<|fim_suffix|>m //! being pretty complex ...
code_fim
medium
{ "lang": "rust", "repo": "Byron/crates-io-cli", "path": "/src/scmds/list/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>m //! being pretty complex for what they do. mod cmd; mod error; pub use self::{cmd::*, error::Error};<|fim_prefix|>// repo: Byron/crates-io-cli path: /src/scmds/list/mod.rs //! If you are seeing this, than you see a very old way of doing things, prior //! to 'async' being a keyword, and while all asyn...
code_fim
medium
{ "lang": "rust", "repo": "Byron/crates-io-cli", "path": "/src/scmds/list/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ould look nowadays, I //! would rather solve new problems than changing existing solutions, despite them //! being pretty complex for what they do. mod cmd; mod error; pub use self::{cmd::*, error::Error};<|fim_prefix|>// repo: Byron/crates-io-cli path: /src/scmds/list/mod.rs //! If you are seeing this...
code_fim
medium
{ "lang": "rust", "repo": "Byron/crates-io-cli", "path": "/src/scmds/list/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jadeaffenjaeger/rust_aoc19 path: /intcomputer/src/lib.rs use std::collections::VecDeque; const LEN_IO_INSTR: usize = 2; const LEN_BASE_INSTR: usize = 2; const LEN_JUMP_INSTR: usize = 3; const LEN_ARITH_INSTR: usize = 4; pub struct IntComputer { pub program: Vec<i64>, pub input: VecDequ...
code_fim
hard
{ "lang": "rust", "repo": "jadeaffenjaeger/rust_aoc19", "path": "/intcomputer/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_add() { let mut comp = IntComputer::new(vec![1, 0, 0, 0, 99]); comp.run(); assert_eq!(comp.program, vec![2, 0, 0, 0, 99]) } #[test] fn test_mul() { let mut comp = IntComputer::new(vec![2, 3, 0, ...
code_fim
hard
{ "lang": "rust", "repo": "jadeaffenjaeger/rust_aoc19", "path": "/intcomputer/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn spawn<T>(self: Arc<Self>, msg: T) -> () where T: Message + 'static, T::Output: Send, { tokio::spawn(msg.handle(self)); } } #[async_trait] pub trait Message { type Output; async fn handle(self, messager: Arc<Messager>) -> Self::Output; }<|fim_pr...
code_fim
medium
{ "lang": "rust", "repo": "Kilerd/gotcha", "path": "/gotcha/src/message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kilerd/gotcha path: /gotcha/src/message.rs use std::sync::Arc; use actix_web::web; use async_trait::async_trait; <|fim_suffix|>#[async_trait] pub trait Message { type Output; async fn handle(self, messager: Arc<Messager>) -> Self::Output; }<|fim_middle|>pub struct Messager {} pub type...
code_fim
hard
{ "lang": "rust", "repo": "Kilerd/gotcha", "path": "/gotcha/src/message.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> buf.copy_from_slice(&h2[0..4]); buf }<|fim_prefix|>// repo: chongyi/tron-payment path: /core/src/utils.rs use sha2::Digest; pub fn to_raw_address<T: AsRef<[u8]>>(checked_address: &T) -> &[u8] { &checked_address.as_ref()[0..21] } <|fim_middle|>pub fn raw_address_base_check(raw_address: &[u8]...
code_fim
medium
{ "lang": "rust", "repo": "chongyi/tron-payment", "path": "/core/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chongyi/tron-payment path: /core/src/utils.rs use sha2::Digest; pub fn to_raw_address<T: AsRef<[u8]>>(checked_address: &T) -> &[u8] { &checked_address.as_ref()[0..21] } <|fim_suffix|> buf.copy_from_slice(&h2[0..4]); buf }<|fim_middle|>pub fn raw_address_base_check(raw_address: &[u8]...
code_fim
medium
{ "lang": "rust", "repo": "chongyi/tron-payment", "path": "/core/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FeistyKit/universe-simulator path: /src/rendering/graphichandler.rs use std::sync::mpsc::Receiver; use crate::{ graphicbody::GraphicBody, transmission::{GuiToGraphicsEvent, SimulationEvent}, }; use sfml::graphics::{CircleShape, Color, RenderTarget, Shape, Transformable}; //The number ...
code_fim
hard
{ "lang": "rust", "repo": "FeistyKit/universe-simulator", "path": "/src/rendering/graphichandler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //adding a body SimulationEvent::Add { id, pos, color, size, } => { //preparing a circle to be the main bit of the graphicbody let mut circle = CircleShape::new(size, 25); //...
code_fim
hard
{ "lang": "rust", "repo": "FeistyKit/universe-simulator", "path": "/src/rendering/graphichandler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cost = [ [0, 5, 2, I, I, I, I], [5, 0, 4, 2, I, I, I], [2, 4, 0, 6,10, I, I], [I, 2, 6, 0, I, 1, I], [I, I,10, I, 0, 3, 5], [I, I, I, 1, 3, 0, 9], [I, I, I, I, 5, 9, 0], ]; let mut d = [I;V]; let mut used = [false;V]; d[0] = 0...
code_fim
medium
{ "lang": "rust", "repo": "Ogiwara-CostlierRain464/RustSample", "path": "/src/archive/ダイクストラ.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ogiwara-CostlierRain464/RustSample path: /src/archive/ダイクストラ.rs use std::cmp::{ min }; fn main(){ dijkstra(); } const I: usize = 10000; const V: usize = 7; <|fim_suffix|> loop { let mut v: isize = -1; for u in 0..V{ if !used[u] && (v == -1 || d[u] < d[v as u...
code_fim
hard
{ "lang": "rust", "repo": "Ogiwara-CostlierRain464/RustSample", "path": "/src/archive/ダイクストラ.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut output_features: Vec<Feature> = if !swap_ab { vec![features[0].clone(), features[1].clone()] } else { vec![features[1].clone(), features[0].clone()] }; for feature in features.iter().skip(2) { let op = extract_expected_result(feature).op; println!("...
code_fim
medium
{ "lang": "rust", "repo": "21re/rust-geo-booleanop", "path": "/tests/src/bin/run_single_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for feature in features.iter().skip(2) { let op = extract_expected_result(feature).op; println!("Testing operation: {:?}", op); let result = apply_operation(&p1, &p2, op); output_features.push(convert_to_feature(&result, Some(op))); } write_compact_geojson(&o...
code_fim
medium
{ "lang": "rust", "repo": "21re/rust-geo-booleanop", "path": "/tests/src/bin/run_single_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 21re/rust-geo-booleanop path: /tests/src/bin/run_single_test.rs //! //! This binary allows running a test case directly by specifying its path //! as argument. //! use clap::{Arg, Command}; use geojson::Feature; use geo_booleanop_tests::compact_geojson::write_compact_geojson; use geo_booleanop_...
code_fim
hard
{ "lang": "rust", "repo": "21re/rust-geo-booleanop", "path": "/tests/src/bin/run_single_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } else { dp[idx1][idx2] = dp[idx1 - 1][idx2].min(dp[idx1][idx2 - 1]) + 1; } } } // println!("{:?}", dp); dp[w1.len()][w2.len()] as i32 } } struct Solution;<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/rust-alg", "path": "/src/leetcode/delete_operation_for_two_strings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/delete_operation_for_two_strings.rs //! 583. Delete Operation for Two Strings impl Solution { pub fn min_distance(word1: String, word2: String) -> i32 { let mut w1 = word1.chars().collect::<Vec<_>>(); let mut w2 = word2.chars().collect::<...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/rust-alg", "path": "/src/leetcode/delete_operation_for_two_strings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", result); // How can you destructure and get the result of the value? match result { Some(z) => println!("{}/{} = {}", x, y, z), None => println!("cannot divide {} by {}", x, y), } // if let / while let if let Some(z) = result { println!("z...
code_fim
medium
{ "lang": "rust", "repo": "fredrikaverpil/rust-syntax", "path": "/src/mod10_options.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // if let / while let if let Some(z) = result { println!("z = {}", z); } } pub fn main() { option(); }<|fim_prefix|>// repo: fredrikaverpil/rust-syntax path: /src/mod10_options.rs fn option() { // Option<T> let x = 3.0; let y = 2.0; // We cannot divide by zero ...
code_fim
hard
{ "lang": "rust", "repo": "fredrikaverpil/rust-syntax", "path": "/src/mod10_options.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredrikaverpil/rust-syntax path: /src/mod10_options.rs fn option() { // Option<T> let x = 3.0; let y = 2.0; <|fim_suffix|> // if let / while let if let Some(z) = result { println!("z = {}", z); } } pub fn main() { option(); }<|fim_middle|> // We cannot di...
code_fim
hard
{ "lang": "rust", "repo": "fredrikaverpil/rust-syntax", "path": "/src/mod10_options.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::fib(2), 1); } #[test] fn test_3() { assert_eq!(Solution::fib(3), 2); } #[test] fn test_4() { assert_eq!(Solution::fib(4), 3); } #[bench] fn bench(b: &mut test::Bencher) { b.iter(|| Solution::fib(30)); } }<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "COLDTURNIP/raphanus_leetcode", "path": "/rust/src/p509.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcode path: /rust/src/p509.rs /* Problem 509. Fibonacci Number ============================= https://leetcode.com/problems/fibonacci-number/ The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of t...
code_fim
hard
{ "lang": "rust", "repo": "COLDTURNIP/raphanus_leetcode", "path": "/rust/src/p509.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Input: 4 Output: 3 Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3. Note: 0 ≤ N ≤ 30. */ use std::collections::HashMap; impl Solution { pub fn fib(n: i32) -> i32 { let mut cache = HashMap::new(); cache.insert(1, 1); Self::fib_impl(n, &mut cache) } fn fi...
code_fim
hard
{ "lang": "rust", "repo": "COLDTURNIP/raphanus_leetcode", "path": "/rust/src/p509.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bahelms/super_perfundo path: /native/quarto_ai/src/mcts/agent.rs use super::{Node, NodeBuilder}; use crate::game::{GameState, Move, Player}; use rand::Rng; use std::rc::Rc; /* Monte Carlo Tree Search - create tree for given game state - start a round: - pick a leaf node - randomly plac...
code_fim
hard
{ "lang": "rust", "repo": "bahelms/super_perfundo", "path": "/native/quarto_ai/src/mcts/agent.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let node_ref = node.borrow(); let child = node_ref.children.first().unwrap(); assert!(child.borrow().node_move.is_some()); } #[test] fn simulate_random_game_returns_the_winning_player() { let mut board = new_board(); board[1] = Some(1); board[2]...
code_fim
hard
{ "lang": "rust", "repo": "bahelms/super_perfundo", "path": "/native/quarto_ai/src/mcts/agent.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eldruin/ds1307-rs path: /src/run.rs use crate::{BitFlags, Ds1307, Error, Register}; use embedded_hal::blocking::i2c::{Write, WriteRead}; <|fim_suffix|> /// Set the clock to run (default on power-on). /// (Does not alter the device register if already running). pub fn set_running(&mut...
code_fim
hard
{ "lang": "rust", "repo": "eldruin/ds1307-rs", "path": "/src/run.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Set the clock to run (default on power-on). /// (Does not alter the device register if already running). pub fn set_running(&mut self) -> Result<(), Error<E>> { // Clock Halt (CH) bit should be cleared for oscillator to work. self.clear_register_bit_flag(Register::SECONDS, ...
code_fim
hard
{ "lang": "rust", "repo": "eldruin/ds1307-rs", "path": "/src/run.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shenek/ucelofka path: /ucelofka-data/src/identification/v1.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Clone, <|fim_suffix|> pub name: String, pub value: String, }<|fim_middle|>PartialEq)] pub struct Identification {
code_fim
easy
{ "lang": "rust", "repo": "shenek/ucelofka", "path": "/ucelofka-data/src/identification/v1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub name: String, pub value: String, }<|fim_prefix|>// repo: shenek/ucelofka path: /ucelofka-data/src/identification/v1.rs use serde::{Deserialize, Serialize}; #[de<|fim_middle|>rive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct Identification {
code_fim
medium
{ "lang": "rust", "repo": "shenek/ucelofka", "path": "/ucelofka-data/src/identification/v1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pranoyk/learning_rust path: /box-t/src/main.rs enum List<T> { Cons(T, Box<List<T>>), Nil, } use crate::List::{Cons, Nil}; <|fim_suffix|> let list1 = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))); let list2 = Cons("a", Box::new(Cons("b", Box::new(Cons("c", Box::new...
code_fim
easy
{ "lang": "rust", "repo": "pranoyk/learning_rust", "path": "/box-t/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let list1 = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))); let list2 = Cons("a", Box::new(Cons("b", Box::new(Cons("c", Box::new(Nil)))))); }<|fim_prefix|>// repo: pranoyk/learning_rust path: /box-t/src/main.rs enum List<T> { Cons(T, Box<List<T>>), Nil, } use crate::List::{...
code_fim
easy
{ "lang": "rust", "repo": "pranoyk/learning_rust", "path": "/box-t/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prateekkumarweb/sudoku-wasm path: /src/sudoku.rs use rsat::msat::*; use rsat::{Lit, Solution}; pub struct Sudoku { pub grid: [[u32; 9]; 9], solver: Solver, } impl Sudoku { pub fn new(grid: [[u32; 9]; 9]) -> Option<Self> { let mut solver = Solver::new(SolverOptions::default(...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/sudoku-wasm", "path": "/src/sudoku.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn solve(&mut self) -> bool { match self.solver.solve(vec![]) { Solution::Sat(sol) => { for i in 0..9 { for j in 0..9 { for k in 0..9 { if sol[9 * 9 * i + 9 * j + k] { ...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/sudoku-wasm", "path": "/src/sudoku.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hershi/AoC2018 path: /aoc_13/src/main.rs use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use std::collections::HashMap; #[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord)] struct Point { x: usize, y: usize, } impl Point { fn next(&self, dir: &Direction...
code_fim
hard
{ "lang": "rust", "repo": "hershi/AoC2018", "path": "/aoc_13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (rails, mut carts) = read_input(); let mut i = 0; loop { next_tick(&rails, &mut carts); { let crash = carts.iter().filter(|(_,c)| c.direction == Direction::Crash).last(); if let Some((pos, cart)) = crash { println!("Crash at tick {}, ...
code_fim
hard
{ "lang": "rust", "repo": "hershi/AoC2018", "path": "/aoc_13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gadomski/atlas-rs path: /src/magick.rs //! Tools that use ImageMagick. //! //! ImageMagick isn't available on all systems, and [the bindings we //! use](https://github.com/nlfiedler/magick-rust) don't always build out right (e.g. on Travis), //! so we quarentine all ImageMagick stuff in this mod...
code_fim
hard
{ "lang": "rust", "repo": "gadomski/atlas-rs", "path": "/src/magick.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Handler for GifHandler { fn handle(&self, _: &mut Request) -> IronResult<Response> { let gif = self.gif.read().unwrap(); if gif.is_empty() { return Ok(Response::with((status::ServiceUnavailable, "gif is empty"))); } let content_type = "image/gif".parse:...
code_fim
hard
{ "lang": "rust", "repo": "gadomski/atlas-rs", "path": "/src/magick.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let gif = self.gif.read().unwrap(); if gif.is_empty() { return Ok(Response::with((status::ServiceUnavailable, "gif is empty"))); } let content_type = "image/gif".parse::<Mime>().unwrap(); Ok(Response::with((content_type, status::Ok, gif.clone()))) } ...
code_fim
hard
{ "lang": "rust", "repo": "gadomski/atlas-rs", "path": "/src/magick.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamransom/id3 path: /src/frame/header/error.rs use std::error; use std::fmt; use std::io; /// A list specifying the errors that can be encountered when constructing a frame header from a reader. #[derive(Debug)] pub enum Error { /// The size was 0 InvalidSize, /// An error occurred...
code_fim
hard
{ "lang": "rust", "repo": "adamransom/id3", "path": "/src/frame/header/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn cause(&self) -> Option<&error::Error> { match *self { Error::InvalidSize => None, Error::Io(ref err) => Some(err), Error::UnknownFlag => None, } } } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::Io(err...
code_fim
hard
{ "lang": "rust", "repo": "adamransom/id3", "path": "/src/frame/header/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pierrechevalier83/unicode_types path: /src/generated/ipa_extensions.rs nSmallLetterIota, /// \u{26a}: 'ɪ' LatinLetterSmallCapitalI, /// \u{26b}: 'ɫ' LatinSmallLetterLWithMiddleTilde, /// \u{26c}: 'ɬ' LatinSmallLetterLWithBelt, /// \u{26d}: 'ɭ' LatinSmallLetterLWit...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/ipa_extensions.rs", "mode": "psm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|>impl std::convert::TryFrom<char> for IPAExtensions { type Error = (); fn try_from(c: char) -> Result<Self, Self::Error> { match c { 'ɐ' => Ok(IPAExtensions::LatinSmallLetterTurnedA), 'ɑ' => Ok(IPAExtensions::LatinSmallLetterAlpha), 'ɒ' => Ok(IPAExtension...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/ipa_extensions.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_suffix|> match c { 'ɐ' => Ok(IPAExtensions::LatinSmallLetterTurnedA), 'ɑ' => Ok(IPAExtensions::LatinSmallLetterAlpha), 'ɒ' => Ok(IPAExtensions::LatinSmallLetterTurnedAlpha), 'ɓ' => Ok(IPAExtensions::LatinSmallLetterBWithHook), 'ɔ' => Ok(IPAExtensi...
code_fim
hard
{ "lang": "rust", "repo": "pierrechevalier83/unicode_types", "path": "/src/generated/ipa_extensions.rs", "mode": "spm", "license": "LicenseRef-scancode-unicode", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ratijas/mess path: /mess-client/src/gui/control/text_field.rs use imports::*; /// Single line of editable text #[derive(Default)] pub struct TextField { pub buffer: String, /// byte cursor. /// ranges from 0 to `buffer` boundary inclusive. /// `buffer[cursor]` may be an out of ...
code_fim
hard
{ "lang": "rust", "repo": "ratijas/mess", "path": "/mess-client/src/gui/control/text_field.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Responder for TextField { fn handle_event(&mut self, event: Event) -> bool { if let Event::Key(key) = event { match key { Key::Char(ch) => { self.buffer.insert(self.cursor, ch); self.cursor += ch.len_utf8(); ...
code_fim
hard
{ "lang": "rust", "repo": "ratijas/mess", "path": "/mess-client/src/gui/control/text_field.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alwayrun/redox path: /libredox/console.rs use alloc::boxed::*; use core::mem::size_of; use core::ptr; use common::event::*; use common::random::*; use common::string::*; use common::vec::*; use graphics::color::*; use graphics::point::*; use graphics::size::*; use graphics::window::*; use sy...
code_fim
hard
{ "lang": "rust", "repo": "alwayrun/redox", "path": "/libredox/console.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if col >= 0 && col < cols && row >= 0 && row < rows{ content.char(Point::new(8 * col, 16 * row), '#', Color::new(255, 255, 255)); col += 2; } let mut i = 0; for c in self.command.chars(){ if self.wrap && col >...
code_fim
hard
{ "lang": "rust", "repo": "alwayrun/redox", "path": "/libredox/console.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: basavesh/splitspectre path: /secret_integers_usage/src/main.rs use std::io; use simple::*; // pub mod simple; pub mod simple { use rand::Rng; use secret_integers::*; /// classify vector of u8s into U8s fn classify_u8s(v: &[u8]) -> Vec<U8> { <|fim_suffix|>pub fn decrypt(cipher: &[u8], s...
code_fim
hard
{ "lang": "rust", "repo": "basavesh/splitspectre", "path": "/secret_integers_usage/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn encrypt(msg: &[u8], sk: &[U8]) -> Vec<u8> { let mut new_block = [U8::zero(); 8]; let classified_msg = classify_u8s(msg); for i in 0..8 { new_block[i] = classified_msg[i] ^ sk[i]; } return declassify_u8s(&new_block); } pub fn decrypt(cipher: &[u8], sk: &[U8]) -> Vec<u8> ...
code_fim
medium
{ "lang": "rust", "repo": "basavesh/splitspectre", "path": "/secret_integers_usage/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: barigorokarl/newsinboundr path: /src/main.rs extern crate diesel; extern crate dotenv; extern crate select; extern crate newsinboundr_db; use newsinboundr_db::db::models::SourceHttp; use newsinboundr_db::db::schema::NewsSourceType; use newsinboundr_db::create_news; use dotenv::dotenv; use std::...
code_fim
hard
{ "lang": "rust", "repo": "barigorokarl/newsinboundr", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } print!("."); std::result::Result::Ok(()) })); } } if let Some(list) = newsinboundr_db::get_rss_sources(connection_pool.get().unwrap()) { for s in list { let pool = connection_pool.clone...
code_fim
hard
{ "lang": "rust", "repo": "barigorokarl/newsinboundr", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tqn/rslambda path: /src/compiler.rs use crate::lambda::*; pub fn compile(input: &str) -> Result<Exp<String>, String> { // TEMP: one char tokens, ignore whitespace let mut tokens = lex(input); preprocess(&mut tokens); // make tokens immutable let tokens = tokens.iter().map(St...
code_fim
hard
{ "lang": "rust", "repo": "tqn/rslambda", "path": "/src/compiler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn application_explicit() { assert_eq!( compile(r"(x y)").unwrap(), App( Box::new(Var(Ident::free("x".into()))), Box::new(Var(Ident::free("y".into()))) ) ); } #[test] fn many() { assert...
code_fim
hard
{ "lang": "rust", "repo": "tqn/rslambda", "path": "/src/compiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nswbmw/rust-napi-demo path: /src/lib.rs #[macro_use] extern crate napi; #[macro_use] extern crate napi_derive; use napi::{NapiEnv, NapiNumber, NapiResult}; #[derive(NapiArgs)] struct Args<'a> { n: NapiNumber<'a> } fn fibonacci<'a>(env: &'a NapiEnv, args: &Args<'a>) -> NapiResult<NapiNumber<...
code_fim
medium
{ "lang": "rust", "repo": "nswbmw/rust-napi-demo", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>napi_callback!(export_fibonacci, fibonacci); fn _fibonacci(n: i32) -> i32 { match n { 1 | 2 => 1, _ => _fibonacci(n - 1) + _fibonacci(n - 2) } }<|fim_prefix|>// repo: nswbmw/rust-napi-demo path: /src/lib.rs #[macro_use] extern crate napi; #[macro_use] extern crate napi_derive; <|fim_middle|...
code_fim
hard
{ "lang": "rust", "repo": "nswbmw/rust-napi-demo", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g-s-k/stdout path: /main_safe.rs use std::{ io::{self, ErrorKind, Write}, process, }; <|fim_suffix|>fn main() { for _ in 0..200 { print_safe!("hello world\n"); } }<|fim_middle|>macro_rules! print_safe { ($fmt:expr $(, $e:expr)*) => {{ let mut std_out = io::st...
code_fim
hard
{ "lang": "rust", "repo": "g-s-k/stdout", "path": "/main_safe.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..200 { print_safe!("hello world\n"); } }<|fim_prefix|>// repo: g-s-k/stdout path: /main_safe.rs use std::{ io::{self, ErrorKind, Write}, process, }; <|fim_middle|>macro_rules! print_safe { ($fmt:expr $(, $e:expr)*) => {{ let mut std_out = io::stdout(); ...
code_fim
hard
{ "lang": "rust", "repo": "g-s-k/stdout", "path": "/main_safe.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jer3m01/wifistop path: /src/main.rs //! wifistop //! //! ARP spoofing attack //! //! PoC from https://gist.github.com/apsun/4ddc09f40c0c65191b8cdee1e09ba70f use pnet::datalink::{Channel, Config, MacAddr}; use pnet::packet::arp::ArpOperations; use std::collections::HashSet; use std::net::Ipv4Addr...
code_fim
hard
{ "lang": "rust", "repo": "jer3m01/wifistop", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loop { // Send a gratuitous ARP request. If we're pretending to be the gateway, // broadcast it to all hosts in the network. Otherwise, only send it to // the gateway, to prevent other hosts from detecting the attack. for host in targets.iter() { let dest_ma...
code_fim
hard
{ "lang": "rust", "repo": "jer3m01/wifistop", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut looping_num: u32 = num as u32; for i in 0..8 { let i1 = (looping_num & mask) >> 28; let position_char = match i1 { 0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', ...
code_fim
hard
{ "lang": "rust", "repo": "obeis/leetcode-rust-1", "path": "/src/convert_a_number_to_hexadecimal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test1() { assert_eq!("1a".to_string(), Solution::to_hex(26)); } #[test] fn test2() { assert_eq!("0", Solution::to_hex(0)); } #[test] fn test3() { assert_eq!("ffffffff", Solution::to_hex(-1)) } }<|fim_prefix|>// repo: obeis/leetcode-r...
code_fim
hard
{ "lang": "rust", "repo": "obeis/leetcode-rust-1", "path": "/src/convert_a_number_to_hexadecimal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: obeis/leetcode-rust-1 path: /src/convert_a_number_to_hexadecimal.rs use std::ops::{Shl, ShlAssign, Shr}; use std::hint::unreachable_unchecked; /// @number 405 /// @title Convert a Number to Hexadecimal /// @url https://leetcode.com/problems/convert-a-number-to-hexadecimal /// @difficulty easy ...
code_fim
hard
{ "lang": "rust", "repo": "obeis/leetcode-rust-1", "path": "/src/convert_a_number_to_hexadecimal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }