text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>/// Generates ioctl functions. See [`::sys::ioctl`](sys/ioctl/index.html).
#[macro_export]
macro_rules! ioctl {
($(#[$attr:meta])* bad none $name:ident with $nr:expr) => (
$(#[$attr])*
pub unsafe fn $name(fd: $crate::libc::c_int)
-> $crate::Result<$crate::li... | code_fim | hard | {
"lang": "rust",
"repo": "afck/nix",
"path": "/src/sys/ioctl/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afck/nix path: /src/sys/ioctl/mod.rs
and are similar to read and write calls in that regard.
//! They operate on file descriptors and have an identifier that specifies what the ioctl is.
//! Additionally they may read or write data and therefore need to pass along a data pointer.
//! Besides th... | code_fim | hard | {
"lang": "rust",
"repo": "afck/nix",
"path": "/src/sys/ioctl/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afck/nix path: /src/sys/ioctl/mod.rs
ssy. `ioctl` is not fun.
//!
//! What is an `ioctl`?
//! ===================
//!
//! The `ioctl` syscall is the grab-bag syscall on POSIX systems. Don't want to add a new
//! syscall? Make it an `ioctl`! `ioctl` refers to both the syscall, and the commands th... | code_fim | hard | {
"lang": "rust",
"repo": "afck/nix",
"path": "/src/sys/ioctl/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("{}", NUMSTR);
let mut greatest: i64 = 0;
let chars: Vec<char> = NUMSTR.chars().collect();
for i in 0..(NUMSTR.len()-12) {
let mut product: i64 = 1;
for j in 0..13 {
let n: i64 = chars[i+j] as i64 - 0x30;
product *= n;
}
i... | code_fim | medium | {
"lang": "rust",
"repo": "simongarisch/300-Project-Euler",
"path": "/exercises/Ex008/rust_ex008/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simongarisch/300-Project-Euler path: /exercises/Ex008/rust_ex008/src/main.rs
const NUMSTR: &str = "73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
85861560789112949495459501737958331952853208805511\
1254069874715852386305071569329096329522... | code_fim | medium | {
"lang": "rust",
"repo": "simongarisch/300-Project-Euler",
"path": "/exercises/Ex008/rust_ex008/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.io.read_int_at::<E>(pos, nbytes)
}
fn read_f32_at(&self, pos: u64) -> Result<f32> {
self.io.read_f32_at::<E>(pos)
}
fn read_f64_at(&self, pos: u64) -> Result<f64> {
self.io.read_f64_at::<E>(pos)
}
}
impl<I, E: ByteOrder> WriteIntAt for ByteIo<I, E>
wher... | code_fim | hard | {
"lang": "rust",
"repo": "Lasia98/Filecoin",
"path": "/mirrors.ustc.edu.cn-b63e9dae659fc205/positioned-io-0.2.2/src/byteorder/byteio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lasia98/Filecoin path: /mirrors.ustc.edu.cn-b63e9dae659fc205/positioned-io-0.2.2/src/byteorder/byteio.rs
use extbyteorder::ByteOrder;
use extbyteorder::ReadBytesExt as ExtReadBytesExt;
use extbyteorder::WriteBytesExt as ExtWriteBytesExt;
use std::marker::PhantomData;
use std::io::{Result, Read,... | code_fim | hard | {
"lang": "rust",
"repo": "Lasia98/Filecoin",
"path": "/mirrors.ustc.edu.cn-b63e9dae659fc205/positioned-io-0.2.2/src/byteorder/byteio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cih-y2k/quick-patricia-trie path: /src/trie.rs
ition(|(u, v)| u != v);
if let Some(p) = pos {
debug!("extension doesn't start with path nor path starts with extension");
break Action::Extension(extension.clone(), p as u32);
... | code_fim | hard | {
"lang": "rust",
"repo": "cih-y2k/quick-patricia-trie",
"path": "/src/trie.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup();
let mut t = Trie::new();
t.insert(&[0x01u8, 0x23], &[0x01u8, 0x23]);
assert_eq!(t.get(&[0x01, 0x23]), Some([0x01, 0x23].as_ref()));
t.insert(&[0x01u8, 0x23], &[0x23u8, 0x45]);
assert_eq!(t.get(&[0x01, 0x23]), Some([0x23, 0x45].as_ref()));
as... | code_fim | hard | {
"lang": "rust",
"repo": "cih-y2k/quick-patricia-trie",
"path": "/src/trie.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some((u, nibble)) = ext_right.and_then(|n| n.pop_front(&self.arena)) {
let new_key = if nibble.len() == 0 {
// there is no nibble extension so the extension is useless
// and we can directly refer to the nibble key
... | code_fim | hard | {
"lang": "rust",
"repo": "cih-y2k/quick-patricia-trie",
"path": "/src/trie.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let process_mem_usage = process_mem_usage(pid);
let system_mem_usage = system_mem_usage();
println!("====================\nprocess_cpu_usage\t->\t{:?}%\nsystem_cpu_usage\t->\t{}%\nprocess_mem_usage\t->\t{}%\nsystem_mem_usage\t->\t{}%",
process_usage,
system_cpu_usage,
... | code_fim | medium | {
"lang": "rust",
"repo": "aiaoyang/processMonitorWithRust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiaoyang/processMonitorWithRust path: /src/main.rs
#[macro_use]
extern crate lazy_static;
mod cpu;
mod error;
mod mem;
mod read;
use cpu::*;
use mem::*;
fn main() {
let pids = std::env::args().collect::<Vec<String>>();
let pid = pids.get(1).unwrap().as_str();
println!("pid is : {}... | code_fim | medium | {
"lang": "rust",
"repo": "aiaoyang/processMonitorWithRust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheMushrr00m/lumen path: /lumen_runtime/src/otp/erlang/is_process_alive_1.rs
// wasm32 proptest cannot be compiled at the same time as non-wasm32 proptest, so disable tests that
// use proptest completely for wasm32
//
// See https://github.com/rust-lang/cargo/issues/4866
#[cfg(all(not(target_ar... | code_fim | hard | {
"lang": "rust",
"repo": "TheMushrr00m/lumen",
"path": "/lumen_runtime/src/otp/erlang/is_process_alive_1.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match pid_to_process(&pid) {
Some(arc_process) => Ok((!arc_process.is_exiting()).into()),
None => Ok(false.into()),
}
}
}<|fim_prefix|>// repo: TheMushrr00m/lumen path: /lumen_runtime/src/otp/erlang/is_process_alive_1.rs
// wasm32 proptest cannot be compiled at... | code_fim | hard | {
"lang": "rust",
"repo": "TheMushrr00m/lumen",
"path": "/lumen_runtime/src/otp/erlang/is_process_alive_1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: topoi-lang/topoi-core path: /src/lib.rs
pub mod node;
#[cfg(test)]
mod tests {
use crate::node::*;
use crate::node::Node::*;
#[test]
fn atom_cmp() {
assert_eq!(Atom("ratatouille"), Atom("ratatouille"));
assert_ne!(Atom("ratatouille"), Atom("baguette"))
}
... | code_fim | hard | {
"lang": "rust",
"repo": "topoi-lang/topoi-core",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn list_cdr() {
use crate::node::cdr;
assert_eq!(
cdr(vec![Atom("ratatouille"), Atom("baguette")]),
List(vec![Atom("baguette")])
);
assert_eq!(
cdr(vec![
Atom("ratatouille"),
Atom("baguette... | code_fim | medium | {
"lang": "rust",
"repo": "topoi-lang/topoi-core",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RemiliaForever/RemiMagicBook path: /data_structure/tests/singly_linked_list.rs
extern crate data_structure;
use data_structure::SinglyLinkedList;
#[test]
fn test_next() {
let mut list = SinglyLinkedList::new();
let head = &mut list;
for i in 0..10 {
head.insert(i);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "RemiliaForever/RemiMagicBook",
"path": "/data_structure/tests/singly_linked_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut list = SinglyLinkedList::new();
let head = &mut list;
for i in 0..10 {
head.insert(i);
}
assert_eq!(
"(start)->(9)->(8)->(7)->(6)->(5)->(4)->(3)->(2)->(1)->(0)",
format!("{:?}", list)
);
}
#[test]
fn test_delete() {
let mut list = SinglyLinkedLi... | code_fim | medium | {
"lang": "rust",
"repo": "RemiliaForever/RemiMagicBook",
"path": "/data_structure/tests/singly_linked_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /execution_engine/src/core/runtime/args.rs
use wasmi::{FromRuntimeValue, RuntimeArgs, Trap};
pub(crate) trait Args
where
Self: Sized,
{
fn parse(args: RuntimeArgs) -> Result<Self, Trap>;
}
impl<T1> Args for (T1,)
where
T1: FromRuntimeValue +... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/execution_engine/src/core/runtime/args.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T1, T2, T3, T4, T5, T6> Args for (T1, T2, T3, T4, T5, T6)
where
T1: FromRuntimeValue + Sized,
T2: FromRuntimeValue + Sized,
T3: FromRuntimeValue + Sized,
T4: FromRuntimeValue + Sized,
T5: FromRuntimeValue + Sized,
T6: FromRuntimeValue + Sized,
{
fn parse(args: RuntimeArgs)... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/execution_engine/src/core/runtime/args.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-leonardodalinky-daily path: /rust-exercise/p/p39/src/main.rs
// Exercise 39: Dictionaries
use std::collections::HashMap;
<|fim_suffix|> let mut hm = HashMap::new();
hm.insert(1i32, "Hello".to_string());
hm.insert(0i32, "World".to_string());
hm.insert(1... | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-leonardodalinky-daily",
"path": "/rust-exercise/p/p39/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hm = HashMap::new();
hm.insert(1i32, "Hello".to_string());
hm.insert(0i32, "World".to_string());
hm.insert(1i32, "Replace".to_string());
for (i, s) in hm.iter() {
println!("Index: {}, Value: {}", i, s);
}
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-leonardoda... | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-leonardodalinky-daily",
"path": "/rust-exercise/p/p39/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeraldgan/rust-primer path: /05-match-result/exercise/src/main.rs
fn main() {
println!("Hello, world!");
}
#[derive(Debug, PartialEq)]
enum Sculpture {
Bunny,
Teapot,
}
fn parse_value(input: &str) -> Sculpture {
<|fim_suffix|> assert_eq!(parse_value("bunny"), Some(Sculpture:... | code_fim | medium | {
"lang": "rust",
"repo": "jeraldgan/rust-primer",
"path": "/05-match-result/exercise/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_using_optional() {
let wrapper = Some("value");
let value = wrapper;
assert_eq!(value, "value");
}
}<|fim_prefix|>// repo: jeraldgan/rust-primer path: /05-match-result/exercise/src/main.rs
fn main() {
println!("Hello, world!");
}
#[derive(Debug, Pa... | code_fim | hard | {
"lang": "rust",
"repo": "jeraldgan/rust-primer",
"path": "/05-match-result/exercise/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if matches.is_present("auto") {
let default_profile = matches.value_of("default-profile");
quickrandr::cmd_auto(&config_path, default_profile, debug);
return;
}
if matches.is_present("create-empty") {
quickrandr::cmd_create_empty(&config_path, debug);
r... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/quickrandr",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kimundi/quickrandr path: /src/main.rs
extern crate quickrandr;
extern crate clap;
use clap::{Arg, App, ArgGroup};
fn main() {
let matches = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
... | code_fim | hard | {
"lang": "rust",
"repo": "Kimundi/quickrandr",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sum = 0;
for line in lines {
let value = line.parse::<i64>()?;
let mut result = value / 3 - 2;
let mut new_mass = result / 3 - 2;
loop {
result += new_mass;
new_mass = new_mass / 3 - 2;
... | code_fim | hard | {
"lang": "rust",
"repo": "i300/AdventOfCode2019",
"path": "/src/days/one.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: i300/AdventOfCode2019 path: /src/days/one.rs
use crate::days::Day;
use crate::Result;
pub struct One {
filename: &'static str
}
impl One {
pub fn new(filename: &'static str) -> One {
One { filename }
}
}
impl Day for One {
fn run(&self) -> Result<String> {
<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "i300/AdventOfCode2019",
"path": "/src/days/one.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut new_mass = result / 3 - 2;
loop {
result += new_mass;
new_mass = new_mass / 3 - 2;
if new_mass <= 0 {
break;
}
}
sum += result;
}
Ok(sum... | code_fim | hard | {
"lang": "rust",
"repo": "i300/AdventOfCode2019",
"path": "/src/days/one.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacemeshos/smart-contract-experiment path: /crates/sm-alloc/src/lib.rs
#[macro_use]
extern crate cfg_if;
cfg_if! {
if #[cfg(test)] {
in<|fim_suffix|>
include!("no_std.rs");
}
}<|fim_middle|>clude!("with_std.rs");
}
else { | code_fim | easy | {
"lang": "rust",
"repo": "spacemeshos/smart-contract-experiment",
"path": "/crates/sm-alloc/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
include!("no_std.rs");
}
}<|fim_prefix|>// repo: spacemeshos/smart-contract-experiment path: /crates/sm-alloc/src/lib.rs
#[macro_use]
extern crate cfg_if;
cfg<|fim_middle|>_if! {
if #[cfg(test)] {
include!("with_std.rs");
}
else { | code_fim | medium | {
"lang": "rust",
"repo": "spacemeshos/smart-contract-experiment",
"path": "/crates/sm-alloc/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TryFrom<Literal> for String {
type Error = &'static str;
fn try_from(value: Literal) -> Result<Self, Self::Error> {
match value {
Literal::String(s) => Ok(s),
_ => Err("Not a String"),
}
}
}
impl TryFrom<Literal> for bool {
type Error = &'stati... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/apply",
"path": "/parser/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Directive::Srid(arg)
}
}
// impl From<Extent> for Directive {
// fn from(arg: Extent) -> Self {
// Directive::Extent(arg)
// }
// }
impl From<Data> for Directive {
fn from(arg: Data) -> Self {
Directive::Data(arg)
}
}
impl From<Sym> for Directive {
fn fro... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/apply",
"path": "/parser/src/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pierremarc/apply path: /parser/src/ast.rs
use std::{convert::TryFrom, fmt};
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum Num {
Integer(i64),
Float(f64),
}
impl fmt::Display for Num {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
... | code_fim | hard | {
"lang": "rust",
"repo": "pierremarc/apply",
"path": "/parser/src/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let date = NaiveDate::from_ymd_opt(2020, 1, 31).unwrap();
let o_clock = NaiveTime::from_hms_opt(1, 2, 3).unwrap();
let base = NaiveDateTime::new(date, o_clock);
assert_eq!(
shift_months(base, 0).date(),
NaiveDate::from_ymd_opt(2020, 1, 31).unwrap()... | code_fim | hard | {
"lang": "rust",
"repo": "andygrove/arrow-rs",
"path": "/arrow-array/src/delta.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andygrove/arrow-rs path: /arrow-array/src/delta.rs
// MIT License
//
// Copyright (c) 2020-2022 Oliver Margetts
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software w... | code_fim | hard | {
"lang": "rust",
"repo": "andygrove/arrow-rs",
"path": "/arrow-array/src/delta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>trait Foo {
type Bar<'a>;
type Bar<'a, 'b>;
type Bar<'a, 'b,>;
type Bar<'a, 'b, T>;
type Bar<'a, 'b, T, U>;
type Bar<'a, 'b, T, U,>;
type Bar<'a, 'b, T: Debug, U,>;
type Bar<'a, 'b, T: Debug, U,>: Debug;
type Bar<'a, 'b, T: Debug, U,>: Deref<Target = T> + Into<U>;
t... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs
// build-pass (FIXME(62277): could be check-pass?)
// compile-flags: -Z parse-only
<|fim_suffix|>trait Foo {
type Bar<'a>;
type Bar<'a, 'b>;
type Bar<'a, 'b,>;
type Bar<'a, 'b, ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfc1598-generic-associated-types/parse/in-trait.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acikek/jage path: /src/input/handler.rs
use super::super::data::data::GameData;
use super::super::data::entity::PlayerStatus;
use super::super::data::location::LocationType;
use super::args::Args;
use super::controller::InputController;
pub fn handler(game: &mut GameData, input: &mut InputCont... | code_fim | hard | {
"lang": "rust",
"repo": "acikek/jage",
"path": "/src/input/handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match game.location().l_type {
Town(_) | City(_) | Capital(_) => {
game.visit(input);
Ok(())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "acikek/jage",
"path": "/src/input/handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mligor/hap-rs path: /src/characteristic/generated/model.rs
// THIS FILE IS AUTO-GENERATED
use crate::characteristic::{Characteristic, Format, HapType, Inner, Perm};
<|fim_suffix|>/// Creates a new Model Characteristic.
pub fn new() -> Model {
Characteristic::new(Inner::<String> {
h... | code_fim | medium | {
"lang": "rust",
"repo": "mligor/hap-rs",
"path": "/src/characteristic/generated/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates a new Model Characteristic.
pub fn new() -> Model {
Characteristic::new(Inner::<String> {
hap_type: HapType::Model,
format: Format::String,
perms: vec![Perm::PairedRead],
..Default::default()
})
}<|fim_prefix|>// repo: mligor/hap-rs path: /src/character... | code_fim | medium | {
"lang": "rust",
"repo": "mligor/hap-rs",
"path": "/src/characteristic/generated/model.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: buratina/Network-Programming-with-Rust path: /Chapter02/syntactic-macro.rs
#![feature(trace_macros)]
trace_macros!(true);
macro_rules! factorial {
($x:expr) => {
{
let mut result = 1;
for i in 1..($x+1) {
result = result * i;
}
... | code_fim | easy | {
"lang": "rust",
"repo": "buratina/Network-Programming-with-Rust",
"path": "/Chapter02/syntactic-macro.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let arg = std::env::args().nth(1).expect("Please provide only one argument");
println!("{:?}", factorial!(arg.parse::<u64>().expect("Could not parse to an integer")));
}<|fim_prefix|>// repo: buratina/Network-Programming-with-Rust path: /Chapter02/syntactic-macro.rs
#![feature(trace_m... | code_fim | hard | {
"lang": "rust",
"repo": "buratina/Network-Programming-with-Rust",
"path": "/Chapter02/syntactic-macro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bastion-rs/agnostik path: /tests/asyncstd.rs
pub use agnostik::prelude::*;
#[cfg(feature = "runtime_asyncstd")]
#[test]
fn test_async_std() {
let agnostik = Agnostik::async_std();
<|fim_suffix|> let res = agnostik::block_on(async {
agnostik::spawn(async {
println!("h... | code_fim | hard | {
"lang": "rust",
"repo": "bastion-rs/agnostik",
"path": "/tests/asyncstd.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = agnostik::block_on(async {
agnostik::spawn(async {
println!("hello world");
1
})
.await
});
assert_eq!(res, 1);
}<|fim_prefix|>// repo: bastion-rs/agnostik path: /tests/asyncstd.rs
pub use agnostik::prelude::*;
#[cfg(feature = "runtim... | code_fim | medium | {
"lang": "rust",
"repo": "bastion-rs/agnostik",
"path": "/tests/asyncstd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chops76/AoC2018 path: /src/day25.rs
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::time::Instant;
use std::collections::HashSet;
type Point = (i64, i64, i64,i64);
type Input = Vec<Point>;
fn parse_line(s: &str) -> Point {
let spl = s.split(",").collect::<Vec<&str>>();
<|fim_s... | code_fim | medium | {
"lang": "rust",
"repo": "chops76/AoC2018",
"path": "/src/day25.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_input(path: &str) -> Input {
let f = File::open(path).unwrap();
BufReader::new(f).lines().flatten().map(|s| parse_line(&s)).collect()
}
fn close(p1: &Point, p2: &Point) -> bool {
(p1.0-p2.0).abs() + (p1.1-p2.1).abs() + (p1.2-p2.2).abs() + (p1.3-p2.3).abs() <= 3
}
fn part1(points: &Input) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "chops76/AoC2018",
"path": "/src/day25.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebagos/rust path: /p004/src/main.rs
/*
左右どちらから読んでも同じ値になる数を回文数という.
2桁の数の積で表される回文数のうち, 最大のものは 9009 = 91 × 99 である.
では, 3桁の数の積で表される回文数の最大値を求めよ.
*/
fn main() {
<|fim_suffix|>fn kai() -> i32 {
let mut rc = 0;
for i in (100..1000).rev() {
for j in (i..1000).rev() {
le... | code_fim | medium | {
"lang": "rust",
"repo": "ebagos/rust",
"path": "/p004/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rc = 0;
for i in (100..1000).rev() {
for j in (i..1000).rev() {
let m = i * j;
if rc > m {break;}
let s = m.to_string();
if s == s.chars().rev().collect::<String>() {
rc = m;
break;
}
... | code_fim | medium | {
"lang": "rust",
"repo": "ebagos/rust",
"path": "/p004/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", kai());
}
fn kai() -> i32 {
let mut rc = 0;
for i in (100..1000).rev() {
for j in (i..1000).rev() {
let m = i * j;
if rc > m {break;}
let s = m.to_string();
if s == s.chars().rev().collect::<String>() {
rc ... | code_fim | medium | {
"lang": "rust",
"repo": "ebagos/rust",
"path": "/p004/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
if n == 0 {
break;
}
if let Some(start_at) = repeats.get(&n).cloned() {
decimal_parts.push(b'(');
(&mut decimal_parts[start_at..].rotate_right(1));
decimal_parts.push(b')');
... | code_fim | hard | {
"lang": "rust",
"repo": "dtynn/learning",
"path": "/leetcode-rs/p0166_fraction_to_recurring_decimal/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtynn/learning path: /leetcode-rs/p0166_fraction_to_recurring_decimal/src/lib.rs
pub struct Solution {}
use std::collections::HashMap;
impl Solution {
pub fn fraction_to_decimal(numerator: i32, denominator: i32) -> String {
if numerator == 0 {
return "0".to_owned();
... | code_fim | hard | {
"lang": "rust",
"repo": "dtynn/learning",
"path": "/leetcode-rs/p0166_fraction_to_recurring_decimal/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Graph { graph }
}
fn solve(&self, start_nodes: &[SquareType]) -> i32 {
let mut priority_queue: BinaryHeap<SearchNode> = BinaryHeap::new();
priority_queue.push(Reverse((0, start_nodes.to_vec(), start_nodes.to_vec())));
//nodes_visited keeps track of a node + keyset... | code_fim | hard | {
"lang": "rust",
"repo": "SeerSkye/aoc-2019",
"path": "/src/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SeerSkye/aoc-2019 path: /src/day18.rs
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::fs;
use std::ops::{Add, Sub};
pub fn day_18() {
let input = fs::read_to_string("input/day18.txt").expect("Could not read file!");
let board = Board::boa... | code_fim | hard | {
"lang": "rust",
"repo": "SeerSkye/aoc-2019",
"path": "/src/day18.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> messages
.lines()
.filter(|l| matches!(rule_0.parse(l, &rules), Some("")))
.count()
}
#[aoc(day19, part2)]
pub fn solve_part2(input: &str) -> usize {
let mut parts = input.split("\n\n");
let rules = parse_rules(
&parts
.next()
... | code_fim | hard | {
"lang": "rust",
"repo": "charlespierce/advent-code-2020",
"path": "/src/day19.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: charlespierce/advent-code-2020 path: /src/day19.rs
use aoc_runner_derive::aoc;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{anychar, digit1, space0};
use nom::combinator::map;
use nom::multi::many1;
use nom::sequence::{delimited, preceded, separated_p... | code_fim | hard | {
"lang": "rust",
"repo": "charlespierce/advent-code-2020",
"path": "/src/day19.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oil-lang/oil-rs path: /shared/src/lib.rs
#![feature(plugin)]
#![plugin(phf_macros)]
<|fim_suffix|>pub mod asset;
pub mod resource;
pub mod style;
pub mod deps;
pub mod markup;
pub mod properties;<|fim_middle|>extern crate phf;
| code_fim | easy | {
"lang": "rust",
"repo": "oil-lang/oil-rs",
"path": "/shared/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod asset;
pub mod resource;
pub mod style;
pub mod deps;
pub mod markup;
pub mod properties;<|fim_prefix|>// repo: oil-lang/oil-rs path: /shared/src/lib.rs
#![feature(plugin)]
#![plugin(phf_macros)]
<|fim_middle|>extern crate phf;
| code_fim | easy | {
"lang": "rust",
"repo": "oil-lang/oil-rs",
"path": "/shared/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bzm3r/rust-ncc path: /simulator/src/parameters/quantity.rs
// Copyright © 2020 Brian Merchant.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your... | code_fim | hard | {
"lang": "rust",
"repo": "bzm3r/rust-ncc",
"path": "/simulator/src/parameters/quantity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn kilo(&self) -> Self {
self.scale(1e3)
}
fn micro(&self) -> Self {
self.scale(1e-6)
}
fn nano(&self) -> Self {
self.scale(1e-9)
}
fn number(&self) -> f64 {
self.0
}
fn units(&self) -> Units {
Units::stress()
}
fn g(... | code_fim | hard | {
"lang": "rust",
"repo": "bzm3r/rust-ncc",
"path": "/simulator/src/parameters/quantity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Omen-of-Aecio/metac path: /lib.rs
parse(line, &mut data).unwrap();
assert_eq!(4, data.len());
assert_eq!(Data::Atom("Set"), data[0]);
assert_eq!(Data::Atom("Log"), data[1]);
assert_eq!(Data::Atom("Level"), data[2]);
assert_eq!(Data::Command(" 0"), dat... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/metac",
"path": "/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn interpret_empty() {
struct Eval {
pub invoked: usize,
}
impl Evaluate<()> for Eval {
fn evaluate<'a>(&mut self, _: &[Data<'a>]) {
self.invoked += 1;
}
}
let mut eval = Eval { invoked: 0 };
... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/metac",
"path": "/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line = "2";
eval.interpret_single(line).unwrap();
eval.interpret_multiple(line).unwrap();
assert_eq!(2, eval.invoked);
}
#[test]
fn interpret_multiple_simple() {
struct Eval {
pub invoked: usize,
}
impl Evaluate<()> for ... | code_fim | hard | {
"lang": "rust",
"repo": "Omen-of-Aecio/metac",
"path": "/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: learnmonitoring/ragent path: /src/reboot.rs
use std::path::Path;
#[derive(Debug, Serialize, Deserialize<|fim_suffix|>fn get_reboot() -> Reboot {
Reboot {
reboot_required: Path::new("/var/run/reboot-required").exists(),
}
}<|fim_middle|>)]
pub struct Reboot {
pub reboot_requi... | code_fim | medium | {
"lang": "rust",
"repo": "learnmonitoring/ragent",
"path": "/src/reboot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ired: Path::new("/var/run/reboot-required").exists(),
}
}<|fim_prefix|>// repo: learnmonitoring/ragent path: /src/reboot.rs
use std::path::Path;
#[derive(Debug, Serialize, Deserialize<|fim_middle|>)]
pub struct Reboot {
pub reboot_required: bool,
}
pub fn get_reboot() -> Reboot {
Reboot {
... | code_fim | medium | {
"lang": "rust",
"repo": "learnmonitoring/ragent",
"path": "/src/reboot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn into_mut(self) -> *mut P {
let ptr = self.inner.as_ptr();
mem::forget(self);
ptr
}
pub fn into_ref<'p>(&self) -> RefCtr<'p, P> {
RefCtr::new(self.inner.clone())
}
}
pub struct RefCtr<'p, P>{
inner: NonNull<P>,
_lifetime: PhantomData<&'p ()>... | code_fim | hard | {
"lang": "rust",
"repo": "ZerothLaw/mscoree-rs",
"path": "/mscoree_safe/src/wrappers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
//Wrapper for heap-allocated memory,
// Invariant: value is non-null and constructed
#[derive(Debug, PartialEq)]
pub struct PtrCtr<P> {
inner: NonNull<P>
}
#[derive(Debug, PartialEq)]
pub enum WrapperErrors {
IsNull
}
impl<P> PtrCtr<P> {
#[must_use]
pub fn new_checked(p: *mut P) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "ZerothLaw/mscoree-rs",
"path": "/mscoree_safe/src/wrappers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZerothLaw/mscoree-rs path: /mscoree_safe/src/wrappers.rs
// wrappers.rs - MIT License
// MIT License
// Copyright (c) 2018 Tyler Laing (ZerothLaw)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "... | code_fim | hard | {
"lang": "rust",
"repo": "ZerothLaw/mscoree-rs",
"path": "/mscoree_safe/src/wrappers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Point3f {
pub fn as_local(self) -> LocalPoint3f {
LocalPoint3f::new(self.x, self.y, self.z)
}
}<|fim_prefix|>// repo: johannesvollmer/iris path: /src/math/point3.rs
use super::{LocalPoint3f, Vec3f};
<|fim_middle|>define_point!(Point3f, Vec3f);
| code_fim | easy | {
"lang": "rust",
"repo": "johannesvollmer/iris",
"path": "/src/math/point3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannesvollmer/iris path: /src/math/point3.rs
use super::{LocalPoint3f, Vec3f};
<|fim_suffix|>impl Point3f {
pub fn as_local(self) -> LocalPoint3f {
LocalPoint3f::new(self.x, self.y, self.z)
}
}<|fim_middle|>define_point!(Point3f, Vec3f);
| code_fim | easy | {
"lang": "rust",
"repo": "johannesvollmer/iris",
"path": "/src/math/point3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saturn-xiv/peony path: /src/plugins/ops/cron/mod.rs
pub mod models;
pub mod schema;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Component, Path};
<|fim_suffix|> let file = Path::new(&Component::RootDir)
.join("etc")
.join("cron.d")
.jo... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/peony",
"path": "/src/plugins/ops/cron/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = Path::new(&Component::RootDir)
.join("etc")
.join("cron.d")
.join(name);
debug!("write crontab into {}", file.display());
let mut file = File::open(&file)?;
for it in TaskDao::all(db)? {
writeln!(file, "{}", it)?;
... | code_fim | medium | {
"lang": "rust",
"repo": "saturn-xiv/peony",
"path": "/src/plugins/ops/cron/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! match_opcodes {
($value:expr; $($rest:tt)*) => {
loop {
let value = $value;
match_opcodes!(@branches{value} $($rest)*);
unimplemented!("Unknown opcode: {:X}", value);
}
};
(@branches{$value:expr} noarg $opcode:... | code_fim | hard | {
"lang": "rust",
"repo": "Epsylon42/Chip8",
"path": "/src/system/opcode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Epsylon42/Chip8 path: /src/system/opcode.rs
#[derive(Clone, Copy)]
#[repr(u16)]
pub enum Opcode {
ClearScreen = 0x00E0, //
Return = 0x00EE, //
Jump = 0x1000, //
Call = 0x2000, //
SkipIfEq = 0x3000, //
SkipIfNeq = 0x4000, //
SkipIfRegEq = 0x5000, //
SetReg = 0x6... | code_fim | hard | {
"lang": "rust",
"repo": "Epsylon42/Chip8",
"path": "/src/system/opcode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Opcode::Jump |
Opcode::Call |
Opcode::SkipIfEq |
Opcode::SkipIfNeq |
Opcode::SetReg |
Opcode::SAddReg |
Opcode::SetIndex |
Opcode::JumpPlus |
Opcode::Rand |
Opcode::Draw => code & 0xF000... | code_fim | hard | {
"lang": "rust",
"repo": "Epsylon42/Chip8",
"path": "/src/system/opcode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!("Successfully decoded the config file");
let metrics:u64 = m.value_of("metrics").unwrap_or("500000")
.parse().unwrap();
let window:usize = m.value_of("window").unwrap_or("1000")
.parse().unwrap();
apollo::client::start(
&config, metrics, window).awai... | code_fim | hard | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/examples/apollo/client/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libdist-rs/libchatter-rs path: /examples/apollo/client/src/main.rs
use clap::{load_yaml, App};
use config::Client;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let yaml = load_yaml!("cli.yml");
let m = App::from_yaml(yaml).get_matches();
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/examples/apollo/client/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quininer/rustcode path: /oj/hdu-1270/src/main.rs
//! https://vjudge.net/problem/HDU-1270
extern crate z3_sys;
use std::ffi::CString;
use z3_sys::*;
fn solver(n: usize, result: &[i32]) -> Vec<i32> {
unsafe {
let cfg = Z3_mk_config();
let ctx = Z3_mk_context(cfg);
l... | code_fim | hard | {
"lang": "rust",
"repo": "quininer/rustcode",
"path": "/oj/hdu-1270/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Z3_del_context(ctx);
Z3_del_config(cfg);
output
}
}
fn main() {
let n = 4;
let results = [4, 5, 7, 10, 12, 13];
let output = solver(n, &results);
println!("{:?}", output);
}<|fim_prefix|>// repo: quininer/rustcode path: /oj/hdu-1270/src/main.rs
//! https:... | code_fim | hard | {
"lang": "rust",
"repo": "quininer/rustcode",
"path": "/oj/hdu-1270/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> m.add_wrapped(wrap_pyfunction!(cosine))?;
Ok(())
}<|fim_prefix|>// repo: VanillaBrooks/instagram_scrape path: /rust/src/lib.rs
mod main;
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
fn cosine(original_phrases: Vec<String>, compared_phrases: Vec<String>, thread_count: usize) -> Py... | code_fim | medium | {
"lang": "rust",
"repo": "VanillaBrooks/instagram_scrape",
"path": "/rust/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VanillaBrooks/instagram_scrape path: /rust/src/lib.rs
mod main;
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
fn cosine(original_phrases: Vec<String>, compared_phrases: Vec<String>, thread_count: usize) -> PyResult<f32> {
<|fim_suffix|> m.add_wrapped(wrap_pyfunction!(cosine)... | code_fim | medium | {
"lang": "rust",
"repo": "VanillaBrooks/instagram_scrape",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Deserialize, OcamlRep, Serialize)]
pub struct Decls {
pub classes: s_map::SMap<shallow_decl_defs::ShallowClass>,
pub funs: s_map::SMap<typing_defs::FunElt>,
pub typedefs: s_map::SMap<typing_defs::TypedefType>,
pub consts: s_map::SMap<typing_defs::DeclTy>,
}<|fim_pref... | code_fim | medium | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/oxidized/gen/direct_decl_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/oxidized/gen/direct_decl_parser.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<ec911a340051c... | code_fim | medium | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/oxidized/gen/direct_decl_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShadowsNetwork/polkadot-ethereum path: /parachain/primitives/xcm-support/src/lib.rs
//! # XCMP Support
//!
//! Includes an implementation for the `TransactAsset` trait, thus enabling
//! withdrawals and deposits to assets via XCMP message execution.
#![cfg_attr(not(feature = "std"), no_std)]
u... | code_fim | hard | {
"lang": "rust",
"repo": "ShadowsNetwork/polkadot-ethereum",
"path": "/parachain/primitives/xcm-support/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = DOT::deposit_creating(&who, value);
Ok(())
},
// Deposit ETH
MultiLocation::X2(
Junction::PalletInstance { id: 0 },
Junction::GeneralIndex { id: 0 },
) => {
let value: U256 = amount.into();
BridgedAssets::deposit(AssetId::ETH, &who, value).map_err(|_| XcmError::... | code_fim | hard | {
"lang": "rust",
"repo": "ShadowsNetwork/polkadot-ethereum",
"path": "/parachain/primitives/xcm-support/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const MINIMAL_KERNEL_VERSION: f32 = 4.8;
pub fn check_linux_version() -> Result<(), Errcode> {
let host = uname();
log::debug!("Linux release: {}", host.release());
log::debug!("{} {} {}", host.version(), host.machine(), host.nodename());
if let Ok(version) = scan_fmt!(host.release()... | code_fim | hard | {
"lang": "rust",
"repo": "m0riiiii/rust_practice",
"path": "/crabcan/src/container.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m0riiiii/rust_practice path: /crabcan/src/container.rs
use crate::cli::Args;
use crate::errors::Errcode;
use crate::config::ContainerOpts;
use crate::child::generate_child_process;
use crate::mounts::clean_mounts;
use nix::sys::utsname::uname;
use nix::sys::wait::waitpid;
use nix::unistd::{clos... | code_fim | hard | {
"lang": "rust",
"repo": "m0riiiii/rust_practice",
"path": "/crabcan/src/container.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn start(args: Args) -> Result<(), Errcode> {
check_linux_version()?;
let mut container = Container::new(args)?;
if let Err(e) = container.create() {
container.clean_exit()?;
log::error!("Error while creating container: {:?}", e);
return Err(e);
}
log::debug... | code_fim | hard | {
"lang": "rust",
"repo": "m0riiiii/rust_practice",
"path": "/crabcan/src/container.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cmdr3nder/advent-of-code-2017 path: /src/days/day_5.rs
use util::files::read_file_to_string;
pub fn main() {
println!("-- Running Day 5 --");
let input = &read_file_to_string("src/days/input/day_5.txt");
println!("It took {} steps to jump out.", count_steps_to_jump_out(input, calc_... | code_fim | hard | {
"lang": "rust",
"repo": "Cmdr3nder/advent-of-code-2017",
"path": "/src/days/day_5.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn calc_jump_with_logic(jump: isize) -> isize {
if jump >= 3 {
jump - 1
} else {
jump + 1
}
}<|fim_prefix|>// repo: Cmdr3nder/advent-of-code-2017 path: /src/days/day_5.rs
use util::files::read_file_to_string;
pub fn main() {
println!("-- Running Day 5 --");
let input ... | code_fim | hard | {
"lang": "rust",
"repo": "Cmdr3nder/advent-of-code-2017",
"path": "/src/days/day_5.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while index >= 0 && index < instructions.len() as isize {
let jump = instructions[index as usize];
instructions[index as usize] = calc_jump(jump);
index = index + jump;
count = count + 1;
}
count
}
fn calc_jump_as_simple_increment(jump: isize) -> isize {
j... | code_fim | hard | {
"lang": "rust",
"repo": "Cmdr3nder/advent-of-code-2017",
"path": "/src/days/day_5.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if root.is_none() {
return 0
}
let root = root.as_ref().unwrap();
let root = root.borrow();
let v = root.val as i64;
let m = v * (parent - v);
let left = max_product(&root.left, parent);
let right = max_product(&root.right, parent);
left.max(right).max(m)
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/1339_max_product.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/1339_max_product.rs
const M: i64 = 1_000_000_007;
use std::rc::Rc;
use std::cell::RefCell;
impl Solution {
pub fn max_product(mut root: Option<Rc<RefCell<TreeNode>>>) -> i32 {
let s = sum_node(&mut root) as i64;
let r = max_product(&roo... | code_fim | medium | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/1339_max_product.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// MISSING DOCUMENTATION!!!
#[prost(message, optional, tag="2")]
pub breaker: ::std::option::Option<Breaker>,
/// MISSING DOCUMENTATION!!!
#[prost(message, repeated, tag="3")]
pub breaker_reading: ::std::vec::Vec<BreakerReading>,
/// MISSING DOCUMENTATION!!!
#[prost(message,... | code_fim | hard | {
"lang": "rust",
"repo": "tupshin/openfmb-ops-protobuf-shuntbranch",
"path": "/src/openfmb/breakermodule.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tupshin/openfmb-ops-protobuf-shuntbranch path: /src/openfmb/breakermodule.rs
use serde::{Serialize,Deserialize};
/// OpenFMB specialization for BreakerDiscreteControlProfile: Added blk LN: Circuit breaker Name:
/// XCBR
#[derive(Clone, PartialEq, ::prost::Message, Serialize, Deserialize)]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "tupshin/openfmb-ops-protobuf-shuntbranch",
"path": "/src/openfmb/breakermodule.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Structural,Clone)]
#[struc(public)]
struct Privacies0{
a:u32,
b:u32,
#[struc(private)]
c:u32,
}
#[derive(Structural,Clone)]
//#[struc(debug_print)]
struct Privacies1{
pub a:u32,
pub b:u32,
#[struc(not_public)]
pub c:u32,
d:u32,
#[struc(public)]
e:u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/structural_crates",
"path": "/structural/src/tests/structural_derive.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RalfJung/structural_crates path: /structural/src/tests/structural_derive.rs
use crate::{
structural_trait::{accessor_names,FieldInfo},
GetField,GetFieldMut,IntoField,IntoFieldMut,
GetFieldExt,
GetFieldType,
Structural,
StructuralDyn,
};
#[cfg(feature="alloc")]
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/structural_crates",
"path": "/structural/src/tests/structural_derive.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut outskirts = self.outskirts.clone();
let mut step = 0;
let mut steps: Vec<(Outskirts, i32)> = Vec::new();
let cycle_length = loop {
outskirts = outskirts.step();
step = step + 1;
let found = steps.iter().find(|(other, _)| {
... | code_fim | hard | {
"lang": "rust",
"repo": "plaflamme/advent-2018",
"path": "/src/puzzle18/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plaflamme/advent-2018 path: /src/puzzle18/mod.rs
use std::collections::HashMap;
use std::fmt::{Display, Formatter, Error};
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy, Clone)]
struct Pt {
x: i16,
y: i16
}
impl Pt {
fn new(x: i16, y: i16) -> Pt { Pt {x, y} }
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "plaflamme/advent-2018",
"path": "/src/puzzle18/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.