text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> debug!("RsyslogCollectorActor - received msg: [{}]", &msg.msg);
match self.collector.to_event(&msg.msg) {
Ok(event) => self.writer_addr.do_send(EventMessage { event }),
Err(e) => error!("RsyslogCollectorActor - Cannot unmarshal event from json: {}", e),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "danielsvitols/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let framed = FramedRead::new(source, codec).map(|msg| StringMessage { msg });
RsyslogCollectorActor::add_stream(framed, ctx);
RsyslogCollectorActor { collector: JsonPayloadCollector::new("syslog"), writer_addr }
});
}
}
impl Actor for RsyslogCollectorActor ... | code_fim | hard | {
"lang": "rust",
"repo": "danielsvitols/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielsvitols/tornado path: /tornado/rsyslog_collector/src/actors/collector.rs
use actix::prelude::*;
use log::*;
use tokio::io::AsyncRead;
use tokio::prelude::Stream;
use tokio_codec::{FramedRead, LinesCodec};
use tornado_collector_common::Collector;
use tornado_collector_json::JsonPayloadColle... | code_fim | medium | {
"lang": "rust",
"repo": "danielsvitols/tornado",
"path": "/tornado/rsyslog_collector/src/actors/collector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parralax_scrolling(
ship_position: Query<&Transform, With<Ship>>,
mut background_position: Query<(&mut Transform, &Layer), With<Background>>
) {
for ship in ship_position.iter() {
for (mut background, layer) in background_position.iter_mut() {
if layer.value == 1 {
... | code_fim | hard | {
"lang": "rust",
"repo": "BrunoWallner/space_shooter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrunoWallner/space_shooter path: /src/main.rs
use bevy::prelude::*;
use bevy::input::{keyboard::KeyCode, Input};
use rand::Rng;
struct Textures {
ship_texture: Handle<TextureAtlas>,
background_layer1_texture: Handle<TextureAtlas>,
background_layer2_texture: Handle<TextureAtlas>,
... | code_fim | hard | {
"lang": "rust",
"repo": "BrunoWallner/space_shooter",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A) {
rotation.angle += rotation_speed;
}
if keyboard_input.pressed(KeyCode::Right) || keyboard_input.pressed(KeyCode::D) {
rotation.angle -= rotation_speed;
}
if keyb... | code_fim | hard | {
"lang": "rust",
"repo": "BrunoWallner/space_shooter",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hencrice/upenn-cis198-2016-homework path: /hw01/src/problem2.rs
/// Represents a matrix in row-major order
pub type Matrix = Vec<Vec<f32>>;
/// Computes the product of the inputs `mat1` and `mat2`.
pub fn mat_mult(mat1: &Matrix, mat2: &Matrix) -> Matrix {
assert!(mat1.len() > 0, "mat1.len()... | code_fim | hard | {
"lang": "rust",
"repo": "hencrice/upenn-cis198-2016-homework",
"path": "/hw01/src/problem2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mat1 = vec![vec![1.; 3]; 4];
let mat2 = vec![vec![]; 3];
mat_mult(&mat1, &mat2);
}
#[test]
#[should_panic(expected = "mat1[0].len(): 3, mat2.len(): 6")]
fn test_mat1_col_count_ne_mat2_row_count() {
let mat1 = vec![vec![1.; 3]; 4];
let mat2 = vec... | code_fim | hard | {
"lang": "rust",
"repo": "hencrice/upenn-cis198-2016-homework",
"path": "/hw01/src/problem2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[should_panic(expected = "mat2[0].len(): 0")]
fn test_mat2_col_count_is_0() {
let mat1 = vec![vec![1.; 3]; 4];
let mat2 = vec![vec![]; 3];
mat_mult(&mat1, &mat2);
}
#[test]
#[should_panic(expected = "mat1[0].len(): 3, mat2.len(): 6")]
fn test_m... | code_fim | hard | {
"lang": "rust",
"repo": "hencrice/upenn-cis198-2016-homework",
"path": "/hw01/src/problem2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arnau/blot path: /blot-lib/src/multihash/sha2.rs
// Copyright 2018 Arnau Siches
//
// Licensed under the MIT license <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to
// those terms.
//! Blot implementation for sha2.
u... | code_fim | hard | {
"lang": "rust",
"repo": "arnau/blot",
"path": "/blot-lib/src/multihash/sha2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n: u64 = code.into();
if n == 0x12 {
Ok(Sha2256)
} else {
Err(MultihashError::Unknown)
}
}
}
impl Multihash for Sha2256 {
type Digester = digester::Sha256;
fn name(&self) -> &'static str {
"sha2-256"
}
fn code(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "arnau/blot",
"path": "/blot-lib/src/multihash/sha2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn digest_primitive(&self, tag: Tag, bytes: &[u8]) -> Harvest {
let mut digester = Self::Digester::default();
digester.input(&tag.to_bytes());
digester.input(bytes);
digester.result().as_ref().to_vec().into()
}
fn digest_collection(&self, tag: Tag, list: Vec<Ve... | code_fim | hard | {
"lang": "rust",
"repo": "arnau/blot",
"path": "/blot-lib/src/multihash/sha2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clonex10100/urbit-rust path: /src/nouns.rs
use ramp::int::Int;
use std::rc::Rc;
use std::fmt;
use std::str::FromStr;
use std::num::ParseIntError;
#[derive(Debug, Clone)]
pub struct NounError(pub String);
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Noun {
pub hash: i64,
pub conte... | code_fim | hard | {
"lang": "rust",
"repo": "clonex10100/urbit-rust",
"path": "/src/nouns.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn parse(s: &str) -> (&str, Noun) {
println!("{}", &s[0..1]);
if &s[0..1] == "[" {
println!("Cell");
let (s, p) = parse(&s[1..]);
assert_eq!(&s[0..1], " ");
let (s, q) = parse(&s[1..]);
let cell... | code_fim | hard | {
"lang": "rust",
"repo": "clonex10100/urbit-rust",
"path": "/src/nouns.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (_, noun) = parse(s);
return Ok(noun);
fn parse(s: &str) -> (&str, Noun) {
println!("{}", &s[0..1]);
if &s[0..1] == "[" {
println!("Cell");
let (s, p) = parse(&s[1..]);
assert_eq!(&s[0..1], " ");
... | code_fim | hard | {
"lang": "rust",
"repo": "clonex10100/urbit-rust",
"path": "/src/nouns.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mindsbackyard/galvanic-mock-lib path: /src/lib.rs
/* Copyright 2017 Christopher Bacher
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/... | code_fim | hard | {
"lang": "rust",
"repo": "mindsbackyard/galvanic-mock-lib",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !std::thread::panicking() && !self.are_expected_behaviours_satisfied() {
panic!("There are unsatisfied expected behaviours for mocked traits.");
}
}
}
impl std::ops::Drop for MockState {
/// Verfies the *expected interactions* on the mock if the policy is enabled.
... | code_fim | hard | {
"lang": "rust",
"repo": "mindsbackyard/galvanic-mock-lib",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// All matchers of the **galvanic-assert** crate can be used as `ArgMatcher`.
///
/// The crate's matchers can either be used to inspect a single argument or all of them (in curried form).
#[cfg(feature = "galvanic_assert_integration")]
impl<'a, T: 'a> ArgMatcher<'a, T> for Box<::galvanic_assert::Matcher... | code_fim | hard | {
"lang": "rust",
"repo": "mindsbackyard/galvanic-mock-lib",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Not all windows have titles, ignore those that don't
if read_len > 0 {
v.set_len((read_len) as usize);
let string = String::from_utf16_lossy(&v);
let wide_string: Vec<u16> = OsStr::new(string.as_str()).encode_wide().chain(once(0)).collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "pingzing/rust-vlc-finder",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pingzing/rust-vlc-finder path: /src/main.rs
use std::env;
use std::process::Command;
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use std::iter::once;
extern crate winapi;
extern crate user32;
fn main() {
<|fim_suffix|>unsafe extern "system" fn enumerate_callback(
hwnd: winapi... | code_fim | hard | {
"lang": "rust",
"repo": "pingzing/rust-vlc-finder",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: faustfu/hello_rust path: /src/doc1.rs
// use "cargo doc --open" to generate <|fim_suffix|>
/// println!("Hello, world!");
/// ```
pub fn run() {
println!("doc111");
}<|fim_middle|>project documents
/// # hi
/// ```rust | code_fim | easy | {
"lang": "rust",
"repo": "faustfu/hello_rust",
"path": "/src/doc1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn run() {
println!("doc111");
}<|fim_prefix|>// repo: faustfu/hello_rust path: /src/doc1.rs
// use "cargo doc --open" to generate project documents
/// # hi
/// ```rust<|fim_middle|>
/// println!("Hello, world!");
/// ``` | code_fim | easy | {
"lang": "rust",
"repo": "faustfu/hello_rust",
"path": "/src/doc1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: faustfu/hello_rust path: /src/doc1.rs
// use "cargo doc --open" to generate <|fim_suffix|>
pub fn run() {
println!("doc111");
}<|fim_middle|>project documents
/// # hi
/// ```rust
/// println!("Hello, world!");
/// ``` | code_fim | medium | {
"lang": "rust",
"repo": "faustfu/hello_rust",
"path": "/src/doc1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niuyuling/denyhosts path: /clamav/libclamav_rust/.cargo/vendor/exr/benches/read.rs
#[macro_use]
extern crate bencher;
extern crate exr;
use exr::prelude::*;
use bencher::Bencher;
use std::fs;
use std::io::Cursor;
use exr::image::pixel_vec::PixelVec;
/// Read uncompressed (always si... | code_fim | hard | {
"lang": "rust",
"repo": "niuyuling/denyhosts",
"path": "/clamav/libclamav_rust/.cargo/vendor/exr/benches/read.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> bench.iter(||{
let image = exr::prelude::read()
.no_deep_data().largest_resolution_level()
.rgba_channels(PixelVec::<(f16,f16,f16,f16)>::constructor, PixelVec::set_pixel)
.all_layers().all_attributes()
.from_buffered(Cursor::new(file.as_slic... | code_fim | hard | {
"lang": "rust",
"repo": "niuyuling/denyhosts",
"path": "/clamav/libclamav_rust/.cargo/vendor/exr/benches/read.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = context
.vm
.environments
.resolve_private_identifier(name)
.expect("private name must be in environment");
let result = base_obj.private_get(&name, context)?;
context.vm.push(result);
Ok(CompletionType::Normal)
... | code_fim | hard | {
"lang": "rust",
"repo": "boa-dev/boa",
"path": "/boa_engine/src/vm/opcode/get/private.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boa-dev/boa path: /boa_engine/src/vm/opcode/get/private.rs
use crate::{
vm::{opcode::Operation, CompletionType},
Context, JsResult,
};
/// `GetPrivateField` implements the Opcode Operation for `Opcode::GetPrivateField`
///
/// Operation:
/// - Get a private property by name from an obj... | code_fim | hard | {
"lang": "rust",
"repo": "boa-dev/boa",
"path": "/boa_engine/src/vm/opcode/get/private.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.url.clone() {
Some(url) => {
btree.insert(String::from("url"), QueryValue::String(url));
}
None => {
btree.insert(String::from("url"), QueryValue::Null);
}
}
match self.struct_type.clone() {... | code_fim | hard | {
"lang": "rust",
"repo": "jcarva/likemark-backend",
"path": "/src/common/criteria.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcarva/likemark-backend path: /src/common/criteria.rs
use common::utils::QueryValue;
use std::collections::BTreeMap;
use common::tree_id::*;
use common::types::FnType;
use common::types::StructType;
#[derive(Debug, Clone)]
pub struct Criteria {
id: Option<i32>,
tree_id: Option<TreeId>,... | code_fim | hard | {
"lang": "rust",
"repo": "jcarva/likemark-backend",
"path": "/src/common/criteria.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn map(&self) -> BTreeMap<String, QueryValue> {
let mut btree: BTreeMap<String, QueryValue> = BTreeMap::new();
match self.id {
Some(id) => {
btree.insert(String::from("id"), QueryValue::Integer(id));
}
None => {
b... | code_fim | hard | {
"lang": "rust",
"repo": "jcarva/likemark-backend",
"path": "/src/common/criteria.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pipehappy1/auto-diff path: /ann/src/minibatch.rs
use ::rand::prelude::StdRng;
use auto_diff::{Var, AutoDiffError};
use auto_diff_data_pipe::dataloader::{DataLoader, DataSlice};
pub struct MiniBatch {
rng: StdRng,
size: usize,
}
impl MiniBatch {
pub fn new(rng: StdRng, size: usize) -... | code_fim | hard | {
"lang": "rust",
"repo": "pipehappy1/auto-diff",
"path": "/ann/src/minibatch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sample_size != sample_size2 {
return Err(AutoDiffError::new(&format!("minibatch needs data and label has the same N {}, {}",
sample_size, sample_size2)));
}
let index_t = Var::rand_usize(&mut self.rng, &[self.size], ... | code_fim | hard | {
"lang": "rust",
"repo": "pipehappy1/auto-diff",
"path": "/ann/src/minibatch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dorucioclea/oso path: /languages/rust/oso/benches/bench.rs
//! Benchmarks of blog post things
use oso::{Class, Oso, ToPolar};
use criterion::{criterion_group, criterion_main, Criterion};
<|fim_suffix|> c.bench_function("rust_get_attribute", |b| {
b.iter_batched_ref(
|| ... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/oso",
"path": "/languages/rust/oso/benches/bench.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("rust_get_attribute", |b| {
b.iter_batched_ref(
|| {
let mut oso = Oso::new();
oso.load_str("foo_x_is_one(foo: Foo) if foo.x = 1;")
.unwrap();
oso.register_class(
Class::builder... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/oso",
"path": "/languages/rust/oso/benches/bench.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut value = 1;
for _ in 0..loop_size {
value = (value * subject_number) % MODULUS;
}
return value;
}<|fim_prefix|>// repo: gmyr/advent_of_code_2020 path: /aoc25/src/main.rs
static MODULUS: u64 = 20201227;
fn main() {
let card_key = 15335876;
let door_key = 15086442;
... | code_fim | medium | {
"lang": "rust",
"repo": "gmyr/advent_of_code_2020",
"path": "/aoc25/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gmyr/advent_of_code_2020 path: /aoc25/src/main.rs
static MODULUS: u64 = 20201227;
fn main() {
let card_key = 15335876;
let door_key = 15086442;
println!("part 1: {}", transform(door_key, loop_size(7, card_key)));
println!("part 2: Merry Christmas!");
}
fn loop_size(subject_numb... | code_fim | medium | {
"lang": "rust",
"repo": "gmyr/advent_of_code_2020",
"path": "/aoc25/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fn consume(self: Pin<&mut Self>, amt: usize) {
// Pin::new(self).cursor += amt;
// }
// }
/// The sending side of the encoder.
#[derive(Debug)]
pub struct Sender(sync::Sender<Vec<u8>>);
/// Create a new SSE encoder.
pub fn encode() -> (Sender, Encoder) {
let (sender, receiver) = s... | code_fim | hard | {
"lang": "rust",
"repo": "RangerStation/alexandrie-run",
"path": "/.cargo/registry/src/github.com-1ecc6299db9ec823/async-sse-3.0.0/src/encoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rust-2018/edition-lint-nested-paths.rs
// run-rustfix
#![feature(rust_2018_preview, crate_visibility_modifier)]
#![deny(absolute_paths_not_starting_with_crate)]
<|fim_suffix|> a();
b();
{
use foo::{self as x, c};
//... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rust-2018/edition-lint-nested-paths.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
use foo::{self as x, c};
//~^ ERROR absolute paths must start with
//~| this was previously accepted
x::a();
c();
}
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rust-2018/edition-lint-nested-paths.rs
// run-rustfix
#![featur... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rust-2018/edition-lint-nested-paths.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Json(val)
}
}
impl<T> Deref for Json<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T: DeserializeOwned + 'static> FromData for Json<T> {
fn from_data<U>(data: Bytes, request: &Request<U>) -> Result<Json<T>, Error> {
if let Some(h) ... | code_fim | hard | {
"lang": "rust",
"repo": "AhmedMostafa16/Silver",
"path": "/src/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AhmedMostafa16/Silver path: /src/json.rs
use bytes::Bytes;
use http::header::HeaderValue;
use http::{header, Request, Response};
use mime::{self, Mime};
use serde::de::DeserializeOwned;
use serde::ser::Serialize;
use serde_json;
use std::ops::Deref;
use error::handler::ErrorHandler;
use error::... | code_fim | hard | {
"lang": "rust",
"repo": "AhmedMostafa16/Silver",
"path": "/src/json.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Responder for JsonValue {
fn respond_to<T>(self, _: &Request<T>) -> Result<Output, Error> {
Ok(json_response(self.0.to_string()))
}
}
#[derive(Debug, Default)]
pub struct JsonErrorHandler {
_priv: (),
}
impl JsonErrorHandler {
pub fn new() -> JsonErrorHandler {
Defau... | code_fim | hard | {
"lang": "rust",
"repo": "AhmedMostafa16/Silver",
"path": "/src/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::io::Cursor;
let data = vec![
"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd",
"byr:1937 iyr:2017 cid:147 hgt:183cm",
"",
"iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884",
"hcl:#cfa07d byr:1929",
"",
"hcl:#ae17e1 iyr:2013",
"eyr... | code_fim | hard | {
"lang": "rust",
"repo": "vernonrj/advent2020",
"path": "/day-4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_read_batch() {
use std::io::Cursor;
let data = vec![
"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd",
"byr:1937 iyr:2017 cid:147 hgt:183cm",
"",
"iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884",
"hcl:#cfa07d byr:1929",
"",
"hcl:... | code_fim | hard | {
"lang": "rust",
"repo": "vernonrj/advent2020",
"path": "/day-4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vernonrj/advent2020 path: /day-4/src/main.rs
#[macro_use] extern crate lazy_static;
use std::convert::TryFrom;
use std::{error::Error, str::FromStr};
use std::fs::File;
use std::io::{Read, BufRead, BufReader};
use clap::{App, Arg};
mod validated_passport;
use validated_passport::ValidatedPass... | code_fim | hard | {
"lang": "rust",
"repo": "vernonrj/advent2020",
"path": "/day-4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> s.emit_struct("ShippingMethod", 1, |s| {
s.emit_struct_field("ShippingOption", 0, |s| self.shipping_option.encode(s))?;
Ok(())
})
}
}<|fim_prefix|>// repo: archer884/order-builder path: /src/shipping_method.rs
use rustc_serialize::{Encodable, Encoder};
#[deriv... | code_fim | medium | {
"lang": "rust",
"repo": "archer884/order-builder",
"path": "/src/shipping_method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: archer884/order-builder path: /src/shipping_method.rs
use rustc_serialize::{Encodable, Encoder};
#[derive(Debug)]
pub struct ShippingMethod {
shipping_option: String,
}
impl ShippingMethod {
pub fn new() -> ShippingMethod {
ShippingMethod {
shipping_option: "0".to_o... | code_fim | medium | {
"lang": "rust",
"repo": "archer884/order-builder",
"path": "/src/shipping_method.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datum-lang/movable path: /reader/src/domain/lang_default.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Partial<|fim_suffix|>main_func: String,
/// e.g. in JavaScript or Python or Ruby, can just run without main func.
pub is_script: bool,
}<|fim_middle|>Eq, Serialize, Deseriali... | code_fim | medium | {
"lang": "rust",
"repo": "datum-lang/movable",
"path": "/reader/src/domain/lang_default.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>main_func: String,
/// e.g. in JavaScript or Python or Ruby, can just run without main func.
pub is_script: bool,
}<|fim_prefix|>// repo: datum-lang/movable path: /reader/src/domain/lang_default.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Partial<|fim_middle|>Eq, Serialize, Deseriali... | code_fim | medium | {
"lang": "rust",
"repo": "datum-lang/movable",
"path": "/reader/src/domain/lang_default.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nocproject/noc path: /rust/agent/src/collectors/block_io/out.rs
// ---------------------------------------------------------------------
// BlockIoOut
// ---------------------------------------------------------------------
// Copyright (C) 2007-2021 The NOC Project
// See LICENSE for details
//... | code_fim | medium | {
"lang": "rust",
"repo": "nocproject/noc",
"path": "/rust/agent/src/collectors/block_io/out.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize)]
pub struct BlockIoOut {
pub read_ios: usize,
pub read_merges: usize,
pub read_sectors: usize,
pub read_ticks: usize,
pub write_ios: usize,
pub write_merges: usize,
pub write_sectors: usize,
pub write_ticks: usize,
pub in_flight: usize,
pub io_ti... | code_fim | medium | {
"lang": "rust",
"repo": "nocproject/noc",
"path": "/rust/agent/src/collectors/block_io/out.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ClientFactory {
pub fn account(config: AccountConfig) -> Result<Box<Account>> {
match &config.provider[..] {
"binance" => Ok(Box::new(BinanceAccount::new(config)?)),
"coinbase" => Ok(Box::new(CoinbaseAccount::new(config)?)),
"coinbasepro" => Ok(Box::new(CoinbaseProAccount::new... | code_fim | medium | {
"lang": "rust",
"repo": "MotleyCap/coin",
"path": "/lib/coin-sdk/src/client_factory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MotleyCap/coin path: /lib/coin-sdk/src/client_factory.rs
use crate::errors::*;
use crate::account::Account;
use crate::model::AccountConfig;
use crate::binance::BinanceAccount;
use crate::coinbase::CoinbaseAccount;
use crate::coinbasepro::CoinbaseProAccount;
use crate::offline::OfflineAccount;
... | code_fim | medium | {
"lang": "rust",
"repo": "MotleyCap/coin",
"path": "/lib/coin-sdk/src/client_factory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiifabbf/ray-tracer-wasm path: /src/lib.rs
extern crate ray_tracer;
use ray_tracer::camera;
use ray_tracer::camera::Camera;
use ray_tracer::geometry::Cube;
use ray_tracer::geometry::Rectangle;
use ray_tracer::geometry::Sphere;
use ray_tracer::mat4::Mat4;
use ray_tracer::material::Dielectric;
us... | code_fim | hard | {
"lang": "rust",
"repo": "aiifabbf/ray-tracer-wasm",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lightMaterial = Arc::new(DiffuseLight::new(Vec3::new(7.0, 7.0, 7.0)));
let light = Arc::new(
Sprite::builder()
.geometry(Rectangle::new(300.0, 265.0).into())
.material(lightMaterial)
.transform(
Mat4::translation(Vec3::new(273.0, 554.... | code_fim | hard | {
"lang": "rust",
"repo": "aiifabbf/ray-tracer-wasm",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arora-aditya/just-another-ray-tracer path: /src/material/dielectric.rs
use crate::material::base::Material;
use crate::material::base::ScatterRecord;
use crate::objects::hittable::HitRecord;
use crate::tracer::color::Color3;
use crate::tracer::ray::Ray;
use crate::tracer::vec3::{self, Vec3};
use... | code_fim | hard | {
"lang": "rust",
"repo": "arora-aditya/just-another-ray-tracer",
"path": "/src/material/dielectric.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut r0: f32 = (1.0 - ref_idx) / (1.0 + ref_idx);
r0 = r0*r0;
r0 + (1.0-r0)*(1.0 - cosine).powf(5.0)
}
impl Material for DielectricMaterial {
fn scatter(&self, mut random: &mut Random, r_in: Ray, hit_record: HitRecord) -> Option<ScatterRecord> {
let attenuation: Color3 ... | code_fim | hard | {
"lang": "rust",
"repo": "arora-aditya/just-another-ray-tracer",
"path": "/src/material/dielectric.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn schlick(cosine: f32, ref_idx: f32) -> f32 {
let mut r0: f32 = (1.0 - ref_idx) / (1.0 + ref_idx);
r0 = r0*r0;
r0 + (1.0-r0)*(1.0 - cosine).powf(5.0)
}
impl Material for DielectricMaterial {
fn scatter(&self, mut random: &mut Random, r_in: Ray, hit_record: HitRecord) -> Option<ScatterRec... | code_fim | hard | {
"lang": "rust",
"repo": "arora-aditya/just-another-ray-tracer",
"path": "/src/material/dielectric.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bigbang231/mikack-cli path: /src/bin/main.rs
use indicatif::ProgressBar;
use lazy_static::lazy_static;
use mikack::{
extractors::{self, DomainRoute, Extractor},
models::*,
};
use mikack_cli::{exporters, *};
use std::collections::HashMap;
use std::sync::Mutex;
lazy_static! {
static r... | code_fim | hard | {
"lang": "rust",
"repo": "bigbang231/mikack-cli",
"path": "/src/bin/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let spinner = create_spinner("Fetching...");
extractor.fetch_chapters(comic)?;
spinner.finish_and_clear();
for (i, chapter) in comic.chapters.iter().enumerate() {
println!("{}. {}", i + 1, chapter.title);
}
let chapter_s = read_input_as_string("\nPlease enter chapter number... | code_fim | hard | {
"lang": "rust",
"repo": "bigbang231/mikack-cli",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RawConfig {
/// Processes the raw config into a `Config` instance.
/// This method relies on the this value being a `RawConfig::Hash`, otherwise a `ConfigError` is
/// returned. The `RCHash` contained in it must contain an integer "version" field, as this will
/// determine how furthe... | code_fim | hard | {
"lang": "rust",
"repo": "michd/mmpd",
"path": "/mmpd-lib/src/config/raw_config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michd/mmpd path: /mmpd-lib/src/config/raw_config.rs
//! Intermediary config value format and tools to parse `RawConfig` into full formed `Config`
use std::fmt::{self, Display, Formatter};
use linked_hash_map::LinkedHashMap;
use crate::config::{Config, ConfigError, versions};
/// The type `Li... | code_fim | hard | {
"lang": "rust",
"repo": "michd/mmpd",
"path": "/mmpd-lib/src/config/raw_config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gallegogt/mailchimp-rs path: /src/types/conversations.rs
//! Conversations
//!
use super::conversation_messages::{
CollectionConversationMessages, ConversationMessage, MessagesBuider, MessagesFilter,
};
use serde::{Deserialize, Serialize};
use std::rc::Rc;
use super::link::LinkType;
use cr... | code_fim | hard | {
"lang": "rust",
"repo": "gallegogt/mailchimp-rs",
"path": "/src/types/conversations.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.has_unread_messages.is_some() {
payload.insert(
"has_unread_messages".to_string(),
format!("{:}", self.has_unread_messages.as_ref().unwrap().clone()),
);
}
if self.list_id.is_some() {
payload.insert(
... | code_fim | hard | {
"lang": "rust",
"repo": "gallegogt/mailchimp-rs",
"path": "/src/types/conversations.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut endpoint = "conversations/".to_string();
endpoint.push_str(&self.id);
endpoint
}
}
///
/// Collection Conversations
///
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CollectionConversations {
/// Recent list activity.
#[serde(default)]
pub conv... | code_fim | hard | {
"lang": "rust",
"repo": "gallegogt/mailchimp-rs",
"path": "/src/types/conversations.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zsytssk/rust path: /saveScript/resultDemo.rs
fn main() {
let result = parse_context(Context("hello"));
println!("{:?}", result);
}
<|fim_suffix|> Parser{context: &context}.parse()
}
struct Context<'s>(&'s str);
struct Parser<'c, 's: 'c> {
context: &'c Context<'s>,
}
impl<'c, '... | code_fim | medium | {
"lang": "rust",
"repo": "zsytssk/rust",
"path": "/saveScript/resultDemo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'c, 's> Parser<'c,'s> {
fn parse(&self) -> Result<&'s str, String> {
let len = &self.context.0.len();
let max = 10;
if *len > max {
Ok(&self.context.0[..])
} else {
let err_str =format!("string not long enogh:{}", max);
Err(Strin... | code_fim | medium | {
"lang": "rust",
"repo": "zsytssk/rust",
"path": "/saveScript/resultDemo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ayrat-playground/exercism_rust path: /diffie-hellman/src/lib.rs
pub fn private_key(p: u64) -> u64 {
// this value should be random (I don't want to use external dependency)
// Rust does not have random module in std library
p - 1
}
<|fim_suffix|>pub fn secret(p: u64, b_pub: u64, a: ... | code_fim | medium | {
"lang": "rust",
"repo": "ayrat-playground/exercism_rust",
"path": "/diffie-hellman/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 {
b_pub.pow(a as u32) % p
}<|fim_prefix|>// repo: ayrat-playground/exercism_rust path: /diffie-hellman/src/lib.rs
pub fn private_key(p: u64) -> u64 {
// this value should be random (I don't want to use external dependency)
// Rust does not have... | code_fim | medium | {
"lang": "rust",
"repo": "ayrat-playground/exercism_rust",
"path": "/diffie-hellman/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ava57r/yandex-checkout-rs path: /src/models/receipt.rs
use crate::models::amount::Amount;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ReceiptRegistrationStatus {
Pending,
Succeeded,
Canceled,
}
#[derive(Seriali... | code_fim | hard | {
"lang": "rust",
"repo": "ava57r/yandex-checkout-rs",
"path": "/src/models/receipt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PaymentSubject {
Commodity,
Excise,
Job,
Service,
GamblingBet,
GamblingPrize,
Lottery,
LotteryPrize,
IntellectualActivity,
Payment,
AgentCommission,
PropertyRight,
NonOperatin... | code_fim | hard | {
"lang": "rust",
"repo": "ava57r/yandex-checkout-rs",
"path": "/src/models/receipt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DouliDev/rustacean path: /src/commands/exec/shell.rs
use std::path::PathBuf;
use commands::exec::language::Language;
use duct::{ cmd, Expression };
#[derive(Debug)]
pub struct Shell;
impl Language for Shell {
fn get_lang_name(&self) -> String {
<|fim_suffix|> cmd!("sh", path)
... | code_fim | medium | {
"lang": "rust",
"repo": "DouliDev/rustacean",
"path": "/src/commands/exec/shell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ".sh".into()
}
fn get_execution_command(&self, path: &PathBuf) -> Expression {
cmd!("sh", path)
}
fn check_compiler_or_interpreter(&self) -> Expression {
cmd!("sh", "-c", "echo \"ok\"")
}
}<|fim_prefix|>// repo: DouliDev/rustacean path: /src/commands/exec... | code_fim | medium | {
"lang": "rust",
"repo": "DouliDev/rustacean",
"path": "/src/commands/exec/shell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = input.len() - input.len() / 4;
let mut output = Vec::with_capacity(size);
for pixel in input.chunks(4) {
let c = pixel[0] as f32 / 255.0;
let m = pixel[1] as f32 / 255.0;
let y = pixel[2] as f32 / 255.0;
let k = pixel[3] as f32 / 255.0;
// C... | code_fim | hard | {
"lang": "rust",
"repo": "emilio/jpeg-decoder",
"path": "/examples/decode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emilio/jpeg-decoder path: /examples/decode.rs
extern crate jpeg_decoder as jpeg;
extern crate png;
use png::HasParameters;
use std::env;
use std::fs::File;
use std::io::BufReader;
fn print_usage(name: &str) {
println!("Usage: {} [--output <pngfile>] <file>", name);
}
fn main() {
let a... | code_fim | hard | {
"lang": "rust",
"repo": "emilio/jpeg-decoder",
"path": "/examples/decode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Native object for the result of a cryptographic key import operation.
///
/// The true result is sent in the `status` field of the response header.
#[derive(Debug)]
pub struct ResultImportKey;<|fim_prefix|>// repo: hug-dev/parsec-interface-rs path: /src/operations/import_key.rs
// Copyright (c) 2019,... | code_fim | hard | {
"lang": "rust",
"repo": "hug-dev/parsec-interface-rs",
"path": "/src/operations/import_key.rs",
"mode": "spm",
"license": "LicenseRef-scancode-dco-1.1",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hug-dev/parsec-interface-rs path: /src/operations/import_key.rs
// Copyright (c) 2019, Arm Limited, All Rights Reserved
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.... | code_fim | hard | {
"lang": "rust",
"repo": "hug-dev/parsec-interface-rs",
"path": "/src/operations/import_key.rs",
"mode": "psm",
"license": "LicenseRef-scancode-dco-1.1",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hinagis/typical90 path: /src/bin/075.rs
fn main() {
proconio::input! {n: u64}
let mut c = 0;
let mut r = n;
let mut i = 2;
while i * i <= <|fim_suffix|>
println!("0");
} else {
if r != 1 {
c += 1;
}
let mut r = 1;
let m... | code_fim | medium | {
"lang": "rust",
"repo": "hinagis/typical90",
"path": "/src/bin/075.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>et mut p = 2;
while p < c {
p *= 2;
r += 1;
}
println!("{}", r);
}
}<|fim_prefix|>// repo: hinagis/typical90 path: /src/bin/075.rs
fn main() {
proconio::input! {n: u64}
let mut c = 0;
let mut r = n;
let mut i = 2;
while i * i <= n {... | code_fim | medium | {
"lang": "rust",
"repo": "hinagis/typical90",
"path": "/src/bin/075.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kildevaeld/tasks-rs path: /band/src/error.rs
use std::error::Error as StdError;
use std::fmt;
#[derive(Debug)]
pub enum Error {
TaskNotFound(String),
InvalidDepency(String),
Rejected,
External(Box<dyn StdError + Send>),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut ... | code_fim | easy | {
"lang": "rust",
"repo": "kildevaeld/tasks-rs",
"path": "/band/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Box<dyn StdError + Send>> for Error {
fn from(error: Box<dyn StdError + Send>) -> Self {
Error::External(error)
}
}<|fim_prefix|>// repo: kildevaeld/tasks-rs path: /band/src/error.rs
use std::error::Error as StdError;
use std::fmt;
#[derive(Debug)]
pub enum Error {
TaskNotF... | code_fim | medium | {
"lang": "rust",
"repo": "kildevaeld/tasks-rs",
"path": "/band/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
impl StdError for Error {}
impl From<Box<dyn StdError + Send>> for Error {
fn from(error: Box<dyn StdError + Send>) -> Self {
Error::External(error)
}
}<|fim_prefix|>// repo: kildevaeld/tasks-rs path: /band/src/error.rs
use std::error::Error as StdError;
use std::... | code_fim | medium | {
"lang": "rust",
"repo": "kildevaeld/tasks-rs",
"path": "/band/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hntd187/bayard path: /src/server/util.rs
use crate::proto::indexpb_grpc::IndexClient;
use crate::proto::indexrpcpb::{ConfChangeReq, RaftDone, RespErr};
use log::*;
use protobuf::{self, Message};
use raft::Config;
use std::collections::HashMap;
<|fim_suffix|>pub fn conf_change(
self_id: u64,... | code_fim | hard | {
"lang": "rust",
"repo": "hntd187/bayard",
"path": "/src/server/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_data<T: Message>(data: &[u8]) -> T {
protobuf::parse_from_bytes::<T>(data).unwrap_or_else(|e| {
panic!("data is corrupted: {:?}", e);
})
}
pub fn conf_change(
self_id: u64,
leader_id: u64,
peers: &HashMap<u64, IndexClient>,
req: ConfChangeReq,
) {
let clie... | code_fim | hard | {
"lang": "rust",
"repo": "hntd187/bayard",
"path": "/src/server/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn conf_change(
self_id: u64,
leader_id: u64,
peers: &HashMap<u64, IndexClient>,
req: ConfChangeReq,
) {
let client = peers.get(&leader_id).unwrap();
let reply = client.raft_conf_change(&req).unwrap_or_else(|_e| {
let mut resp = RaftDone::new();
resp.set_err(Res... | code_fim | medium | {
"lang": "rust",
"repo": "hntd187/bayard",
"path": "/src/server/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /node/src/components/gossiper/event.rs
use std::{
collections::HashSet,
fmt::{self, Display, Formatter},
};
use serde::Serialize;
use super::{Item, Message};
use crate::{
types::NodeId,
utils::{DisplayIter, Source},
};
/// `Gossiper` ev... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/node/src/components/gossiper/event.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Event::ItemReceived { item_id, source } => {
write!(formatter, "new item {} received from {}", item_id, source)
}
Event::GossipedTo { item_id, peers, .. } => write!(
formatter,
"gossiped {} to {}",
... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/node/src/components/gossiper/event.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnflanigan/compilers path: /catc/src/test_type_check.rs
use crate::check_type::type_check;
use crate::source_grammar::*;
use std::collections::VecDeque;
// In the future we will have a parser (woot, woot)
//use crate::tiger::{ProgramParser};
#[test]
fn test_int_lit() {
let body = Box::new(... | code_fim | hard | {
"lang": "rust",
"repo": "johnflanigan/compilers",
"path": "/catc/src/test_type_check.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_bad_array_bad_init() {
let program = r#"
type intArray = array of int
function main (): void {
let var a : intArray := intArray [10] of "20" in
()
end
}
"#;
// print!("{:#?}", ProgramParser::new().parse(program).unwrap());
type_check(P... | code_fim | hard | {
"lang": "rust",
"repo": "johnflanigan/compilers",
"path": "/catc/src/test_type_check.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.a.item_size() + self.b.item_size()
}
// fn buffered_next(
// &mut self,
// mem_region: OneSidedMemoryRegion<u8>,
// ) -> Option<Box<dyn LamellarArrayRequest<Output = ()>>> {
// let a_sub_region = mem_region.sub_region(0..self.a.item_size());
// let ... | code_fim | hard | {
"lang": "rust",
"repo": "pnnl/lamellar-runtime",
"path": "/src/array/iterator/one_sided_iterator/zip.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnnl/lamellar-runtime path: /src/array/iterator/one_sided_iterator/zip.rs
use crate::array::iterator::one_sided_iterator::*;
// use crate::array::LamellarArrayRequest;
// use crate::memregion::OneSidedMemoryRegion;
// use async_trait::async_trait;
use pin_project::pin_project;
// struct ZipBuf... | code_fim | hard | {
"lang": "rust",
"repo": "pnnl/lamellar-runtime",
"path": "/src/array/iterator/one_sided_iterator/zip.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 5hadowblad3/healer path: /healer_core/src/parse/mod.rs
parsing tree first
let call_nodes = SyntaxParser::parse(Rule::Prog, p)?;
let mut calls = Vec::new();
for node in call_nodes.filter(|node| node.as_rule() != Rule::EOI) {
let call = convert_call(target, node)?;
ca... | code_fim | hard | {
"lang": "rust",
"repo": "5hadowblad3/healer",
"path": "/healer_core/src/parse/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "bad ptr addr value")
}
}
impl std::error::Error for BadPtrAddrError {}
fn parse_addr(node: Node) -> Result<u64, ParseError> {
let raw_addr = parse_int(node.clone())?;
if raw_addr < ENCODING_ADDR_BASE {
Err(value_error(node.as_span(), BadPtrAddrError))
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "5hadowblad3/healer",
"path": "/healer_core/src/parse/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ty = ty.checked_as_ptr();
let elem_ty = target.ty_of(ty.elem());
let elem_dir = ty.dir();
let mut nodes = node.into_inner();
let addr_node = nodes.next().unwrap();
let addr = match addr_node.as_rule() {
Rule::Int => parse_addr(addr_node)?,
Rule::Auto => 0, // f... | code_fim | hard | {
"lang": "rust",
"repo": "5hadowblad3/healer",
"path": "/healer_core/src/parse/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for layer in iter {
let collected = layer.to_vec();
println!("collected? {:?}",collected );
println!("count? {:?}",collected.len() );
let num_zeros = count_string(collected.clone(), "0".to_string());
println!("zeros? {}",num_zeros );
if num_zeros != 0 &... | code_fim | hard | {
"lang": "rust",
"repo": "kamn/advent_of_code_2019",
"path": "/src/day8a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kamn/advent_of_code_2019 path: /src/day8a.rs
use std::fs;
fn read_file() -> String {
println!("Reading file?");
let contents = fs::read_to_string("day8.txt")
.expect("Something went wrong reading the file");
//println!("With text:\n{}", contents);
contents.to_owned... | code_fim | hard | {
"lang": "rust",
"repo": "kamn/advent_of_code_2019",
"path": "/src/day8a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn test_day8a_count_str() {
let example1 = "123456789012";
let x : Vec<String> = example1.to_string().split("").map(ToOwned::to_owned).collect();
assert_eq!(count_string(x.to_owned(), "1".to_string()), 2);
assert_eq!(count_string(x.to_owned(), "5".to_string()), 1);
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "kamn/advent_of_code_2019",
"path": "/src/day8a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/** Resolution 0 base cell lookup table for each face.
*
* Given the face number and a resolution 0 ijk+ coordinate in that face's
* face-centered ijk coordinate system, gives the base cell located at that
* coordinate and the number of 60 ccw rotations to rotate into that base
* cell's orientation.
... | code_fim | hard | {
"lang": "rust",
"repo": "worace/h3-rs",
"path": "/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: worace/h3-rs path: /src/constants.rs
],
[
// i 2
[[117, 4], [118, 5], [114, 5]], // j 0
[[106, 1], [109, 0], [108, 0]], // j 1
[[90, 1], [93, 1], [95, 0]] // j 2
]],
[// face 16
[
// i 0
... | code_fim | hard | {
"lang": "rust",
"repo": "worace/h3-rs",
"path": "/src/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/** Resolution 0 base cell data table.
For each base cell, gives:
* The "home" face and ijk+ coordinates on that face
* Whether or not the base cell is a pentagon.
* Additionally, if the base cell is a pentagon,
the two cw offset rotation adjacent faces are given if available.
*/
pub static BASE_CE... | code_fim | hard | {
"lang": "rust",
"repo": "worace/h3-rs",
"path": "/src/constants.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.