text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>//fn process_box(payload: &Payload) -> Result<Vec<u8>, Error> {
//
//}
pub fn load_keys(keys: &Vec<Vec<String>>) -> HashMap<String, SecretKey> {
let mut key_map: HashMap<String, SecretKey> = HashMap::new();
for key_set in keys {
let key = match SecretKey::read_from(&key_set[1]) {
... | code_fim | medium | {
"lang": "rust",
"repo": "LeakyBucket/app_therapy",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ark2038/algebra path: /benches/mnt4753/fq.rs
use algebra::UniformRand;
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::ops::{AddAssign, MulAssign, SubAssign};
use algebra::{
biginteger::BigInteger768 as FqRepr, fields::mnt4753::fq::Fq, BigInteger, Field, PrimeField,
Squa... | code_fim | hard | {
"lang": "rust",
"repo": "ark2038/algebra",
"path": "/benches/mnt4753/fq.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v: Vec<(Fq, Fq)> = (0..SAMPLES)
.map(|_| (Fq::rand(&mut rng), Fq::rand(&mut rng)))
.collect();
let mut count = 0;
b.iter(|| {
let mut tmp = v[count].0;
tmp.sub_assign(&v[count].1);
count = (count + 1) % SAMPLES;
tmp
});
}
#[bench]
fn be... | code_fim | hard | {
"lang": "rust",
"repo": "ark2038/algebra",
"path": "/benches/mnt4753/fq.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let receipt = level_contract
.add_liquidity(token3_address, U256::from_dec_str("1")?)
.legacy()
.send()
.await?
.await?;
println!(
"add token3 liquidity:\n{}",
serde_json::to_string_pretty(&receipt)?
);
let receipt = level_contract
... | code_fim | hard | {
"lang": "rust",
"repo": "0xYYY/ethernaut-rs",
"path": "/src/solutions/solution23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xYYY/ethernaut-rs path: /src/solutions/solution23.rs
use crate::types::*;
use crate::utils;
use ethers::prelude::*;
use ethers::utils::{compile, Solc};
use ethers_core::abi::{Token, Tokenize};
use std::error::Error;
use std::sync::Arc;
abigen!(
LevelContract,
r#"[
function toke... | code_fim | hard | {
"lang": "rust",
"repo": "0xYYY/ethernaut-rs",
"path": "/src/solutions/solution23.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct PWM_PIN_IS_STARTED_OUTPUT {
pub IsStarted: super::super::Foundation::BOOLEAN,
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::marker::Copy for PWM_PIN_IS_STARTED_OUTPUT {}
#[cfg(feature = "Win32_Foundation")]
impl ::c... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Win32/Devices/Pwm/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
#[repr(C)]
pub struct PWM_CONTROLLER_SET_DESIRED_PERIOD_OUTPUT {
pub ActualPeriod: u64,
}
impl ::core::marker::Copy for PWM_CONTROLLER_SET_DESIRED_PERIOD_OUTPUT {}
impl ::core::clone::Clone for PWM_CONTROLLER_SET_DESIRED_PERIOD_OUTPUT {
fn clone(&self) -> Self {
*self... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Win32/Devices/Pwm/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Win32/Devices/Pwm/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub const GUID_DEVINTERFACE_PWM_CONTROLLER: ::wi... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Win32/Devices/Pwm/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nical/vodk.rs path: /gfx2d/scenegraph.rs
use gfx2d::color::Rgba;
use math::units::world;
use math::units::texels;
use containers::copy_on_write;
use gfx2d::shapes;
use gpu;
pub type NodeFlags = u16;
pub static ANIMATED_NODE: NodeFlags = 1;
pub static ANIM_SCROLL: NodeFlags = 1 << 1 + ... | code_fim | hard | {
"lang": "rust",
"repo": "nical/vodk.rs",
"path": "/gfx2d/scenegraph.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_last_sibling(&self, id: NodeId) -> NodeId {
assert!(id.is_some());
let mut it = id;
loop {
let next = self.get(it).next_sibling;
if next.is_none() {
return it;
}
it = next
}
}
pub fn get... | code_fim | hard | {
"lang": "rust",
"repo": "nical/vodk.rs",
"path": "/gfx2d/scenegraph.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_state(&self, state: &[u8]) -> migration::errors::Result<()> {
use migration::errors::ErrorKind;
let state = GICv3State::from_bytes(state).unwrap();
let mut regu32 = state.redist_typer_l;
self.access_gic_redistributor(GICR_TYPER, 0, &mut regu32, false)
... | code_fim | hard | {
"lang": "rust",
"repo": "zhutony/stratovirt",
"path": "/devices/src/interrupt_controller/aarch64/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-mulanpsl-2.0-en",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhutony/stratovirt path: /devices/src/interrupt_controller/aarch64/state.rs
8;
/// The status of GICv3 redistributor.
#[repr(C)]
#[derive(Copy, Clone, ByteCode)]
struct GICv3RedistState {
vcpu: usize,
edge_trigger: u32,
gicr_ctlr: u32,
gicr_statusr: u32,
gicr_waker: u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "zhutony/stratovirt",
"path": "/devices/src/interrupt_controller/aarch64/state.rs",
"mode": "psm",
"license": "LicenseRef-scancode-mulanpsl-2.0-en",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhutony/stratovirt path: /devices/src/interrupt_controller/aarch64/state.rs
)]
struct GICv3RedistState {
vcpu: usize,
edge_trigger: u32,
gicr_ctlr: u32,
gicr_statusr: u32,
gicr_waker: u32,
gicr_igroupr0: u32,
gicr_ienabler0: u32,
gicr_ipendr0: u32,
gicr_iactiv... | code_fim | hard | {
"lang": "rust",
"repo": "zhutony/stratovirt",
"path": "/devices/src/interrupt_controller/aarch64/state.rs",
"mode": "psm",
"license": "LicenseRef-scancode-mulanpsl-2.0-en",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilipDaniels/projecteuler path: /src/fibonacci.rs
use std::ops::Range;
pub fn fib_in_range(r: Range<u64>) -> Vec<u64> {
FibonacciIterator::new()
.skip_while(|&p| p < r.start)
.take_while(|&p| p < r.end)
.collect()
}
<|fim_suffix|> fn next(&mut self) -> Option<u6... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/projecteuler",
"path": "/src/fibonacci.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn fib_in_range_for_start_at_nonzero_returns_correct_fibs() {
assert_eq!(fib_in_range(10..100), vec![13, 21, 34, 55, 89]);
}
}<|fim_prefix|>// repo: PhilipDaniels/projecteuler path: /src/fibonacci.rs
use std::ops::Range;
pub fn fib_in_range(r: Range<u64>) -> Vec<u64> {
Fi... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/projecteuler",
"path": "/src/fibonacci.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn fib_in_range_for_start_at_zero_returns_first_fibs() {
assert_eq!(fib_in_range(0..10), vec![1, 2, 3, 5, 8]);
}
#[test]
fn fib_in_range_for_start_at_nonzero_returns_correct_fibs() {
assert_eq!(fib_in_range(10..100), vec![13, 21, 34, 55, 89]);
}
}<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/projecteuler",
"path": "/src/fibonacci.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = cellvalue(33, 45, 18);
assert_eq!(v, 4);
}
#[test]
fn testcell() {
assert_eq!(cellvalue(3, 5, 8), 4);
}
#[test]
fn testblock1() {
let t = maxblock(3, 18);
println!("test1: {},{} has value {}", t.0, t.1, t.2);
assert!(t == (33, 45, 29));
}
#[test]
fn test2() {
let t =... | code_fim | hard | {
"lang": "rust",
"repo": "fweez/adventofcode",
"path": "/2018/day11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fweez/adventofcode path: /2018/day11/src/main.rs
use std::i32;
fn cellvalue(x: usize, y: usize, serial: i32) -> i32 {
if x >= 300 || y >= 300 { panic!("bad x/y"); }
let rackid = (x + 10) as i32;
let power = rackid * y as i32;
let power = power + serial;
let power = power * r... | code_fim | hard | {
"lang": "rust",
"repo": "fweez/adventofcode",
"path": "/2018/day11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..6 {
let g = altcube.clone();
for w in 1..grid_w {
for d in 1..grid_depth {
for r in 1..grid_height {
for c in 1..grid_width {
let neighbors = count_neighbours_2(c, r, d, w, &g);
altcube[w][d][c][r] = if g[w][d][c][r] {
neighbors == 2 || neighbors == 3
... | code_fim | hard | {
"lang": "rust",
"repo": "MitMaro/advent-of-code-2020",
"path": "/src/day17.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MitMaro/advent-of-code-2020 path: /src/day17.rs
pub fn parse_input(input: &str) -> Vec<Vec<Vec<bool>>> {
let pc = 7;
let mut grid = input
.lines()
.map(|v| {
let mut line = v.chars().map(|c| c == '#').collect::<Vec<bool>>();
for _ in 0..pc {
line.insert(0, false);
line.push(f... | code_fim | hard | {
"lang": "rust",
"repo": "MitMaro/advent-of-code-2020",
"path": "/src/day17.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day17, part2)]
pub fn part2(input: &str) -> i32 {
let cube = parse_input(input);
let grid_width = cube[0][0].len() - 1;
let grid_height = cube[0].len() - 1;
let grid_depth = cube.len() - 1;
let mut altcube = vec![cube];
for _ in 0..7 {
altcube.insert(0, vec![
vec![vec![false; grid_width... | code_fim | hard | {
"lang": "rust",
"repo": "MitMaro/advent-of-code-2020",
"path": "/src/day17.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn merge_groups_full_nested_deep() {
check_crate(
"std::foo::bar::quux::Baz",
r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};",
r"use std::foo::bar::{Qux, quux::{Fez, Fizz, Baz}};",
)
}
#[test]
fn merge_groups_full_nested_long() {
check_crate(
"std::foo:... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/ide-db/src/imports/insert_use/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> check_crate("std::foo::bar::Baz", r"use std::foo::bar::Qux;", r"use std::foo::bar::{Qux, Baz};")
}
#[test]
fn merge_groups_long_last() {
check_module(
"std::foo::bar::Baz",
r"use std::foo::bar::Qux;",
r"use std::foo::bar::{Qux, Baz};",
)
}
#[test]
fn merge_groups_long... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/ide-db/src/imports/insert_use/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust-analyzer path: /crates/ide-db/src/imports/insert_use/tests.rs
]
fn insert_no_imports() {
check_crate(
"foo::bar",
"fn main() {}",
r"use foo::bar;
fn main() {}",
)
}
#[test]
fn insert_empty_file() {
cov_mark::check_count!(insert_empty_file, 2);... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/ide-db/src/imports/insert_use/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fatho/glui path: /src/core/id.rs
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Id(u64);
impl Id {
/// *The* invalid ID. Used where it is necessary to explicitly
/// state that no existing widget is referenced.
#[inline(always)]
pub const fn invalid() -> Id {
Id... | code_fim | hard | {
"lang": "rust",
"repo": "fatho/glui",
"path": "/src/core/id.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Build a widget ID from line and column where the generator macro is used.
pub const fn make_id(line: u32, column: u32) -> Id {
let mut fnv = 0xcbf29ce484222325u64;
fnv = fnv_u32!(fnv, line);
fnv = fnv_u32!(fnv, column);
Id(fnv)
}<|fim_prefix|>// repo: fatho/glui path: /src/core/id.r... | code_fim | hard | {
"lang": "rust",
"repo": "fatho/glui",
"path": "/src/core/id.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: goodhel/rust-graphql path: /src/paths.rs
use actix_web::{Error, HttpResponse, web};
use juniper::http::graphiql::graphiql_source;
use juniper::http::GraphQLRequest;
use crate::db::PgPool;
use crate::handler::root::{create_schema, Context, Schema};
<|fim_suffix|>pub async fn graphql_playground(... | code_fim | hard | {
"lang": "rust",
"repo": "goodhel/rust-graphql",
"path": "/src/paths.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(HttpResponse::Ok()
.content_type("application/json")
.body(json))
}
pub async fn graphql_playground() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(graphiql_source("/graphql", None))
}
pub fn init(app: &mut web::ServiceCon... | code_fim | hard | {
"lang": "rust",
"repo": "goodhel/rust-graphql",
"path": "/src/paths.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikeb01/advent2018 path: /src/advent4.rs
use std::io::{BufRead, BufReader, Error};
use std::fs::File;
use chrono::{Timelike, NaiveDateTime};
use std::collections::HashMap;
#[derive(PartialEq, Eq, Clone, Debug)]
enum GuardAction {
StartShift(i32),
Sleep,
Wake
}
#[derive(Debug)]
str... | code_fim | hard | {
"lang": "rust",
"repo": "mikeb01/advent2018",
"path": "/src/advent4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let mut guards = Vec::new();
for (_id, guard) in guards_by_id.drain() {
guards.push(guard);
}
guards.sort_by(|a, b| a.total_minutes_asleep.cmp(&b.total_minutes_asleep));
let solution_a = guards.last().map(|g| calc_sleepiest_minute(&g).0 * g.id);
guards.sort_by(|a, b| ca... | code_fim | hard | {
"lang": "rust",
"repo": "mikeb01/advent2018",
"path": "/src/advent4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Settings {
pub fn new(config_path: &str) -> Result<Self, ConfigError> {
let mut cfg = Config::new();
cfg.merge(File::with_name(config_path).required(false))?;
cfg.merge(Environment::with_prefix("heimdallr").separator("_"))?;
// Deserialize and freeze the entire configuration
c... | code_fim | hard | {
"lang": "rust",
"repo": "chimney-rock/kube-auth",
"path": "/src/settings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chimney-rock/kube-auth path: /src/settings.rs
use config::{ConfigError, Config, File, Environment};
use std::net::SocketAddr;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Settings {
pub inbound_listener: Listener,
pub database: Database
}
<|fim_suffix|>impl Settings {
... | code_fim | hard | {
"lang": "rust",
"repo": "chimney-rock/kube-auth",
"path": "/src/settings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Blei/rust-timerfd path: /src/lib.rs
//! Integration of Linux' timerfd into the GLib main loop as a GSource
// Mostly mirroring the names in C
#![allow(non_camel_case_types)]
extern crate gtk;
extern crate libc;
use std::cmp;
use std::default;
use std::io;
use std::mem;
use gtk::ffi;
#[deriv... | code_fim | hard | {
"lang": "rust",
"repo": "Blei/rust-timerfd",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Timer {
pub fn new() -> Timer {
Timer {
timerfd: TimerFD::new(),
current: default::Default::default(),
active: false,
}
}
/// initial_ms has to be > 0
pub fn set_interval(&mut self, initial_ms: i64, interval_ms: i64) {
asser... | code_fim | hard | {
"lang": "rust",
"repo": "Blei/rust-timerfd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wangwpf/rftrace path: /rftrace-frontend/src/frontend.rs
use crate::interface::*;
use byteorder::{LittleEndian, WriteBytesExt};
use std::fs::File;
use std::io::{self, prelude::*};
extern "C" {
fn rftrace_backend_enable();
fn rftrace_backend_disable();
fn rftrace_backend_init(bufptr: ... | code_fim | hard | {
"lang": "rust",
"repo": "wangwpf/rftrace",
"path": "/rftrace-frontend/src/frontend.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // For each TID, loop through the events array and save only the relevant items to disk
for current_tid in &tids {
// clear out vec in case it contains entries from previous tid
out.clear();
let tid = current_tid.map_or(0, |tid| tid.get());
println!(" Parsing TID... | code_fim | hard | {
"lang": "rust",
"repo": "wangwpf/rftrace",
"path": "/rftrace-frontend/src/frontend.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SkylerLipthay/bean path: /examples/repl.rs
extern crate ansi_term;
extern crate bean;
extern crate rustyline;
use ansi_term::Colour::{Green, Fixed, Red};
use bean::context::Context;
use bean::stdlib;
use bean::value::Object;
use rustyline::{Editor, error::ReadlineError};
use std::time::SystemTi... | code_fim | hard | {
"lang": "rust",
"repo": "SkylerLipthay/bean",
"path": "/examples/repl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rl.add_history_entry(line);
},
Err(ReadlineError::Interrupted) => continue,
Err(ReadlineError::Eof) => break,
Err(err) => {
println!("CLI error: {:?}", err);
break;
},
}
}
}
fn print_he... | code_fim | hard | {
"lang": "rust",
"repo": "SkylerLipthay/bean",
"path": "/examples/repl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rl.add_history_entry(line);
},
Ok(ref line) => {
let before = SystemTime::now();
let (changed_scope, result) = context.eval_with_scope(line, scope.take().unwrap());
scope.replace(changed_scope);
let ela... | code_fim | hard | {
"lang": "rust",
"repo": "SkylerLipthay/bean",
"path": "/examples/repl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn collect_stats<R>(enabled: bool, f: impl FnOnce() -> R) -> (R, Option<Stats>) {
if enabled {
let (result, stats) = stats::collect(f);
(result, Some(stats))
} else {
let result = f();
(result, None)
}
}<|fim_prefix|>// repo: jakoschiko/dicetest path: /src/... | code_fim | hard | {
"lang": "rust",
"repo": "jakoschiko/dicetest",
"path": "/src/runner/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakoschiko/dicetest path: /src/runner/util.rs
use crate::hints::{self, Hints};
use crate::stats::{self, Stats};
<|fim_suffix|>pub fn collect_stats<R>(enabled: bool, f: impl FnOnce() -> R) -> (R, Option<Stats>) {
if enabled {
let (result, stats) = stats::collect(f);
(result, ... | code_fim | hard | {
"lang": "rust",
"repo": "jakoschiko/dicetest",
"path": "/src/runner/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sixteen: f32 = 16;
//~^ ERROR mismatched types
//~| HELP use a float literal
let a_million_and_seventy: f64 = 1_000_070;
//~^ ERROR mismatched types
//~| HELP use a float literal
let negative_nine: f32 = -9;
//~^ ERROR mismatched types
//~| HELP use a float literal
... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache Licens... | code_fim | medium | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// only base-10 literals get the suggestion
let sixteen_again: f64 = 0x10;
//~^ ERROR mismatched types
let and_once_more: f32 = 0o20;
//~^ ERROR mismatched types
}<|fim_prefix|>// repo: unnsa/rust path: /src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs
//... | code_fim | hard | {
"lang": "rust",
"repo": "unnsa/rust",
"path": "/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UMASHIBA1/MyRustTutorialPractice path: /4/4_33/deref/src/main.rs
// Derefによる型強制
use std::ops::Deref;
struct DerefExample<T> {
value: T,
}
// *(ポインタ演算子)をオーバーロードする!
impl<T> Deref for DerefExample<T> {
type Target = T;
fn deref(&self) -> &T {
<|fim_suffix|>// derefによる型強制
fn foo(_s: &... | code_fim | medium | {
"lang": "rust",
"repo": "UMASHIBA1/MyRustTutorialPractice",
"path": "/4/4_33/deref/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> foo(&owned);
let owned2 = vec![1, 2, 3];
foo2(&owned2);
struct Foo;
impl Foo {
fn foo(&self) {
println!("Foo");
}
}
let f = &&Foo;
// 以下は全て同じ
f.foo();
(&f).foo();
(&&f).foo();
(&&&&&&&&&&f).foo();
}<|fim_prefix|>// repo: UMASH... | code_fim | medium | {
"lang": "rust",
"repo": "UMASHIBA1/MyRustTutorialPractice",
"path": "/4/4_33/deref/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felipehfs/Rust-Learning path: /struct2.rs
struct Person {
first_name: String,
last_name: String
}
impl Person {
fn new(first: &str, name: &str) -> Person {
<|fim_suffix|>fn main() {
let p = Person::new("Felipe", "Henrique");
println!("person {} {}", p.first_name, p.last_name... | code_fim | hard | {
"lang": "rust",
"repo": "felipehfs/Rust-Learning",
"path": "/struct2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let p = Person::new("Felipe", "Henrique");
println!("person {} {}", p.first_name, p.last_name);
println!("fullname {}", p.full_name());
}<|fim_prefix|>// repo: felipehfs/Rust-Learning path: /struct2.rs
struct Person {
first_name: String,
last_name: String
}
<|fim_middle|>... | code_fim | hard | {
"lang": "rust",
"repo": "felipehfs/Rust-Learning",
"path": "/struct2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_will_return_random() {
const HIGH:u8 = 0xCD;
const LOW:u8 = 0x65;
let actual = parse_opcode(HIGH, LOW);
assert_eq!(OpCode::RND(0x0D, 0x65), actual);
}
#[test]
fn it_will_draw() {
const HIGH:u8 = 0xD4;
const LOW:u8 = 0xE3;
... | code_fim | hard | {
"lang": "rust",
"repo": "andrewgoacher/chip8",
"path": "/lib_chip/opcode/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewgoacher/chip8 path: /lib_chip/opcode/parser.rs
//! Contains the parsers to take the data from memory and return an opcode
use super::{AddOp, OpCode, ShiftOp, SkipOp, LoadOp, JumpOp};
/// Generates a 16bit opcode from 2 8bit operands.
/// These will generally be found at memory address x a... | code_fim | hard | {
"lang": "rust",
"repo": "andrewgoacher/chip8",
"path": "/lib_chip/opcode/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: obayemi/lapin path: /src/topology_internal.rs
use crate::{
channel::Channel,
consumer::Consumer,
message::BasicGetMessage,
options::{BasicGetOptions, QueueDeclareOptions},
topology::{
BindingDefinition, ChannelDefinition, ConsumerDefinition, ExchangeDefinition,
... | code_fim | hard | {
"lang": "rust",
"repo": "obayemi/lapin",
"path": "/src/topology_internal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.definition
}
}
impl From<ConsumerDefinition> for ConsumerDefinitionInternal {
fn from(definition: ConsumerDefinition) -> Self {
Self {
consumer: None,
definition,
}
}
}
impl From<ConsumerDefinitionInternal> for ConsumerDefinition {
fn... | code_fim | hard | {
"lang": "rust",
"repo": "obayemi/lapin",
"path": "/src/topology_internal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.definition
}
}
impl From<QueueDefinition> for QueueDefinitionInternal {
fn from(definition: QueueDefinition) -> Self {
Self {
definition,
declared: true,
}
}
}
impl From<QueueDefinitionInternal> for QueueDefinition {
fn from(internal:... | code_fim | hard | {
"lang": "rust",
"repo": "obayemi/lapin",
"path": "/src/topology_internal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/log4rs-fluentd path: /examples/from_conf.rs
extern crate log4rs;
extern crate log4rs_fluentd;
#[macro_use]
extern crate log;
extern crate tempfile;
fn main() {
use std::io::Write;
let mut deserializers = log4rs::file::Deserializers::new();
log4rs_fluentd::register(&mut ... | code_fim | medium | {
"lang": "rust",
"repo": "Devolutions/log4rs-fluentd",
"path": "/examples/from_conf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..5 {
trace!("Example trace message: {}", i);
debug!("Example debug message: {}", i);
info!("Example information message: {}", i);
warn!("Example warning message: {}", i);
error!("Example error message: {}", i);
::std::thread::sleep(::std::time... | code_fim | medium | {
"lang": "rust",
"repo": "Devolutions/log4rs-fluentd",
"path": "/examples/from_conf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> log4rs::init_file(tmp_conf.path(), deserializers).unwrap();
for i in 0..5 {
trace!("Example trace message: {}", i);
debug!("Example debug message: {}", i);
info!("Example information message: {}", i);
warn!("Example warning message: {}", i);
error!("Example... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/log4rs-fluentd",
"path": "/examples/from_conf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GameRuiner/adventofcode path: /src/day11.rs
#[allow(dead_code)]
pub fn seating_system(seats : &[String]) -> i32 {
let mut vec_seats = Vec::<Vec<char>>::new();
for line in seats {
vec_seats.push(line.chars().collect());
}
//let mut new_seats = round(&vec_seats);
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "GameRuiner/adventofcode",
"path": "/src/day11.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut left = seat_num as i32 -1;
while left >= 0 {
let status = check_seat(seats[line_num][left as usize]);
if status != -1 {
count += status;
break;
}
left -= 1;
}
let mut right = seat_num+1;
while right < seats[0].len() {... | code_fim | hard | {
"lang": "rust",
"repo": "GameRuiner/adventofcode",
"path": "/src/day11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if val != actual {
panic!("incorrect value for errno {}; got={}; expected={}",
err, val, actual);
}
}
}<|fim_prefix|>// repo: teotwaki/nix-rust path: /nix-test/src/lib.rs
#![feature(libc, std_misc)]
extern crate libc;
use std::ffi::CString;
use libc::{... | code_fim | hard | {
"lang": "rust",
"repo": "teotwaki/nix-rust",
"path": "/nix-test/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(actual > 0);
if val != actual {
panic!("incorrect value for errno {}; got={}; expected={}",
err, val, actual);
}
}
}<|fim_prefix|>// repo: teotwaki/nix-rust path: /nix-test/src/lib.rs
#![feature(libc, std_misc)]
extern crate libc;
use ... | code_fim | medium | {
"lang": "rust",
"repo": "teotwaki/nix-rust",
"path": "/nix-test/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teotwaki/nix-rust path: /nix-test/src/lib.rs
#![feature(libc, std_misc)]
extern crate libc;
use std::ffi::CString;
use libc::{c_int};
mod ffi {
use libc::{c_int, c_char};
#[link(name = "nixtest", kind = "static")]
extern {
pub fn assert_errno_eq(errno: *const c_char) -> c... | code_fim | hard | {
"lang": "rust",
"repo": "teotwaki/nix-rust",
"path": "/nix-test/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(df_receiver)
}
fn create_emails(
matches: &ArgMatches<'_>,
sender: &str,
df_receiver: DataFrame,
) -> Result<Vec<Email>, anyhow::Error> {
let receiver_col: &str;
// If argument 'RECEIVER_COLUMN' is not present the default value 'email' will be used
match matches.value_of(a... | code_fim | hard | {
"lang": "rust",
"repo": "tawawhite/pigeon-rs",
"path": "/src/email_handler/bulk_email.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tawawhite/pigeon-rs path: /src/email_handler/bulk_email.rs
use crate::{
arg, cmd,
data_sources::{query_postgres, read_csv},
email_handler::{Confirmed, Email, Message, MessageTemplate},
email_provider,
helper::{check_send_status, format_green},
};
use anyhow::{anyhow, Context,... | code_fim | hard | {
"lang": "rust",
"repo": "tawawhite/pigeon-rs",
"path": "/src/email_handler/bulk_email.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joachimff/riscv-emu path: /src/cpu/instr_type.rs
#[derive(Debug)]
pub struct RType{
pub funct7: u8,
pub rs2: usize,
pub rs1: usize,
pub funct3: u8,
pub rd: usize,
pub opcode: u8
}
impl From<u32> for RType{
fn from(instruction:u32) -> Self{
RType{
... | code_fim | hard | {
"lang": "rust",
"repo": "joachimff/riscv-emu",
"path": "/src/cpu/instr_type.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct UType{
pub imm: u32,
pub rd: usize,
pub opcode: u8
}
impl From<u32> for UType{
fn from(instruction:u32) -> Self{
UType{
imm: ((instruction >> 12) & 0b1111_1111_1111_1111_1111) as u32,
rd: ((instruction >> 7) & 0b11111) as usi... | code_fim | hard | {
"lang": "rust",
"repo": "joachimff/riscv-emu",
"path": "/src/cpu/instr_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbacarella/sparktop path: /src/sprocs.rs
/// SProcs: a collection of all processes on the system.
use std::collections::{hash_map::Values, HashMap};
use sysinfo::{ProcessExt, System, SystemExt};
<|fim_suffix|>impl SProcs {
pub fn new() -> Self {
Self {
sys: System::new_... | code_fim | medium | {
"lang": "rust",
"repo": "mbacarella/sparktop",
"path": "/src/sprocs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SProcs {
pub fn new() -> Self {
Self {
sys: System::new_all(),
sprocs: HashMap::default(),
}
}
pub fn update(&mut self, ewma_weight: f64) {
// TODO: refresh_processes() doesn't seem to work?
self.sys.refresh_all();
let lates... | code_fim | medium | {
"lang": "rust",
"repo": "mbacarella/sparktop",
"path": "/src/sprocs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberFlameGO/abi_stable_crates path: /abi_stable/src/type_layout/tl_field.rs
use super::*;
/// The layout of a field.
#[repr(C)]
#[derive(Debug, Copy, Clone, StableAbi)]
#[sabi(unsafe_sabi_opaque_fields)]
pub struct TLField {
/// The field's name.
name: RStr<'static>,
/// Which lif... | code_fim | hard | {
"lang": "rust",
"repo": "CyberFlameGO/abi_stable_crates",
"path": "/abi_stable/src/type_layout/tl_field.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(test)]
mod tests{
use super::*;
use crate::{
abi_stability::stable_abi_trait::GetTypeLayoutCtor,
std_types::RString,
};
#[test]
fn roundtrip(){
const UNIT_CTOR:TypeLayoutCtor=GetTypeLayoutCtor::<()>::STABLE_ABI;
const U32_CTOR:TypeLayoutCtor=GetT... | code_fim | hard | {
"lang": "rust",
"repo": "CyberFlameGO/abi_stable_crates",
"path": "/abi_stable/src/type_layout/tl_field.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jplevyak/sdk path: /src/dfx/src/commands/identity/deploy_wallet.rs
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::identity::Identity;
use crate::lib::provider::{create_agent_environment, get_network_descriptor};
use crate::lib::root_key::fetch_root_ke... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/commands/identity/deploy_wallet.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let canister_id = opts.canister_id;
match CanisterId::from_text(&canister_id) {
Ok(id) => {
runtime.block_on(async {
Identity::create_wallet(&agent_env, &network, &identity_name, Some(id)).await?;
DfxResult::Ok(())
})?;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/commands/identity/deploy_wallet.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesMcGuigan/ecosystem-research path: /rust/rust-python/maturin_test/src/lib.rs
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
fn double(x: usize) -> usize {
x * 2
}
#[pyfunction]
fn double_f64(x: f64) -> f64 {
x * 2.0
}
<|fim_suffix|> m.add_wrapped(wrap_pyfunction... | code_fim | hard | {
"lang": "rust",
"repo": "JamesMcGuigan/ecosystem-research",
"path": "/rust/rust-python/maturin_test/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[pymodule]
#[pyo3(name = "maturin_test")]
fn module_with_functions(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(double))?;
m.add_wrapped(wrap_pyfunction!(double_f64))?;
m.add_wrapped(wrap_pyfunction!(sum_as_string))?;
Ok(())
}<|fim_prefix|>// repo: JamesMcGu... | code_fim | medium | {
"lang": "rust",
"repo": "JamesMcGuigan/ecosystem-research",
"path": "/rust/rust-python/maturin_test/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /demo/src/bitmagic.rs
use buffer::Buffer;
use buffer::BufferRef;
use buffer::with_buffer;
use common;
use std::mem;
use std::slice;
use raw::Callback;
use raw::CallbackReadError;
use raw::ResultExt;
use writer;
/// Safe to write arbitrary bytes to this struct.
pub uns... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/demo/src/bitmagic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Callback> CallbackExt for T { }
pub trait WriteCallbackExt: writer::Callback {
fn write_raw<T: Packed>(&mut self, t: &T) -> Result<(), Self::Error> {
self.write(as_bytes(t))
}
}
impl<T: writer::Callback> WriteCallbackExt for T { }<|fim_prefix|>// repo: heinrich5991/libtw2 path: ... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/demo/src/bitmagic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> Result<&'d [u8], Self::Error>
{
with_buffer(buf, |buf| self.read_buffer_ref(buf))
}
fn read_buffer_ref<'d, 's>(&mut self, mut buf: BufferRef<'d, 's>)
-> Result<&'d [u8], Self::Error>
{
unsafe {
let read = self.read(buf.uninitialized_mut())?;
... | code_fim | hard | {
"lang": "rust",
"repo": "heinrich5991/libtw2",
"path": "/demo/src/bitmagic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google-apis-rs/generated path: /gen/adexchangebuyer/v1.4/lib/src/lib.rs
= <&str>::deserialize(deserializer)?;
Ok(match value {
"accept" => PatchUpdateAction::Accept,
"cancel" => PatchUpdateAction::Cancel,
... | code_fim | hard | {
"lang": "rust",
"repo": "google-apis-rs/generated",
"path": "/gen/adexchangebuyer/v1.4/lib/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Vec::new()
}
}
impl ::google_field_selector::ToFieldType
for CreativeServingRestrictionsItemsDisapprovalReasonsItems
{
fn field_type() -> ::google_field_selector::FieldType {
::google_field_selector::FieldType::Leaf
}
}
#[derive(
... | code_fim | hard | {
"lang": "rust",
"repo": "google-apis-rs/generated",
"path": "/gen/adexchangebuyer/v1.4/lib/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google-apis-rs/generated path: /gen/adexchangebuyer/v1.4/lib/src/lib.rs
dyn ::google_api_auth::GetAccessToken,
}
impl<'a> PubprofilesActions<'a> {
fn auth_ref(&self) -> &dyn ::google_api_auth::GetAccessToken {
self.auth
}
#[doc... | code_fim | hard | {
"lang": "rust",
"repo": "google-apis-rs/generated",
"path": "/gen/adexchangebuyer/v1.4/lib/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkaleas/opengl-tutorial-rs path: /src/main.rs
#![allow(non_upper_case_globals)]
#![macro_use]
extern crate glfw;
use self::glfw::{Context, Key, Action};
extern crate gl;
extern crate cgmath;
use self::gl::types::*;
use std::sync::mpsc::Receiver;
use std::mem;
use std::os::raw::c_void;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "tkaleas/opengl-tutorial-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
//EBO Generation
let mut EBO = 0;
let mut VAO: u32 = 0;
let mut VBO = 0;
gl::GenVertexArrays(1, &mut VAO);
gl::GenBuffers(1, &mut EBO);
gl::GenBuffers(1, &mut VBO);
gl::BindVertexArray... | code_fim | hard | {
"lang": "rust",
"repo": "tkaleas/opengl-tutorial-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graphprotocol/graph-node path: /graph/src/components/graphql.rs
use futures::prelude::*;
use crate::data::query::QueryResults;
use crate::data::query::{Query, QueryTarget};
use crate::data::subscription::{Subscription, SubscriptionError, SubscriptionResult};
use crate::prelude::DeploymentHash;
... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/graph/src/components/graphql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Future for subscription results.
pub type SubscriptionResultFuture =
Box<dyn Future<Item = SubscriptionResult, Error = SubscriptionError> + Send>;
pub enum GraphQlTarget {
SubgraphName(String),
Deployment(DeploymentHash),
}
/// A component that can run GraphqL queries against a [Store](..... | code_fim | medium | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/graph/src/components/graphql.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulgb/json-ld path: /src/compaction/property.rs
y to compacted item where the key is
// the result of IRI compacting @index and value is value.
if let Some(index) = expanded_index {
let key = compact_iri(active_context.clone(), Keyword::Index, true, false, options)?;
match compacted_i... | code_fim | hard | {
"lang": "rust",
"repo": "paulgb/json-ld",
"path": "/src/compaction/property.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulgb/json-ld path: /src/compaction/property.rs
compacted_item)
}
Ok(())
}
async fn compact_property_graph<T: Sync + Send + Id, C: ContextMut<T>, L: Loader>(node: &Node<T>, expanded_index: Option<&str>, nest_result: &mut json::object::Object, container: Container, as_array: bool, item_acti... | code_fim | hard | {
"lang": "rust",
"repo": "paulgb/json-ld",
"path": "/src/compaction/property.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((nest_result, container, as_array))
}
/// Compact the given property into the `result` compacted object.
pub async fn compact_property<'a, T: 'a + Sync + Send + Id, N: 'a + object::Any<T> + Sync + Send, O: IntoIterator<Item=&'a Indexed<N>>, C: ContextMut<T>, L: Loader>(result: &mut json::object::Obje... | code_fim | hard | {
"lang": "rust",
"repo": "paulgb/json-ld",
"path": "/src/compaction/property.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn check_compiler_or_interpreter(&self) -> String {
String::from("nasm -version && ld -version")
}
}<|fim_prefix|>// repo: Kryod/rustacean path: /src/commands/exec/asmx64.rs
use std::path::PathBuf;
use crate::commands::exec::language::Language;
#[derive(Debug)]
pub struct Asmx64;
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "Kryod/rustacean",
"path": "/src/commands/exec/asmx64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kryod/rustacean path: /src/commands/exec/asmx64.rs
use std::path::PathBuf;
use crate::commands::exec::language::Language;
#[derive(Debug)]
pub struct Asmx64;
impl Asmx64 {
fn get_file_name(&self, src_path: &PathBuf) -> String {
src_path
.with_extension("")
... | code_fim | medium | {
"lang": "rust",
"repo": "Kryod/rustacean",
"path": "/src/commands/exec/asmx64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: writer4/compiler path: /src/parser/hir.rs
use crate::ast::{hir, lir};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {}
pub fn parse<'a>(document: &lir::Document<'a>) -> Result<hir::Document<'a>> {
let mut statements = Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "writer4/compiler",
"path": "/src/parser/hir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(hir::List { items })
}
fn parse_text_segments<'a>(
segments_lir: &[lir::TextSegment<'a>],
) -> Result<Vec<hir::TextSegment<'a>>> {
let mut segments = Vec::new();
let mut idx = 0;
while idx < segments_lir.len() {
match segments_lir[idx] {
lir::TextSegment::Text(... | code_fim | hard | {
"lang": "rust",
"repo": "writer4/compiler",
"path": "/src/parser/hir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Killua67/curlconverter path: /fixtures/rust/post_with_data_raw.rs
extern crate reqwest;
use reqwest::header;
fn main() -> Result<(), Box<dyn std::error::Error>> {
<|fim_suffix|> let res = reqwest::Client::new()
.post("http://example.com/post")
.headers(headers)
.body(... | code_fim | medium | {
"lang": "rust",
"repo": "Killua67/curlconverter",
"path": "/fixtures/rust/post_with_data_raw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = reqwest::Client::new()
.post("http://example.com/post")
.headers(headers)
.body("msg1=wow&msg2=such&msg3=@rawmsg")
.send()?
.text()?;
println!("{}", res);
Ok(())
}<|fim_prefix|>// repo: Killua67/curlconverter path: /fixtures/rust/post_with_da... | code_fim | medium | {
"lang": "rust",
"repo": "Killua67/curlconverter",
"path": "/fixtures/rust/post_with_data_raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn sqlite_setup() {}
pub fn sqlite_teardown(_: ()) {}
#[macro_export]
macro_rules! maketest {
($fname:ident, $backend:expr, $connstr:expr, $dataname:ident) => {
paste::item! {
#[test]
pub fn [<$fname _ $backend>]() {
env_logger::try_init().ok();
... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/butane",
"path": "/butane/tests/common/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! testall {
($fname:ident) => {
cfg_if::cfg_if! {
if #[cfg(feature = "sqlite")] {
maketest!($fname, sqlite, &format!(":memory:"), setup_data);
}
}
cfg_if::cfg_if! {
if #[cfg(feature = "pg")] {
... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/butane",
"path": "/butane/tests/common/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustWorks/butane path: /butane/tests/common/mod.rs
#![allow(dead_code)] //this module is used by multiple tests, not all use all parts
use butane::db::{Backend, Connection, ConnectionSpec};
use butane::migrations::{MemMigrations, Migration, Migrations, MigrationsMut};
pub mod blog;
#[cfg(featur... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/butane",
"path": "/butane/tests/common/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Farkal/diesel_geometry path: /src/doctest_setup.rs
#[macro_use]
extern crate cfg_if;
extern crate dotenv;
use diesel::prelude::*;
use diesel_geometry::prelude::*;
use self::dotenv::dotenv;
cfg_if! {
if #[cfg(feature = "postgres")] {
#[allow(dead_code)]
type DB = diesel::pg:... | code_fim | hard | {
"lang": "rust",
"repo": "Farkal/diesel_geometry",
"path": "/src/doctest_setup.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let connection = connection_no_transaction();
connection.begin_test_transaction().unwrap();
connection.execute("DROP TABLE IF EXISTS drawings CASCADE").unwrap();
connection.execute("DROP TABLE IF EXISTS shapes CASCADE").unwrap();
connection
... | code_fim | hard | {
"lang": "rust",
"repo": "Farkal/diesel_geometry",
"path": "/src/doctest_setup.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // a * b = b * a
assert_eq!(Uint256::from(u64::max_value() / 2) * Uint256::from(u64::max_value()),
Uint256::from(u64::max_value()) * Uint256::from(u64::max_value() / 2));
// 0x 010695afb4 71c944a6003cde34 bbf030a89c42b158
// *
// 0x 81 301220c079eedb8d
// =
// 0x 8482bc32fd a9bd6aa2e336b156 ... | code_fim | hard | {
"lang": "rust",
"repo": "hollywoodcoin-project/metamint",
"path": "/tests/uint256.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hollywoodcoin-project/metamint path: /tests/uint256.rs
extern crate metamint;
use metamint::utils::bignum::{Uint512, Uint256, Zero, One};
#[test]
fn test_zero() {
assert_eq!(Uint256::zero(), Uint256::from_raw([0; 4]));
assert_ne!(Uint256::zero(), Uint256::from_raw([1; 4]));
assert!(Uint256... | code_fim | hard | {
"lang": "rust",
"repo": "hollywoodcoin-project/metamint",
"path": "/tests/uint256.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 0x 7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffff
// divide by
// 0x 0000000000000000 ef2affdf53f0473c ebdcf3dfd3572173 113cf3ffdfff0071
// equal to
// 0x 890220e52de7a082
assert_eq!(Uint256::from_raw([0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x7fffffffffff... | code_fim | hard | {
"lang": "rust",
"repo": "hollywoodcoin-project/metamint",
"path": "/tests/uint256.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.