text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: smithhmark/splendiforust path: /src/main.rs
fn greeting() -> &'static str {
"Hello, world"
}
<|fim_suffix|> #[test]
fn correct_greeting() {
assert_eq!(greeting(), "Hello, world");
}
}<|fim_middle|>fn main() {
println!("{}", greeting());
}
#[cfg(test)]
mod tests {
... | code_fim | medium | {
"lang": "rust",
"repo": "smithhmark/splendiforust",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(greeting(), "Hello, world");
}
}<|fim_prefix|>// repo: smithhmark/splendiforust path: /src/main.rs
fn greeting() -> &'static str {
"Hello, world"
}
<|fim_middle|>fn main() {
println!("{}", greeting());
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn corre... | code_fim | medium | {
"lang": "rust",
"repo": "smithhmark/splendiforust",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bench_fft! {
size_1024: 1024
size_2048: 2048
size_4096: 4096
}
criterion_group!(fft_benches, size_1024, size_2048, size_4096);
criterion_main!(fft_benches);<|fim_prefix|>// repo: timothycobrien/numlib path: /benches/bignum/utils/fft.rs
#[macro_use]
extern crate criterion;
extern crate numlib... | code_fim | hard | {
"lang": "rust",
"repo": "timothycobrien/numlib",
"path": "/benches/bignum/utils/fft.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion_group!(fft_benches, size_1024, size_2048, size_4096);
criterion_main!(fft_benches);<|fim_prefix|>// repo: timothycobrien/numlib path: /benches/bignum/utils/fft.rs
#[macro_use]
extern crate criterion;
extern crate numlib;
use criterion::Criterion;
use numlib::_fft;
macro_rules! bench_fft {
... | code_fim | hard | {
"lang": "rust",
"repo": "timothycobrien/numlib",
"path": "/benches/bignum/utils/fft.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timothycobrien/numlib path: /benches/bignum/utils/fft.rs
#[macro_use]
extern crate criterion;
extern crate numlib;
use criterion::Criterion;
use numlib::_fft;
<|fim_suffix|> c.bench_function(concat!("Bignum_", $size, "_utils_fft"), |b| {
b.iter(|| {
... | code_fim | medium | {
"lang": "rust",
"repo": "timothycobrien/numlib",
"path": "/benches/bignum/utils/fft.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{:?}/{}", self.fun, self.arity)
}
}
impl FunArity {
pub fn new(fun: Atom, arity: u16) -> Self {
FunArity { fun, arity }
}
}<|fim_prefix|>// repo: kvakvs/Quokka path: /qk_term/src/funarity.rs
use crate::atom::Atom;
use std::fmt::Debug;
use std::fmt;
#[derive(Hash, Eq, PartialEq,... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/Quokka",
"path": "/qk_term/src/funarity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FunArity {
pub fn new(fun: Atom, arity: u16) -> Self {
FunArity { fun, arity }
}
}<|fim_prefix|>// repo: kvakvs/Quokka path: /qk_term/src/funarity.rs
use crate::atom::Atom;
use std::fmt::Debug;
use std::fmt;
#[derive(Hash, Eq, PartialEq, Copy, Clone)]
pub struct FunArity {
pub fun: Atom,
... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/Quokka",
"path": "/qk_term/src/funarity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvakvs/Quokka path: /qk_term/src/funarity.rs
use crate::atom::Atom;
use std::fmt::Debug;
use std::fmt;
<|fim_suffix|> write!(f, "{:?}/{}", self.fun, self.arity)
}
}
impl FunArity {
pub fn new(fun: Atom, arity: u16) -> Self {
FunArity { fun, arity }
}
}<|fim_middle|>#[derive(Hash, ... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/Quokka",
"path": "/qk_term/src/funarity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let got: Vec<String> =
(vec!["one", "ударения", "four"]).iter().map(|w| w.to_string()).collect();
assert_eq!(got.char_count(), 15);
}
#[test]
fn test_remove_punct() {
let input: Vec<String> = (vec!["removed,;:...!'\""]).iter().map(|w| w.to_string()).collect();
assert_eq!(input.re... | code_fim | medium | {
"lang": "rust",
"repo": "ernestas-poskus/text.rs",
"path": "/tests/text_manipulation.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ernestas-poskus/text.rs path: /tests/text_manipulation.rs
extern crate text;
use text::Manipulation;
#[test]
fn test_average_length() {
let got: Vec<String> = (vec!["one", "two", "four"]).iter().map(|w| w.to_string()).collect();
assert_eq!(got.average_length(), 3.3333333333333335);
... | code_fim | hard | {
"lang": "rust",
"repo": "ernestas-poskus/text.rs",
"path": "/tests/text_manipulation.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn part_two(&self, input: &str) -> Option<String> {
let map: Vec<Vec<char>> = input
.split('\n')
.filter(|line| !line.is_empty())
.map(|line| line.chars().collect())
.collect();
let slopes = vec![(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)];
let result = slopes
.iter... | code_fim | hard | {
"lang": "rust",
"repo": "srujun/aoc2020",
"path": "/src/day03.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srujun/aoc2020 path: /src/day03.rs
use crate::problem::Problem;
#[derive(Default)]
pub struct DayThree {
debug: bool,
}
impl DayThree {
fn count_trees(&self, map: &Vec<Vec<char>>, slope: (usize, usize)) -> u32 {
const TREE: char = '#';
let width = map[0].len();
let height = map... | code_fim | hard | {
"lang": "rust",
"repo": "srujun/aoc2020",
"path": "/src/day03.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alakahakai/vector path: /src/transforms/lua/v2/interop/metric.rs
}
MetricValue::Set { values } => {
let set = ctx.create_table()?;
set.set("values", ctx.create_sequence_from(values.into_iter())?)?;
tbl.set("set", set)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/transforms/lua/v2/interop/metric.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alakahakai/vector path: /src/transforms/lua/v2/interop/metric.rs
"Metric kind should be either \"incremental\" or \"absolute\"".to_string(),
),
}),
}
}
}
impl<'a> ToLua<'a> for Metric {
fn to_lua(self, ctx: LuaContext<'a>) -> LuaResu... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/transforms/lua/v2/interop/metric.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn to_lua_counter_full() {
let metric = Metric {
name: "example counter".into(),
timestamp: Some(Utc.ymd(2018, 11, 14).and_hms_nano(8, 9, 10, 11)),
tags: Some(
vec![("example tag".to_string(), "example value".to_string())]
... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/transforms/lua/v2/interop/metric.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/core_functions/color/hsl/four_args/clamped.rs
//! Tests auto-converted from "sass-spec/spec/core_functions/color/hsl/four_args/clamped.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("clamped")
}
mod alpha {
#[allow(un... | code_fim | medium | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/core_functions/color/hsl/four_args/clamped.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
runner().ok("a {b: hsl(0, 100%, 9999%, 0.5)}\n"),
"a {\
\n b: hsla(0, 100%, 100%, 0.5);\
\n}\n"
);
}
#[test]
fn saturation() {
assert_eq!(
runner().ok("a {b: hsl(0, -0.1%, 50%, 0.5)}\n"),
"a {\
\n b: hsla(0, 0%, 50%, 0.5)... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/core_functions/color/hsl/four_args/clamped.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
runner().ok("a {b: hsl(0, -0.1%, 50%, 0.5)}\n"),
"a {\
\n b: hsla(0, 0%, 50%, 0.5);\
\n}\n"
);
}<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/core_functions/color/hsl/four_args/clamped.rs
//! Tests auto-converted from "sass-spec/spec/core_... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/core_functions/color/hsl/four_args/clamped.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SidneyArmitage/png path: /src/process/mod.rs
mod signature;
mod crc;
mod read;
mod chunks;
pub enum State {
INIT,
IHDR,
PLTE,// optional state
IDAT,
IEND,
FIN,
}
<|fim_suffix|>impl Options {
pub fn new() -> Options {
Options {
bit_depth: 0,
colour_type: 0,
h... | code_fim | medium | {
"lang": "rust",
"repo": "SidneyArmitage/png",
"path": "/src/process/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Options {
pub fn new() -> Options {
Options {
bit_depth: 0,
colour_type: 0,
height: 0,
interlace: false,
plte: vec!(),
state: State::INIT,
width: 0,
crc: crc::CRC::new(),
}
}
}<|fim_prefix|>// repo: SidneyArmitage/png path: /src/process/mod... | code_fim | medium | {
"lang": "rust",
"repo": "SidneyArmitage/png",
"path": "/src/process/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.debug_struct("TIM14").finish()
}
}
#[doc = "General purpose timers"]
pub mod tim14;
#[doc = "General purpose timers"]
pub struct TIM15 {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for TIM15 {}
impl TIM15 {
#[doc = r"Pointer to the register block"]
pub const PTR: *const t... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g051/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32g0/src/stm32g051/mod.rs
st PTR: *const tim14::RegisterBlock = 0x4000_2000 as *const _;
#[doc = r"Return the pointer to the register block"]
#[inline(always)]
pub const fn ptr() -> *const tim14::RegisterBlock {
Self::PTR
}
#[doc ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g051/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { &*Self::PTR }
}
}
impl core::fmt::Debug for DMAMUX {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DMAMUX").finish()
}
}
#[doc = "DMAMUX"]
pub mod dmamux;
#[doc = "HDMI-CEC"]
pub struct HDMI_CEC {
_marker: PhantomData<*const ()>... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g051/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bit 0 - Queue 0 Interrupt status This bit indicates that there is an interrupt from Queue 0."]
#[inline(always)]
pub fn q0is(&self) -> Q0IS_R {
Q0IS_R::new((self.bits() & 0x01) != 0)
}
#[doc = "Bit 1 - Queue 1 Int... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/enet/mtl_intr_stat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s() & 0x01) != 0)
}
#[doc = "Bit 1 - Queue 1 Interrupt status This bit indicates that there is an interrupt from Queue 1."]
#[inline(always)]
pub fn q1is(&self) -> Q1IS_R {
Q1IS_R::new(((self.bits() >> 1) & 0x01) != 0)
}
}<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/enet/mtl_intr_stat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/enet/mtl_intr_stat.rs
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
impl super::MTL_INTR_STAT {
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.reg... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/enet/mtl_intr_stat.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let frame: Vec<u8> = vec![
0x30, 0x2A, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04,
0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/lib/rust/crates/wlan-rsn/src/rsne.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: return/garnet path: /lib/rust/crates/wlan-rsn/src/rsne.rs
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use akm;
use bytes::{BufMut, Bytes, BytesMut};
use cipher;
use failure::E... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/lib/rust/crates/wlan-rsn/src/rsne.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
#[bench]
fn bench_parse_with_nom(b: &mut Bencher) {
let frame: Vec<u8> = vec![
0x30, 0x2A, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04,
0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, ... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/lib/rust/crates/wlan-rsn/src/rsne.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alberthuang24/parser path: /source/rules/comments.rs
// Tagua VM
//
//
// New BSD License
//
// Copyright © 2016-2017, Ivan Enderlin.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following condit... | code_fim | hard | {
"lang": "rust",
"repo": "alberthuang24/parser",
"path": "/source/rules/comments.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(comment_single_line(input), output);
assert_eq!(comment(input), output);
}
#[test]
fn case_comment_single_line_hash_empty() {
let input = Span::new(b"#");
let output = Ok((Span::new_at(b"", 1, 1, 2), Span::new_at(b"", 1, 1, 2)));
assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "alberthuang24/parser",
"path": "/source/rules/comments.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KJMAN678/rust_algorithm path: /098_golf.rs
fn main() {
// 入力受付 1
let mut num_str = String::new();
std::io::stdin().read_line(&mut num_str).unwrap();
num_str.trim_end().to_owned();
let num :i32 = num_str.trim().parse().unwrap();
// 入力受付 2 ベクタ
let mut num_vec = String::new... | code_fim | hard | {
"lang": "rust",
"repo": "KJMAN678/rust_algorithm",
"path": "/098_golf.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut flag :bool = false;
// ベクタ間の中でnumで割った余りを求め、余りがゼロのものがあれば OK を出力
for v in vec[0]..=vec[1] {
if v % num == 0 {
flag = true;
break;
}
}
if flag {
println!("OK");
} else {
println!("NG");
}
}<|fim_prefix|>// repo: KJMAN678/rust_algorithm path: /... | code_fim | hard | {
"lang": "rust",
"repo": "KJMAN678/rust_algorithm",
"path": "/098_golf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 文字列のベクターを数字のベクターに変換
for v in vec_str {
let n :i32 = v.parse::<i32>().unwrap();
vec.push(n);
}
let mut flag :bool = false;
// ベクタ間の中でnumで割った余りを求め、余りがゼロのものがあれば OK を出力
for v in vec[0]..=vec[1] {
if v % num == 0 {
flag = true;
break;
}
}
if flag ... | code_fim | hard | {
"lang": "rust",
"repo": "KJMAN678/rust_algorithm",
"path": "/098_golf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /net/src/connection.rs
cket<'a>
where W: Warn<Warning>,
{
let chunks_iter = ChunksIter::new(data, num_chunks);
let ack = online.ack.clone();
let mut iter = chunks_iter.clone();
while let Some(c) = iter.next_warn(&mut w(warn)) ... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/net/src/connection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, W: Warn<Warning>> Warn<protocol::Warning> for WarnCallback<'a, W> {
fn warn(&mut self, warning: protocol::Warning) {
self.warn.warn(Warning::Packet(warning))
}
}
impl Connection {
pub fn new() -> Connection {
Connection {
state: State::Unconnected,
... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/net/src/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let online = self.state.assert_online();
let vital = if vital {
let sequence = online.sequence.next();
online.resend_queue.push_front(ResendChunk::new(cb, sequence, buffer));
Some((sequence.to_u16(), false))
} else {
None
};
... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/net/src/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Model {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Model {
value: String::new(),
code: String::new(),
step: String::new(),
reg: Default::default(),
... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/web-assembler",
"path": "/src/component.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match msg {
Msg::Assemble => {
self.assemble().unwrap_or(());
true
}
Msg::TextChanged(value) => {
self.value = value;
true
}
Msg::Step => {
self.step().unwrap... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/web-assembler",
"path": "/src/component.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kinodjnz/web-assembler path: /src/component.rs
use crate::assembler::parse_and_assemble;
use crate::emulator::{Emulator, Register};
use crate::parser::Parser;
use yew::{html, Component, ComponentLink, Html, ShouldRender};
pub struct Model {
value: String,
code: String,
step: String,... | code_fim | hard | {
"lang": "rust",
"repo": "kinodjnz/web-assembler",
"path": "/src/component.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forksbot/wifi-captive-rs path: /src/network_backend/iwd/generated/network.rs
// This code was autogenerated with `dbus-codegen-rust -c nonblock -m None --dbuscrate ::dbus -o network.rs`, see https://github.com/diwic/dbus-rs
use ::dbus;
use ::dbus::arg;
use ::dbus::nonblock;
pub trait NetConnman... | code_fim | hard | {
"lang": "rust",
"repo": "forksbot/wifi-captive-rs",
"path": "/src/network_backend/iwd/generated/network.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn name(&self) -> nonblock::MethodReply<String> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::get(&self, "net.connman.iwd.Network", "Name")
}
fn connected(&self) -> nonblock::MethodReply<bool> {
<Self as nonblock::stdintf::org_freedesktop_dbus::Properties>::... | code_fim | medium | {
"lang": "rust",
"repo": "forksbot/wifi-captive-rs",
"path": "/src/network_backend/iwd/generated/network.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut stderr = stderr();
let ref src = env::args().nth(1).fail("no source argument.", &mut stderr);
let dsts = env::args().skip(2);
if dsts.len() < 1 {
fail("no destination arguments.", &mut stderr);
}
let mut src_file = fs::File::open(src).try(&mut stderr);
for ref... | code_fim | medium | {
"lang": "rust",
"repo": "GedRap/coreutils",
"path": "/src/bin/cp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GedRap/coreutils path: /src/bin/cp.rs
#![deny(warnings)]
extern crate extra;
use std::env;
use std::fs;
use std::io::{self, Seek, SeekFrom, stderr};
use extra::io::fail;
use extra::option::OptionalExt;
fn main() {
let mut stderr = stderr();
let ref src = env::args().nth(1).fail("no so... | code_fim | hard | {
"lang": "rust",
"repo": "GedRap/coreutils",
"path": "/src/bin/cp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> src_file.seek(SeekFrom::Start(0)).try(&mut stderr);
io::copy(&mut src_file, &mut dst_file).try(&mut stderr);
}
}<|fim_prefix|>// repo: GedRap/coreutils path: /src/bin/cp.rs
#![deny(warnings)]
extern crate extra;
use std::env;
use std::fs;
use std::io::{self, Seek, SeekFrom, stderr};... | code_fim | hard | {
"lang": "rust",
"repo": "GedRap/coreutils",
"path": "/src/bin/cp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use arith::{MulReduce, ModMul, ModAdd, ModInv, ModNeg};
pub use arith::Value as Scalar;
pub use field::{Field, FieldValue};
pub use element::FieldElement;
pub use mont::MontgomeryElement;<|fim_prefix|>// repo: pepyakin/ng path: /field/src/lib.rs
//! Abstract field and field element operations impleme... | code_fim | medium | {
"lang": "rust",
"repo": "pepyakin/ng",
"path": "/field/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pepyakin/ng path: /field/src/lib.rs
//! Abstract field and field element operations implementation
#![warn(missing_docs)]
<|fim_suffix|>pub use arith::{MulReduce, ModMul, ModAdd, ModInv, ModNeg};
pub use arith::Value as Scalar;
pub use field::{Field, FieldValue};
pub use element::FieldElement;... | code_fim | medium | {
"lang": "rust",
"repo": "pepyakin/ng",
"path": "/field/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut request = tonic::Request::new(HelloRequest {
name: "Tonic".into(),
});
global::get_text_map_propagator(|propagator| {
propagator.inject_context(&tracing::Span::current().context(), request.metadata_mut())
});
let response = client
.say_hello(request)
... | code_fim | hard | {
"lang": "rust",
"repo": "NathanHowell/opentelemetry-rust",
"path": "/examples/tracing-grpc/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NathanHowell/opentelemetry-rust path: /examples/tracing-grpc/src/client.rs
use hello_world::greeter_client::GreeterClient;
use hello_world::HelloRequest;
use opentelemetry::global;
use opentelemetry::sdk::propagation::TraceContextPropagator;
use tracing::*;
use tracing_futures::Instrument;
use t... | code_fim | medium | {
"lang": "rust",
"repo": "NathanHowell/opentelemetry-rust",
"path": "/examples/tracing-grpc/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> global::get_text_map_propagator(|propagator| {
propagator.inject_context(&tracing::Span::current().context(), request.metadata_mut())
});
let response = client
.say_hello(request)
.instrument(info_span!("say_hello"))
.await?;
info!("Response received: {:?}... | code_fim | hard | {
"lang": "rust",
"repo": "NathanHowell/opentelemetry-rust",
"path": "/examples/tracing-grpc/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn clone(&self) -> Self {
*self
}
}
pub type ContactPickerUI = *mut ::core::ffi::c_void;
pub type ContactRemovedEventArgs = *mut ::core::ffi::c_void;<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/ApplicationModel/Contacts/Provider/mod.rs
#![allow(non_sna... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/ApplicationModel/Contacts/Provider/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/ApplicationModel/Contacts/Provider/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(transparent)]
pub struct... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/ApplicationModel/Contacts/Provider/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mshatoori/pacman path: /src/main.rs
mod agent;
mod world;
mod utils;
use crate::world::WorldModel;
use crate::agent::Agent;
<|fim_suffix|> let mut agent = Agent::new(WorldModel::from_input());
// game loop
loop {
agent.wm().update_by_input();
eprintln!("============... | code_fim | medium | {
"lang": "rust",
"repo": "mshatoori/pacman",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // game loop
loop {
agent.wm().update_by_input();
eprintln!("=============== Step {}", agent.wm().turn());
let result = agent.decide();
println!("{}", result);
}
}<|fim_prefix|>// repo: mshatoori/pacman path: /src/main.rs
mod agent;
mod world;
mod utils;
use... | code_fim | medium | {
"lang": "rust",
"repo": "mshatoori/pacman",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/abortive-work path: /src/entities/tree.rs
use crate::systems::*;
use bevy::{ecs::system::SystemParam, prelude::*};
use super::{Blocking, NotGround};
#[derive(Default)]
pub struct Tree {
pub mass: f32,
pub mark_cut_tree: bool,
pub tree_radius: f32,
}
pub struct Model;
... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/abortive-work",
"path": "/src/entities/tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut cmds: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut debug_config: ResMut<DebugConfig>,
materials: Res<ThingMaterials>,
) {
let capsule = shape::Capsule {
radius: 0.2,
depth: 1.0,
latitudes: 5,
longitudes: 10,
rings: 5,
..Default::de... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/abortive-work",
"path": "/src/entities/tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbharadwajj/zipnet path: /ml/src/lib.rs
pub mod activation_functions;
pub mod convolutions;
pub mod models;
pub mod transposed_convolutions;
pub mod weight_loader;
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_middle|>pub type ... | code_fim | medium | {
"lang": "rust",
"repo": "sbharadwajj/zipnet",
"path": "/ml/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: sbharadwajj/zipnet path: /ml/src/lib.rs
pub mod activation_functions;
pub mod convolutions;
pub mod models;
pub mod transposed_convolutions;
pub mod weight_loader;
<|fim_middle|>pub type WeightPrecision = f32;
pub type ImagePrecision = f32;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "sbharadwajj/zipnet",
"path": "/ml/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<F: Clone, RA> Fn<(RA,)> for ReaderFunc<F> {
extern "rust-call" fn call(&self, ra: (RA,)) -> Self::Output {
MappedReader {
func: self.func.clone(),
ra: ra.0,
}
}
}
pub fn fmap<F>(func: F) -> ReaderFunc<F> {
ReaderFunc { func }
}
#[cfg(test)]
mod te... | code_fim | hard | {
"lang": "rust",
"repo": "huanhulan/CTfP-Challenges",
"path": "/src/challenge_7_4_3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn int_to_float(x: i32) -> f64 {
(x * x) as _
}
fn float_to_vec(x: f64) -> Vec<f64> {
vec![x]
}
#[test]
fn map_identity() {
assert_eq!(fmap(identity)(bool_to_int)(false), bool_to_int(false));
assert_eq!(fmap(identity)(bool_to_int)(true), bool_to_in... | code_fim | hard | {
"lang": "rust",
"repo": "huanhulan/CTfP-Challenges",
"path": "/src/challenge_7_4_3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huanhulan/CTfP-Challenges path: /src/challenge_7_4_3.rs
pub struct MappedReader<F, RA> {
func: F,
ra: RA,
}
impl<A, B, R, F: Fn(A) -> B, RA: Fn(R) -> A> FnOnce<(R,)> for MappedReader<F, RA> {
type Output = B;
extern "rust-call" fn call_once(self, r: (R,)) -> Self::Output {
... | code_fim | hard | {
"lang": "rust",
"repo": "huanhulan/CTfP-Challenges",
"path": "/src/challenge_7_4_3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let literals = vec!();
let root_method = MethodObject::new(vec!(Bytecode::HALT), &literals, 0);
let frame = Frame::new(FrameInfo {
stack_depth: 1,
local_count: 1,
literal_count: 0,
method: &root_method
});
}<|fim_prefix|>// repo: samgiles/naulang-runtime pa... | code_fim | easy | {
"lang": "rust",
"repo": "samgiles/naulang-runtime",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samgiles/naulang-runtime path: /src/main.rs
mod naulang;
use naulang::interpreter::frame::{Frame, FrameInfo};
use naulang::interpreter::bytecode::Bytecode;
use naulang::objectspace::method::{MethodObject};
<|fim_suffix|> let literals = vec!();
let root_method = MethodObject::new(vec!(B... | code_fim | easy | {
"lang": "rust",
"repo": "samgiles/naulang-runtime",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: superjose/rust-include-files-example path: /src/house/bathroom/shower.rs
pub enum ShowerTemperature {
Hot,
Cold,
Mild,
}
pub fn take_shower(te<|fim_suffix|>n!("Brrrr.... Cold water ❄"),
ShowerTemperature::Hot => println!("Nice sauna bath 🛀"),
ShowerTemperature::Mild... | code_fim | medium | {
"lang": "rust",
"repo": "superjose/rust-include-files-example",
"path": "/src/house/bathroom/shower.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>na bath 🛀"),
ShowerTemperature::Mild => println!("Not too shabby"),
}
}<|fim_prefix|>// repo: superjose/rust-include-files-example path: /src/house/bathroom/shower.rs
pub enum ShowerTemperature {
Hot,
Cold,
Mild,
}
pub fn take_shower(te<|fim_middle|>mp: ShowerTemperature) {
... | code_fim | medium | {
"lang": "rust",
"repo": "superjose/rust-include-files-example",
"path": "/src/house/bathroom/shower.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Blockchain {
chain: Vec<Block>,
current_transactions: Vec<Transaction>,
nodes: HashSet<String>,
}
impl Blockchain {
fn new() -> Result<Blockchain, Error> {
let mut b = Blockchain {
chain: vec![],
current_transactions: vec![],
nodes: HashS... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/study",
"path": "/blockchain/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AgustinCB/study path: /blockchain/src/main.rs
extern crate crypto;
#[macro_use] extern crate failure;
extern crate futures;
extern crate hyper;
extern crate serde;
#[macro_use] extern crate serde_derive;
extern crate serde_json;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use failure... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/study",
"path": "/blockchain/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let started_at = std::time::Instant::now();
let storage = pathfinder_lib::storage::Storage::migrate(
path.clone(),
pathfinder_lib::storage::JournalMode::WAL,
)
.unwrap();
let migrated_at = std::time::Instant::now();
let size_after_migration = std::fs::metadata(&pat... | code_fim | medium | {
"lang": "rust",
"repo": "lucadonnoh/pathfinder",
"path": "/crates/pathfinder/examples/migrate_db.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucadonnoh/pathfinder path: /crates/pathfinder/examples/migrate_db.rs
fn main() {
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "pathfinder=info");
}
tracing_subscriber::fmt::init();
// simple tool for running and timing the database migrations... | code_fim | hard | {
"lang": "rust",
"repo": "lucadonnoh/pathfinder",
"path": "/crates/pathfinder/examples/migrate_db.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn step_iterator<'a>(&'a self) -> Box<Iterator<Item=Vec<Note>> + 'a> {
Box::new(
// zip the four patterns together to get an iterator giveing
// the status of the 4 notes at each step
self.0[0].0.iter()
.zip(self.0[1].0.iter())
.z... | code_fim | hard | {
"lang": "rust",
"repo": "EnigmaCurry/every_beat",
"path": "/src/patterns.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EnigmaCurry/every_beat path: /src/patterns.rs
use note::Note;
// Each instrument has a 16 note pattern
struct InstrumentPattern([bool; 16]);
// For simplicity, assume the drum machine has 4 instruments (kick, snare, closed hat, open hat)
pub struct MachinePattern([InstrumentPattern; 4]);
// d... | code_fim | hard | {
"lang": "rust",
"repo": "EnigmaCurry/every_beat",
"path": "/src/patterns.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MachinePattern {
pub fn from_u64(num: u64) -> Self {
MachinePattern ([
InstrumentPattern::kick_from_u16 (((num & 0xffff000000000000) >> 48) as u16),
InstrumentPattern::snare_from_u16(((num & 0xffff00000000) >> 32) as u16),
InstrumentPattern::ch_from... | code_fim | hard | {
"lang": "rust",
"repo": "EnigmaCurry/every_beat",
"path": "/src/patterns.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxdemarzi/COST path: /src/graph_iterator.rs
use hilbert_curve::BytewiseCached;
use typedrw::TypedMemoryMap;
pub trait EdgeMapper {
fn map_edges<F: FnMut(u32, u32) -> ()>(&self, action: F) -> ();
}
pub struct UpperLowerMemMapper {
upper: TypedMemoryMap<((u16,u16), u32)>,
lower: T... | code_fim | hard | {
"lang": "rust",
"repo": "maxdemarzi/COST",
"path": "/src/graph_iterator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NodesEdgesMemMapper {
pub fn new(graph_name: &str) -> NodesEdgesMemMapper {
NodesEdgesMemMapper {
nodes: TypedMemoryMap::new(format!("{}.nodes", graph_name)),
edges: TypedMemoryMap::new(format!("{}.edges", graph_name)),
}
}
}
impl EdgeMapper for NodesE... | code_fim | hard | {
"lang": "rust",
"repo": "maxdemarzi/COST",
"path": "/src/graph_iterator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const PREFACE_FORMER: &'static str = include_str!("preface_former.rs");
const PREFACE_LATTER: &'static str = include_str!("preface_latter.rs");
const SOURCE_END: &'static str = "}\n";
fn compile(tokens: &[Token], out_file: Option<String>, tape_size: usize) {
// Insert the preface, which in this insta... | code_fim | hard | {
"lang": "rust",
"repo": "treyzania/brainfuck",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: treyzania/brainfuck path: /src/main.rs
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
use std::fs::File;
use std::io::{Read, Write};
// The StructOpt crate is really easy to use for quick argument parsing.
#[derive(StructOpt, Debug)]
#[structopt(n... | code_fim | hard | {
"lang": "rust",
"repo": "treyzania/brainfuck",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut indentation = String::new();
for _ in 0..count {
indentation.push_str(" ");
}
indentation
}
// Now we can just iterate over every one of our tokens.
for &token in tokens {
match token {
Add => {
// Here... | code_fim | hard | {
"lang": "rust",
"repo": "treyzania/brainfuck",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeviSchuck/oxidize path: /src/route.rs
extern crate http;
use response::Response;
use request::Request;
<|fim_suffix|>//#[deriving(Clone)]
pub struct Route<'r> {
method : &'r str,
path : &'r str,
fptr : View, // fn(&'a Request) -> &'a Response
}
impl<'r> Route<'r> {
pub fn call(&self, ... | code_fim | medium | {
"lang": "rust",
"repo": "LeviSchuck/oxidize",
"path": "/src/route.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'r> Route<'r> {
pub fn call(&self, request: &mut Request) -> Response {
println!("Routing calling the function for path [{}]", self.path);
(self.fptr)(request)
//call(request)
}
}<|fim_prefix|>// repo: LeviSchuck/oxidize path: /src/route.rs
extern crate http;
use res... | code_fim | medium | {
"lang": "rust",
"repo": "LeviSchuck/oxidize",
"path": "/src/route.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/diagnostics/archivist/src/component_lifecycle.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use async_lock::Mutex;
use fidl::endpoints::RequestStr... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/diagnostics/archivist/src/component_lifecycle.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TestControllerServer {
pub fn new() -> (Self, oneshot::Receiver<()>) {
let (stop_sender, stop_recv) = oneshot::channel();
let (server_task_sender, rcv) = mpsc::unbounded();
(
Self {
stop_sender: Arc::new(Mutex::new(Some(stop_sender))),
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/diagnostics/archivist/src/component_lifecycle.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luqmana/rray path: /src/geometry.rs
use math::*;
use std::num::Float;
pub static EPSILON: f32 = 1.0e-4;
pub type Pixel = Vec2f32;
pub type Colour = Vec3f32;
pub type Intersection<'a> = (f32, Vec3f32, &'a (Object + 'a));
pub trait Object {
// Determine if a ray from some origin intersects ... | code_fim | hard | {
"lang": "rust",
"repo": "luqmana/rray",
"path": "/src/geometry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Determine the ray from the origin to us and solve
// the quadratic equation to check for an intersection
let line = self.pos.sub_v(origin);
let rayLens = quad_root(ray.length2(), -2.0 * line.dot(ray),
line.length2() - (self.rad * self.rad)... | code_fim | hard | {
"lang": "rust",
"repo": "luqmana/rray",
"path": "/src/geometry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Errors that may occur when checkpointing a project.
///
/// Question:
/// * Does an invalid dependency update list in a checkpoint invalidate it
/// entirely?
pub enum CheckpointError {
/// A dependency update is invalid if it adds a dependency the project
/// already uses.
UsedDependencyA... | code_fim | hard | {
"lang": "rust",
"repo": "oscoin/oscoin-parity-wasm-prototype",
"path": "/ledger-spec/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oscoin/oscoin-parity-wasm-prototype path: /ledger-spec/src/error.rs
/// Description of errors that a transfer of Oscoin may raise.
pub enum TransferError {
/// This type of error is only here tentatively since the validation of a
/// transfer's data may not necessarily occur in the Ledge... | code_fim | hard | {
"lang": "rust",
"repo": "oscoin/oscoin-parity-wasm-prototype",
"path": "/ledger-spec/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.set_r(params.rt, sign_extend(u32::from(data), 15, 32) as u32);
return Ok(ExecuteSuccess::Taken { cycles: 2 });
}
Ok(ExecuteSuccess::NotTaken)
}
fn exec_str_imm(&mut self, params: &Reg2FullParams) -> ExecuteResult {
if self.condition_passed() {
... | code_fim | hard | {
"lang": "rust",
"repo": "bolifeyo/zmu",
"path": "/zmu_cortex_m/src/executor/load_and_store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.condition_passed() {
let (address, offset_address) = resolve_addressing(
self.get_r(params.rn),
params.imm32,
params.add,
params.index,
);
let data = self.read16(address)?;
if p... | code_fim | hard | {
"lang": "rust",
"repo": "bolifeyo/zmu",
"path": "/zmu_cortex_m/src/executor/load_and_store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bolifeyo/zmu path: /zmu_cortex_m/src/executor/load_and_store.rs
rams, Reg2RtRnParams, Reg3FullParams,
Reg3RdRtRnImm32Params, Reg3RdRtRnParams, RegImm32AddParams,
},
monitor::Monitor,
operation::{shift, sign_extend, zero_extend, zero_extend_u16},
regist... | code_fim | hard | {
"lang": "rust",
"repo": "bolifeyo/zmu",
"path": "/zmu_cortex_m/src/executor/load_and_store.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cechmanek/learning-rust path: /crates_and_cargo/src/lib.rs
//! This is a top level crate comment
//!
//! the crate named 'crates_and_cargo' is created by Justin Cechmanek as a way to learn about Rust.
/// Adds one to the number given.
///
/// # Examples
///
/// ```
/// let arg = 5;
/// let ans... | code_fim | hard | {
"lang": "rust",
"repo": "cechmanek/learning-rust",
"path": "/crates_and_cargo/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>n
/// # like this heading
/// The headings are links to something
/// ## and this sub heading
///
///
/// run >> cargo doc --open to view the html in your browswer
pub fn view_doc(x: i32) ->bool {
let view_documentation = true;
return view_documentation;
}<|fim_prefix|>// repo: cechmanek/learning-r... | code_fim | hard | {
"lang": "rust",
"repo": "cechmanek/learning-rust",
"path": "/crates_and_cargo/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x.b = y.b;
//~^ ERROR lifetime may not live long enough
}
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs
struct Ref<'a, 'b> {
a: &'a u32,
b: &'b u32,
}
<|fim_middle|>fn foo(mut x: Ref, y: Ref) {
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs
struct Ref<'a, 'b> {
a: &'a u32,
b: &'b u32,
}
<|fim_suffix|> x.b = y.b;
//~^ ERROR lifetime may not live long enough
}
fn main() {}<|fim_middle|>fn foo(mut x: Ref, y: Ref) {
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /txpool/src/pool/ready.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! Transaction Readiness indicator
//!
//! Transaction readiness is responsible for indicating if
//! particular transaction can be included in the block.... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/txpool/src/pool/ready.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Condition {
/// Create a new condition checker given current block number and UTC timestamp.
pub fn new(block_number: u64, now: u64) -> Self {
Condition { block_number, now }
}
}
impl tx_pool::Ready<VerifiedTransaction> for Condition {
fn is_ready(&mut self, tx: &VerifiedTran... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/txpool/src/pool/ready.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ngraham20/ssh-manager path: /src/main.rs
use std::io;
use tui::Terminal;
use tui::backend::CrosstermBackend;
use tui::widgets::{Widget, Block, Borders};
use tui::layout::{Layout, Constraint, Direction};
fn main() -> Result<(), io::Error> {
let stdout = io::stdout();
let backend = Crosst... | code_fim | hard | {
"lang": "rust",
"repo": "ngraham20/ssh-manager",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> y: chunks[1].y,
width: chunks[1].width,
height: chunks[1].height
});
let block = Block::default()
.title("Block 3")
.borders(Borders::ALL);
f.render_widget(block, chunks2[0]);
let block = Block::de... | code_fim | hard | {
"lang": "rust",
"repo": "ngraham20/ssh-manager",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .borders(Borders::NONE);
f.render_widget(block, chunks[1]);
let chunks2 = Layout::default()
.direction(Direction::Horizontal)
.margin(0)
.constraints(
[
Constraint::Percentage(50),
Constraint::Per... | code_fim | hard | {
"lang": "rust",
"repo": "ngraham20/ssh-manager",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("Part 1: {}", play(468, 71_010).iter().max().unwrap());
println!("Part 2: {}", play(468, 7_101_000).iter().max().unwrap());
}<|fim_prefix|>// repo: loewenheim/aoc18 path: /09/rust/src/main.rs
use ring_queue::Ring;
type Marbles = Ring<usize>;
fn insert_marble(marbles: &mut M... | code_fim | hard | {
"lang": "rust",
"repo": "loewenheim/aoc18",
"path": "/09/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loewenheim/aoc18 path: /09/rust/src/main.rs
use ring_queue::Ring;
type Marbles = Ring<usize>;
fn insert_marble(marbles: &mut Marbles, marble: usize) -> usize {
if marble % 23 == 0 {
marbles.rotate(7);
marble + marbles.pop_left().unwrap()
} else {
marbles.rotate(... | code_fim | medium | {
"lang": "rust",
"repo": "loewenheim/aoc18",
"path": "/09/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> d_println(format!("Render manager: shutting down"));
}).unwrap();
Self {
job_id_allocator: JobIDAllocator::new(),
job_queue: s,
thread_handle: handle,
}
}
pub fn schedule_job(&mut self, scene_data: &SceneData, config: JobCon... | code_fim | hard | {
"lang": "rust",
"repo": "jtdaugherty/flux",
"path": "/fluxcore/src/manager.rs",
"mode": "spm",
"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.