text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut delay = arduino_leonardo::Delay::new();
let mut pins = arduino_leonardo::Pins::new(dp.PORTB, dp.PORTC, dp.PORTD, dp.PORTE);
// According to the manual, PC7(D13) is connected to Timer/Counter4
// If you don't want to look it up, just try supplying a wrong one, rustc will
// tel... | code_fim | medium | {
"lang": "rust",
"repo": "Rahix/leonardo-examples",
"path": "/src/pwm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rahix/leonardo-examples path: /src/pwm.rs
//! PWM
//! ===
//!
//! Example of using a pwm pin
#![no_std]
#![no_main]
extern crate arduino_leonardo;
extern crate atmega32u4;
extern crate atmega32u4_hal;
use arduino_leonardo::prelude::*;
#[no_mangle]
pub extern fn main() {
let dp = atmega32u4... | code_fim | hard | {
"lang": "rust",
"repo": "Rahix/leonardo-examples",
"path": "/src/pwm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
InternalError::Other(string) => write!(f, "{}", string),
}
}
}<|fim_prefix|>// repo: m10io/L3-37 path: /src/error.rs
#[derive(Debug)]
pub enum InternalError {
Other(String),
}
impl std::error::Error for InternalError {
fn source(&self) -> Option<&(dyn... | code_fim | medium | {
"lang": "rust",
"repo": "m10io/L3-37",
"path": "/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m10io/L3-37 path: /src/error.rs
#[derive(Debug)]
pub enum InternalError {
Other(String),
}
<|fim_suffix|>impl std::fmt::Display for InternalError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
InternalError::Other(string) => write!(f,... | code_fim | medium | {
"lang": "rust",
"repo": "m10io/L3-37",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn fetch(&self,
function: ConsolidationFunction,
start: time_t,
end: time_t,
step: u64)
-> Result<HashMap<String, &[f64]>, Error> {
let mut num_of_data_sources: u_long = 0;
let mut names_of_data_so... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-rrd",
"path": "/src/rrd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result != 0 {
Err(Error::RrdError(unsafe { CString::from_raw(rrd_get_error()) }))
} else {
let name_slices = unsafe {
std::slice::from_raw_parts(names_of_data_sources, num_of_data_sources as usize)
};
let names = name_slice... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-rrd",
"path": "/src/rrd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azdlowry/rust-rrd path: /src/rrd.rs
use librrd_sys::*;
use std::ffi::*;
use error::*;
use std;
use std::os::raw::c_char;
use std::collections::HashMap;
pub struct Database {
filename: CString,
}
impl Database {
pub fn open(filename: String) -> Result<Database, Error> {
Ok(Datab... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-rrd",
"path": "/src/rrd.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(provided_name) =
optional_argument.get_provided()
{
let function_symbol_id =
interpreter.intern_symbol_id(provided_name);
interpreter.define_function(
... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/evaluator/define_environment_functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emirayka/nia_interpreter_core path: /src/interpreter/evaluator/define_environment_functions.rs
use crate::interpreter::evaluator::evaluate_value::evaluate_value;
use crate::EnvironmentId;
use crate::Error;
use crate::FunctionArguments;
use crate::Interpreter;
use crate::Value;
mod define_ordina... | code_fim | hard | {
"lang": "rust",
"repo": "emirayka/nia_interpreter_core",
"path": "/src/interpreter/evaluator/define_environment_functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/murmurhash3/src/mmh3_32.rs
use
std
:
:
mem
;
fn
fmix32
(
mut
h
:
u32
)
-
>
u32
{
h
^
=
h
>
>
16
;
h
=
h
.
wrapping_mul
(
0x85ebca6b
)
;
h
^
=
h
>
>
13
;
h
=
h
.
wrapping_mul
(
0xc2b2ae35
)
;
h
^
=
h
>
>
16
;
return
h
;
}
fn
get_32_block
(
bytes... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/murmurhash3/src/mmh3_32.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>8
)
;
}
#
[
cfg
(
feature
=
"
nightly
"
)
]
mod
bench
{
extern
crate
rand
;
extern
crate
test
;
use
std
:
:
iter
:
:
FromIterator
;
use
self
:
:
rand
:
:
Rng
;
use
self
:
:
test
:
:
{
Bencher
black_box
}
;
use
super
:
:
super
:
:
murmurhash3_x86_32
;
fn
run_bench
(
b
:
&
mut
Bencher
size
:
u64
)
{
let
mut... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/murmurhash3/src/mmh3_32.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ukolka/rustendo64 path: /src/interconnect.rs
use std::fmt;
const RAM_SIZE: usize = 4 * 1024 * 1024;
pub struct Interconnect {
ram: Vec<u16>
}
impl fmt::Debug for Interconnect {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<|fim_suffix|> Interconnect {
ram:... | code_fim | medium | {
"lang": "rust",
"repo": "ukolka/rustendo64",
"path": "/src/interconnect.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Interconnect {
fn default() -> Self {
Interconnect {
ram: vec![0; RAM_SIZE]
}
}
}<|fim_prefix|>// repo: ukolka/rustendo64 path: /src/interconnect.rs
use std::fmt;
const RAM_SIZE: usize = 4 * 1024 * 1024;
<|fim_middle|>pub struct Interconnect {
ra... | code_fim | medium | {
"lang": "rust",
"repo": "ukolka/rustendo64",
"path": "/src/interconnect.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Evanfeenstra/brood path: /frontend/app/src/components/icons/gear.rs
use yew::{html, Component, Properties, Callback, ComponentLink, Html, ShouldRender};
pub struct Gear {
link: ComponentLink<Self>,
active: bool,
onclick: Callback<()>,
}
pub enum Msg {
Clicked,
}
#[derive(Prope... | code_fim | medium | {
"lang": "rust",
"repo": "Evanfeenstra/brood",
"path": "/frontend/app/src/components/icons/gear.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.active {
return html! {<div class="gear-icon" onclick=self.link.callback(|_| Msg::Clicked)>
<svg class="gear" fill="#FFFFFF" viewBox="0 0 1024 1024">
<path d="M512.5 390.6c-29.9 0-57.9 11.6-79.1 32.8-21.1 21.2-32.8 49.2-32.8 79.1 0 29.9 11.7 ... | code_fim | hard | {
"lang": "rust",
"repo": "Evanfeenstra/brood",
"path": "/frontend/app/src/components/icons/gear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let uri: hyper::Uri = format!("http://{}/", $ip).parse().unwrap();
let dst = Destination::try_from_uri(uri.clone()).unwrap();
let mut conn = HttpConnector::new(2);
conn.set_keepalive(Some(Duration::new(60, 0)));
let settings = client::Builder::new().http2_only(true... | code_fim | hard | {
"lang": "rust",
"repo": "satelit-project/satelit-import",
"path": "/_tests/rpc_tests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satelit-project/satelit-import path: /_tests/rpc_tests/mod.rs
mod import;
mod task;
use diesel::prelude::*;
use satelit_import::db::{entity::Schedule, ConnectionPool, QueryError};
// MARK: db
fn all_schedules(pool: &ConnectionPool) -> Result<Vec<Schedule>, QueryError> {
use satelit_impor... | code_fim | hard | {
"lang": "rust",
"repo": "satelit-project/satelit-import",
"path": "/_tests/rpc_tests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: callym/pbrst path: /pbrt/src/math/point.rs
use std::cmp::{ min, max };
use num::traits::Zero as Zero;
use cgmath::prelude::*;
use cgmath::{ Point2, Point3, Vector2, Vector3 };
use crate::prelude::*;
pub trait PointExt: Sized {
type Element;
fn min_component(&self) -> Self::Element;
... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/src/math/point.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::new(self.x.floor(), self.y.floor())
}
#[inline(always)]
fn ceil(self) -> Self {
Self::new(self.x.ceil(), self.y.ceil())
}
#[inline(always)]
fn abs(self) -> Self {
Self::new(self.x.abs(), self.y.abs())
}
#[inline(always)]
fn lerp(self, ot... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/src/math/point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: efancier-cn/fb2d path: /src/texture.rs
extern crate image;
use std::fs;
use std::io;
use image::{GenericImage, DynamicImage, imageops};
use dimension::*;
use screen_writer::{ScreenInfo};
use sprite::{Sprite, render_to_canvas};
pub struct TextureSprite {
pub gravity : Gravity,
pub filt... | code_fim | hard | {
"lang": "rust",
"repo": "efancier-cn/fb2d",
"path": "/src/texture.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_image = image.resize(width as u32, height as u32, self.filter);
self.raw_pixels = new_image.raw_pixels();
width = new_image.width() as i32;
height = new_image.height() as i32;
let mut frame = Rect {pos : POS_ZERO, size : Size {width : wi... | code_fim | hard | {
"lang": "rust",
"repo": "efancier-cn/fb2d",
"path": "/src/texture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jDomantas/interpreter path: /src/compiler/util.rs
use std::collections::{BTreeSet, BTreeMap};
use ast::{Node, Sym, Symbol};
use ast::resolved::Type;
pub struct Graph<'a, T: 'a + ?Sized> {
nodes: BTreeMap<&'a T, Vec<&'a T>>,
}
impl<'a, T: Ord + ?Sized> Graph<'a, T> {
pub fn new<I>(node... | code_fim | hard | {
"lang": "rust",
"repo": "jDomantas/interpreter",
"path": "/src/compiler/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.index.insert(node, self.next_index);
self.lowlink.insert(node, self.next_index);
self.next_index += 1;
self.on_stack.insert(node);
self.stack.push(node);
for &ng in &self.neighbours[node] {
if !self.neighbours.contains_key(&ng) {
... | code_fim | hard | {
"lang": "rust",
"repo": "jDomantas/interpreter",
"path": "/src/compiler/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connect(&mut self, node: &'a T) -> usize {
self.index.insert(node, self.next_index);
self.lowlink.insert(node, self.next_index);
self.next_index += 1;
self.on_stack.insert(node);
self.stack.push(node);
for &ng in &self.neighbours[node] {
... | code_fim | hard | {
"lang": "rust",
"repo": "jDomantas/interpreter",
"path": "/src/compiler/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"Showing {} open pull requests in {}",
pulls_mut.len(), full_name
);
println!("");
}
pulls_mut.to_std_out();
}
}
struct Pulls<'a>(&'a Vec<Pull>);
impl<'a> PrintStd for Vec<Pull> {
fn to_std_out(&self)... | code_fim | hard | {
"lang": "rust",
"repo": "mttrbit/bardo-github",
"path": "/ghauto-console/src/commands/pulls/get.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mttrbit/bardo-github path: /ghauto-console/src/commands/pulls/get.rs
use crate::cmd::{Command, IterableCommand, HttpResponse, ResultIterator, PrintStd};
use crate::commands::repo::get::{GetRepoCmd, Repository};
use client::client::{Executor, Github, Result};
use config::context::BardoContext;
u... | code_fim | hard | {
"lang": "rust",
"repo": "mttrbit/bardo-github",
"path": "/ghauto-console/src/commands/pulls/get.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kwantam/Nova path: /src/lib.rs
//! This library implements core components of Nova.
#![allow(non_snake_case)]
#![allow(clippy::type_complexity)]
#![feature(test)]
#![deny(missing_docs)]
mod commitments;
pub mod bellperson;
pub mod errors;
pub mod pasta;
pub mod r1cs;
pub mod traits;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "kwantam/Nova",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Consider a cubic equation: `x^3 + x + 5 = y`, where `x` and `y` are respectively the input and output.
// The R1CS for this problem consists of the following constraints:
// `I0 * I0 - Z0 = 0`
// `Z0 * I0 - Z1 = 0`
// `(Z1 + I0) * 1 - Z2 = 0`
// `(Z2 + 5) * 1 - I1 = ... | code_fim | hard | {
"lang": "rust",
"repo": "kwantam/Nova",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knownasilya/hands-on-rust path: /dungeoncrawl/src/systems/mod.rs
mod collisions;
mod entity_renderer;
mod map_renderer;
mod player_input;
<|fim_suffix|>pub fn build_scheduler() -> Schedule {
Schedule::builder()
.add_system(player_input::player_input_system())
.add_system(collisions::c... | code_fim | easy | {
"lang": "rust",
"repo": "knownasilya/hands-on-rust",
"path": "/dungeoncrawl/src/systems/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn build_scheduler() -> Schedule {
Schedule::builder()
.add_system(player_input::player_input_system())
.add_system(collisions::collisions_system())
.add_system(map_renderer::map_render_system())
.add_system(entity_renderer::entity_render_system())
.build()
}<|fim_prefix|>// repo... | code_fim | easy | {
"lang": "rust",
"repo": "knownasilya/hands-on-rust",
"path": "/dungeoncrawl/src/systems/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ert!((const || true)());
};
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs
// check-pass
#![feature(const_closures, const_trait_impl)]
#![allow(incomplete<|fim_middle|>_features)]
pub const _: () = {
ass | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs
// check-pass
#![feature(const_closures<|fim_suffix|>_features)]
pub const _: () = {
assert!((const || true)());
};
fn main() {}<|fim_middle|>, const_trait_impl)]
#![allow(incomplete | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_features)]
pub const _: () = {
assert!((const || true)());
};
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs
// check-pass
#![feature(const_closures<|fim_middle|>, const_trait_impl)]
#![allow(incomplete | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut state = serializer.serialize_struct(
"ISCSIVolumeSource",
3 +
self.chap_auth_discovery.as_ref().map_or(0, |_| 1) +
self.chap_auth_session.as_ref().map_or(0, |_| 1) +
self.fs_type.as_ref().map_or(0, |_| 1) +
self.initia... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_24/api/core/v1/iscsi_volume_source.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /src/v1_24/api/core/v1/iscsi_volume_source.rs
std::fmt::Result {
f.write_str("ISCSIVolumeSource")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
l... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_24/api/core/v1/iscsi_volume_source.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>eligible for expiry.")]
VendorNotYetExpired,
#[msg("Please collect your reward before otherwise using the program.")]
RewardsNeedsProcessing,
#[msg("Locked reward vendor expected but an unlocked vendor was given.")]
ExpectedLockedVendor,
#[msg("Unlocked reward vendor expected but a... | code_fim | hard | {
"lang": "rust",
"repo": "GoRiant-Finance/goriant-rs",
"path": "/programs/staking/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>he realizor metadata.")]
InvalidRealizorMetadata,
#[msg("Invalid vesting schedule for the locked reward.")]
InvalidVestingSchedule,
#[msg("Please specify the correct authority for this program.")]
InvalidProgramAuthority,
#[msg("Transfer token fail")]
TransferTokenFail,
#[m... | code_fim | hard | {
"lang": "rust",
"repo": "GoRiant-Finance/goriant-rs",
"path": "/programs/staking/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoRiant-Finance/goriant-rs path: /programs/staking/src/error.rs
use anchor_lang::prelude::*;
#[error]
pub enum ErrorCode {
#[msg("The given reward queue has already been initialized.")]
RewardQAlreadyInitialized,
#[msg("The nonce given doesn't derive a valid program address.")]
... | code_fim | hard | {
"lang": "rust",
"repo": "GoRiant-Finance/goriant-rs",
"path": "/programs/staking/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let req = TestRequest::get().uri("/pokemon/charizard").to_request();
let result: ShakesMon = test::read_response_json(&mut app, req).await;
assert_eq!(result.name, "charizard");
assert!(result.description.len() > 0);
}
#[actix_rt::test]
async fn pokemon_endpoi... | code_fim | hard | {
"lang": "rust",
"repo": "marcelo140/shakesperean-pokemon",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcelo140/shakesperean-pokemon path: /src/main.rs
use actix_web::middleware::Logger;
use actix_web::{web, get, HttpServer, App, HttpResponse};
use cached::Cached;
use cached::stores::SizedCache;
use log::debug;
use env_logger::Env;
use shakesperean_pokemon::services::shakesperean_pokemon::{Sha... | code_fim | hard | {
"lang": "rust",
"repo": "marcelo140/shakesperean-pokemon",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[actix_rt::test]
async fn pokemon_endpoint_404() {
let mut app = test::init_service(
App::new()
.service(cached_pokemon)
.app_data(web::Data::new(AppState::new(None)))
).await;
let req = TestRequest::get().uri("/pokemon/charizarda").to_... | code_fim | hard | {
"lang": "rust",
"repo": "marcelo140/shakesperean-pokemon",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuildOfWeavers/winterfell path: /air/src/air/transition/mod.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use core::cmp;
use math::FieldElement;
use utils::c... | code_fim | hard | {
"lang": "rust",
"repo": "GuildOfWeavers/winterfell",
"path": "/air/src/air/transition/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // EVALUATOR
// --------------------------------------------------------------------------------------------
/// Computes a linear combination of evaluations relevant to this constraint group.
///
/// The linear combination is computed as follows:
/// $$
/// \sum_{i=0}^{k-1}{C_... | code_fim | hard | {
"lang": "rust",
"repo": "GuildOfWeavers/winterfell",
"path": "/air/src/air/transition/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: splav/rust-tinyraytracer path: /src/ray_tracer/raster.rs
use std::cmp;
use image::jpeg::JPEGDecoder;
use image::ImageDecoder;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use super::Vec3f;
#[derive(Debug, Clone)]
pub struct Image {
pub width: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "splav/rust-tinyraytracer",
"path": "/src/ray_tracer/raster.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(file, "P6\n{} {}\n255\n", self.width, self.height)?;
for i in 0..self.height * self.width {
let mut point = self.buffer[i];
let max = point.max();
if max > 1.0 {
point /= max
}
for b in point.iter() {
... | code_fim | hard | {
"lang": "rust",
"repo": "splav/rust-tinyraytracer",
"path": "/src/ray_tracer/raster.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zheland/custom-print path: /src/macros/writer.rs
/// Defines a writer from writer expression arguments or from the provided one.
///
/// If more than one argument is used, the first argument specifies the writer type,
/// and the others are used to define the expression:
/// - `concat, args...`:... | code_fim | hard | {
"lang": "rust",
"repo": "zheland/custom-print",
"path": "/src/macros/writer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> one argument is used, the first argument specifies the writer type,
/// and the others are used to define the expression:
/// - `concat, args...`: [`ConcatTryWriter`]`::from_closure(`[`define_writer_expr`]`!(args...))`
/// - `fmt, args...`: [`FmtTryWriter`]`::from_closure(`[`define_writer_expr`]`!(args..... | code_fim | hard | {
"lang": "rust",
"repo": "zheland/custom-print",
"path": "/src/macros/writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let code = "foo bar";
let lexer = lexer::Lexer::new(code);
let result: Vec<TokenType> = lexer.map(|pair| pair.0).collect();
let expected: Vec<TokenType> = vec![
TokenType::Identifier {
token: Token::new("foo".to_string(), 0, 0, 0, 3),
... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/rider",
"path": "/rider-lexers/src/plain.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eraden/rider path: /rider-lexers/src/plain.rs
pub mod lexer {
use crate::{Span, Token, TokenType};
use plex::lexer;
lexer! {
fn next_token(text: 'a) -> (TokenType, &'a str);
r"[ \t\r\n]" => (TokenType::Whitespace {
token: Token::new(text.to_string(), 0, ... | code_fim | hard | {
"lang": "rust",
"repo": "Eraden/rider",
"path": "/rider-lexers/src/plain.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Connicpu/conniecs path: /src/entity/builder.rs
use crate::component::ComponentManager;
use crate::entity::{BuildData, ModifyData};
use crate::services::ServiceManager;
pub trait EntityBuilder<C, M>
where
C: ComponentManager,
M: ServiceManager,
{
fn build<'a>(self, entity: BuildData<... | code_fim | medium | {
"lang": "rust",
"repo": "Connicpu/conniecs",
"path": "/src/entity/builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C, M> EntityModifier<C, M> for ()
where
C: ComponentManager,
M: ServiceManager,
{
fn modify(self, _: ModifyData<C>, _: &mut C, _: &mut M) {}
}
impl<C, M, F> EntityModifier<C, M> for F
where
C: ComponentManager,
M: ServiceManager,
F: FnOnce(ModifyData<C>, &mut C, &mut M),
{
... | code_fim | hard | {
"lang": "rust",
"repo": "Connicpu/conniecs",
"path": "/src/entity/builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>\u{2cc6}' => "COPTIC CAPITAL LETTER OLD COPTIC ESH",
'\u{2cc7}' => "COPTIC SMALL LETTER OLD COPTIC ESH",
'\u{2cc8}' => "COPTIC CAPITAL LETTER AKHMIMIC KHEI",
'\u{2cc9}' => "COPTIC SMALL LETTER AKHMIMIC KHEI",
'\u{2cca}' => "COPTIC CAPITAL LETTER DIALECT-P HORI",
'\u{2ccb}' => "COPTIC S... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/rust-irc-bot",
"path": "/src/plugins/unicode_names/data.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinityb/rust-irc-bot path: /src/plugins/unicode_names/data.rs
INAL FORM",
'\u{fd18}' => "ARABIC LIGATURE SEEN WITH YEH FINAL FORM",
'\u{fd19}' => "ARABIC LIGATURE SHEEN WITH ALEF MAKSURA FINAL FORM",
'\u{fd1a}' => "ARABIC LIGATURE SHEEN WITH YEH FINAL FORM",
'\u{fd1b}' => "ARAB... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/rust-irc-bot",
"path": "/src/plugins/unicode_names/data.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinityb/rust-irc-bot path: /src/plugins/unicode_names/data.rs
F CIRCLES",
'\u{1f01e}' => "MAHJONG TILE SIX OF CIRCLES",
'\u{1f01f}' => "MAHJONG TILE SEVEN OF CIRCLES",
'\u{1f020}' => "MAHJONG TILE EIGHT OF CIRCLES",
'\u{1f021}' => "MAHJONG TILE NINE OF CIRCLES",
'\u{1f022}'... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/rust-irc-bot",
"path": "/src/plugins/unicode_names/data.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use]
extern crate log;
pub mod types;
pub mod appdata;
pub mod block;
pub mod signed_transaction;
pub mod state;
pub mod transaction_pool;<|fim_prefix|>// repo: Talentica/simpleblockchain path: /src/schema/src/lib.rs
#[macro_use]
extern crate exonum_derive;
<|fim_middle|>#[macro_use]
extern cr... | code_fim | easy | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/schema/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Talentica/simpleblockchain path: /src/schema/src/lib.rs
#[macro_use]
extern crate exonum_derive;
<|fim_suffix|>pub mod appdata;
pub mod block;
pub mod signed_transaction;
pub mod state;
pub mod transaction_pool;<|fim_middle|>#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;... | code_fim | medium | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/schema/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiayihu/fedra-thesis path: /packages/fedra-iot/src/polybench/gramschmidt.rs
#![allow(non_snake_case)]
use core::intrinsics::sqrtf32;
fn init_array<const M: usize, const N: usize>(
m: usize,
n: usize,
A: &mut [[f32; N]; M],
R: &mut [[f32; N]; N],
Q: &mut [[f32; N]; M],
) {
... | code_fim | hard | {
"lang": "rust",
"repo": "jiayihu/fedra-thesis",
"path": "/packages/fedra-iot/src/polybench/gramschmidt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> m: usize,
n: usize,
A: &mut [[f32; N]; M],
R: &mut [[f32; N]; N],
Q: &mut [[f32; N]; M],
) {
for k in 0..n {
let mut nrm = 0.0;
for i in 0..m {
nrm += A[i][k] * A[i][k];
}
R[k][k] = unsafe { sqrtf32(nrm) };
for i in 0..m {
... | code_fim | medium | {
"lang": "rust",
"repo": "jiayihu/fedra-thesis",
"path": "/packages/fedra-iot/src/polybench/gramschmidt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dirbaio/static-executor path: /static-executor-macro/src/lib.rs
#![feature(proc_macro_diagnostic)]
extern crate proc_macro;
use darling::FromMeta;
use proc_macro::{Diagnostic, Level, Span, TokenStream};
use quote::{format_ident, quote};
use syn::spanned::Spanned;
#[derive(Debug, FromMeta)]
st... | code_fim | hard | {
"lang": "rust",
"repo": "Dirbaio/static-executor",
"path": "/static-executor-macro/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = quote! {
#task_fn
#[allow(non_camel_case_types)]
type #future_type_name = impl ::core::future::Future + 'static;
fn #create_fn_name(#args) -> #future_type_name {
#task_fn_name(#arg_names)
}
#[allow(non_camel_case_types)]
... | code_fim | hard | {
"lang": "rust",
"repo": "Dirbaio/static-executor",
"path": "/static-executor-macro/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let order_book = coinbase.order_book(&OrderBookRequest {market_pair: "BTC-EUR".to_string()})
.await
.expect("Couldn't get order book");
println!("{:?}", order_book);
}<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /examples/coinbase.rs
use openl... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/examples/coinbase.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /examples/coinbase.rs
use openlimits::exchange::coinbase::Coinbase;
use openlimits::exchange::coinbase::CoinbaseParameters;
use openlimits::prelude::*;
<|fim_suffix|> let order_book = coinbase.order_book(&OrderBookRequest {market_pair: "BTC-EUR".to_string()})
... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/examples/coinbase.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: x1-/rust_comparison_of_threads path: /src/spawn_demo.rs
use std::{thread, time};
pub fn n_tasks(n: usize, sleep_sec: u64) {
<|fim_suffix|> jhs.into_iter().for_each(|jh| {jh.join().expect("The thread has panicked");});
println!("end!");
}<|fim_middle|> let mut jhs = Vec::<thread::Joi... | code_fim | hard | {
"lang": "rust",
"repo": "x1-/rust_comparison_of_threads",
"path": "/src/spawn_demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> jhs.into_iter().for_each(|jh| {jh.join().expect("The thread has panicked");});
println!("end!");
}<|fim_prefix|>// repo: x1-/rust_comparison_of_threads path: /src/spawn_demo.rs
use std::{thread, time};
pub fn n_tasks(n: usize, sleep_sec: u64) {
<|fim_middle|> let mut jhs = Vec::<thread::Joi... | code_fim | hard | {
"lang": "rust",
"repo": "x1-/rust_comparison_of_threads",
"path": "/src/spawn_demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devqueue/rust-learning path: /src/closures.rs
// closure
fn testing(){
<|fim_suffix|>pub fn run(){
}<|fim_middle|> let plus_one = |x:i32| -> i32 { x+1 };
let a = 6;
println!("{} + 1 = {}", a, plus_one(a));
}
| code_fim | medium | {
"lang": "rust",
"repo": "devqueue/rust-learning",
"path": "/src/closures.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub fn run(){
}<|fim_prefix|>// repo: devqueue/rust-learning path: /src/closures.rs
// closure
fn testing(){
<|fim_middle|> let plus_one = |x:i32| -> i32 { x+1 };
let a = 6;
println!("{} + 1 = {}", a, plus_one(a));
| code_fim | medium | {
"lang": "rust",
"repo": "devqueue/rust-learning",
"path": "/src/closures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: balabit/syslog-ng-rust-modules path: /syslog-ng-rs/syslog-ng-common/src/logtemplate/mod.rs
//! Contains templating related types.
use syslog_ng_sys;
use syslog_ng_sys::logtemplate as sys;
use glib_sys;
use glib;
use LogMessage;
use GlobalConfig;
use std::slice::from_raw_parts;
use std::ffi::{... | code_fim | hard | {
"lang": "rust",
"repo": "balabit/syslog-ng-rust-modules",
"path": "/syslog-ng-rs/syslog-ng-common/src/logtemplate/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_cfg = cfg.raw_ptr();
LogTemplate {
wrapped: unsafe { sys::log_template_new(raw_cfg, ::std::ptr::null()) },
buffer: unsafe { glib_sys::g_string_sized_new(128) },
}
}
/// Creates a new instance.
///
/// `content` is the literal string ... | code_fim | hard | {
"lang": "rust",
"repo": "balabit/syslog-ng-rust-modules",
"path": "/syslog-ng-rs/syslog-ng-common/src/logtemplate/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Format a slice of log messages into a string representation.
///
/// # Safety
///
/// This method takes `&mut self`, because it lends a mutable buffer to the wrapped `LogTemplate`.
/// The returned byte slice points to this internal buffer.
pub fn format_with_context(&mut s... | code_fim | hard | {
"lang": "rust",
"repo": "balabit/syslog-ng-rust-modules",
"path": "/syslog-ng-rs/syslog-ng-common/src/logtemplate/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Number of passes through the training data
#[structopt(short, long, default_value = "50")]
num_epochs: usize,
/// Number of training examples to use
#[structopt(short, long, default_value = "60000")]
training_examples: usize,
},
/// Runs a varie... | code_fim | medium | {
"lang": "rust",
"repo": "aujxn/perceptron",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aujxn/perceptron path: /src/main.rs
use anyhow::Result;
use perceptron::network::{run_variety, train_and_run};
use std::io::Write;
use structopt::StructOpt;
// Configuration for command line args and help tool
#[derive(StructOpt, Debug)]
enum Opt {
/// Trains and tests a custom network with... | code_fim | hard | {
"lang": "rust",
"repo": "aujxn/perceptron",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>2) << OFFSET;
self.w
}
}
#[doc = "Values that can be written to the field `TXE`"]
pub enum TXEW {
#[doc = "Disabled"]
_0,
#[doc = "Enabled"]
_1,
}
impl TXEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _bits(&self) -> bool {
match *self {
... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/usbhs/epcr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stv0g/k66 path: /src/usbhs/epcr.rs
(Clone, Copy, Debug, PartialEq)]
pub enum RXTR {
#[doc = "Control"]
_00,
#[doc = "Isochronous"]
_01,
#[doc = "Bulk"]
_10,
#[doc = "Interrupt"]
_11,
}
impl RXTR {
#[doc = r" Value of the field as raw bits"]
#[inline]
p... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/usbhs/epcr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>c = "Values that can be written to the field `TXE`"]
pub enum TXEW {
#[doc = "Disabled"]
_0,
#[doc = "Enabled"]
_1,
}
impl TXEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _bits(&self) -> bool {
match *self {
TXEW::_0 => false,
T... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/usbhs/epcr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icewind1991/xtensa-lx106-rt path: /src/exception/assembly.rs
use crate::{ExceptionCause, ExceptionContext};
global_asm!(
"
.set XT_STK_PC, 0
.set XT_STK_PS, 4
.set XT_STK_A0, 8
.equ XT_STK_A1, 12
.set XT_STK_A2, ... | code_fim | hard | {
"lang": "rust",
"repo": "icewind1991/xtensa-lx106-rt",
"path": "/src/exception/assembly.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .ifc \level,double
rsr a0, EXCSAVE2 // ok to reuse EXCSAVE7 for double exception as long as
// double exception is not in first couple of instructions
// of level 7 handler
.else
rsr a0, EXC... | code_fim | hard | {
"lang": "rust",
"repo": "icewind1991/xtensa-lx106-rt",
"path": "/src/exception/assembly.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NewWorldVulture/brainf-ck_interpreter path: /tape.rs
#[derive(Debug)]
pub struct State {
pub tape: Vec<u8>,
pub ptr: i64,
}
impl State {
// Add one to the current cell. Should not error.
pub fn add(&mut self) -> Result< (), &'static str > {
println!("Adding one.... | code_fim | hard | {
"lang": "rust",
"repo": "NewWorldVulture/brainf-ck_interpreter",
"path": "/tape.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Get one
// TODO! : Finish this
pub fn get(&mut self) -> Result< (), &'static str > {
println!("[get() called]");
Ok(())
}
// Print the current cell's ASCII value as a character
pub fn prt(&mut self) -> Result< (), &'static str > {
print!("{}", s... | code_fim | hard | {
"lang": "rust",
"repo": "NewWorldVulture/brainf-ck_interpreter",
"path": "/tape.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn rocket() -> Rocket {
rocket::ignite()
.mount("/", routes::routes())
}<|fim_prefix|>// repo: Noah2610/level-editor-prototype path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
<|fim_middle|>#[macro_use]
extern crate rocket;
mod routes;
use rocket::Rocket;
pub const STATIC_DIR: &'s... | code_fim | medium | {
"lang": "rust",
"repo": "Noah2610/level-editor-prototype",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/level-editor-prototype path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
mod routes;
use rocket::Rocket;
pub const STATIC_DIR: &'static str = "static/";
fn main() {
<|fim_suffix|>fn rocket() -> Rocket {
rocket::ignite()
.mount("/... | code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/level-editor-prototype",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const STATIC_DIR: &'static str = "static/";
fn main() {
rocket().launch();
}
fn rocket() -> Rocket {
rocket::ignite()
.mount("/", routes::routes())
}<|fim_prefix|>// repo: Noah2610/level-editor-prototype path: /src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern c... | code_fim | easy | {
"lang": "rust",
"repo": "Noah2610/level-editor-prototype",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle_message_list_sessions(
&mut self,
conn: &mut Connection<S>,
) -> Result<()> {
let mut watcher_counts = std::collections::HashMap::new();
for watcher in self.watchers() {
let watch_id =
if let ConnectionState::Watching { watch_id... | code_fim | hard | {
"lang": "rust",
"repo": "doy/teleterm",
"path": "/teleterm/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doy/teleterm path: /teleterm/src/server.rs
,
) -> Result<()> {
let parser = conn.state.term_mut().unwrap();
let screen = parser.screen().clone();
parser.process(data);
let diff = parser.screen().contents_diff(&screen);
for watch_conn in self.watchers_... | code_fim | hard | {
"lang": "rust",
"repo": "doy/teleterm",
"path": "/teleterm/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doy/teleterm path: /teleterm/src/server.rs
l::Message),
Error = Error,
> + Send,
>,
>,
> {
let client = conn.oauth_client.take().ok_or_else(|| {
Error::UnexpectedMessage {
message: crate::prot... | code_fim | hard | {
"lang": "rust",
"repo": "doy/teleterm",
"path": "/teleterm/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: puiterwijk/tpmless-tpm2-rs path: /src/lib.rs
use std::str::FromStr;
use openssl::hash::MessageDigest;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Invalid PCR number requested")]
InvalidPcr,
#[error("Unused algorithm requested")]
UnusedAlgo,
#[err... | code_fim | hard | {
"lang": "rust",
"repo": "puiterwijk/tpmless-tpm2-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for DigestAlgorithm {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
let s = s.to_lowercase();
match &s[..] {
"sha1" => Ok(DigestAlgorithm::Sha1),
"sha256" => Ok(DigestAlgorithm::Sha256),
"sha384" => Ok(DigestAlgori... | code_fim | hard | {
"lang": "rust",
"repo": "puiterwijk/tpmless-tpm2-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fosskers/wasm-game-of-life path: /src/lib.rs
mod utils;
use fixedbitset::FixedBitSet;
use js_sys::Math;
use wasm_bindgen::prelude::*;
// use web_sys;
// macro_rules! log {
// ( $( $t:tt )* ) => {
// web_sys::console::log_1(&format!( $( $t )* ).into());
// }
// }
// When the `w... | code_fim | hard | {
"lang": "rust",
"repo": "fosskers/wasm-game-of-life",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e = self.get_index(row, east);
count += self.cells[e] as u8;
let sw = self.get_index(south, west);
count += self.cells[sw] as u8;
let s = self.get_index(south, col);
count += self.cells[s] as u8;
let se = self.get_index(south, east);
c... | code_fim | hard | {
"lang": "rust",
"repo": "fosskers/wasm-game-of-life",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: syuan100/lighthouse path: /common/warp_utils/src/metrics.rs
use eth2::lighthouse::Health;
use lighthouse_metrics::*;
lazy_static::lazy_static! {
pub static ref PROCESS_NUM_THREADS: Result<IntGauge> = try_create_int_gauge(
"process_num_threads",
"Number of threads used by the... | code_fim | hard | {
"lang": "rust",
"repo": "syuan100/lighthouse",
"path": "/common/warp_utils/src/metrics.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>&PROCESS_VIRT_MEM, health.pid_mem_virtual_memory_size as i64);
set_gauge(&SYSTEM_VIRT_MEM_TOTAL, health.sys_virt_mem_total as i64);
set_gauge(
&SYSTEM_VIRT_MEM_AVAILABLE,
health.sys_virt_mem_available as i64,
);
set_gauge(&SYSTEM_VIRT_MEM_USED, healt... | code_fim | hard | {
"lang": "rust",
"repo": "syuan100/lighthouse",
"path": "/common/warp_utils/src/metrics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut parents: HashMap<String, Vec<String>, ARandomState> = make_hashmap();
let mut p_union: HashMap<String, f64, ARandomState> = make_hashmap();
// Get all parents first, process their IC
for term in ids_a.iter().chain(ids_b.iter()) {
let p_tmp = annotation
... | code_fim | hard | {
"lang": "rust",
"repo": "bschiffthaler/heimdall",
"path": "/src/utils/semanticsimilarity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut arr: Array2<f64> = Array2::zeros((ids.len(), ids.len()));
arr.diag_mut().fill(1.0);
for i in 1..ids.len() {
for j in 0..i {
let row = &ids[i];
let col = &ids[j];
let ns1 = annotation.get_namespace(row);
... | code_fim | hard | {
"lang": "rust",
"repo": "bschiffthaler/heimdall",
"path": "/src/utils/semanticsimilarity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bschiffthaler/heimdall path: /src/utils/semanticsimilarity.rs
a hashmap with all GO terms to contain
// ln(1)
let mut hmap_scores: HashMap<u32, f64> = HashMap::with_capacity(terms.len());
let mut hmap_nparents: HashMap<u32, usize> = HashMap::with_capacity(terms.len());
... | code_fim | hard | {
"lang": "rust",
"repo": "bschiffthaler/heimdall",
"path": "/src/utils/semanticsimilarity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut label_list: Vec<Label> = Vec::new();
while let Some(result) = label_iter.next() {
if let Some(mut label) = result.ok() {
label_list.push(label);
}
}
label_list
}
pub fn fetch_labels_for_item(&self, item_uuid: &String)... | code_fim | hard | {
"lang": "rust",
"repo": "jprider63/sync-storage-prototype",
"path": "/complex/cargo/list/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update_item(&self, item: &Item) {
let sql = r#"UPDATE items SET name=?, due_date=?, completion_date=? WHERE uuid=?"#;
let conn = self.store.write_connection();
let _ = conn.execute(sql, &[&item.name, &item.due_date, &item.completion_date, &item.uuid]);
let exist... | code_fim | hard | {
"lang": "rust",
"repo": "jprider63/sync-storage-prototype",
"path": "/complex/cargo/list/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jprider63/sync-storage-prototype path: /complex/cargo/list/src/lib.rs
// Copyright 2016 Mozilla
//
// 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.o... | code_fim | hard | {
"lang": "rust",
"repo": "jprider63/sync-storage-prototype",
"path": "/complex/cargo/list/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jneem/ojo path: /ojo/src/main.rs
#[macro_use]
extern crate clap;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate log as other_log;
use clap::{App, ArgMatches};
use failure::{Error, ResultExt};
use flexi_logger::Logger;
use libojo::Repo;
mod branch;
mod clear;
mod diff;
mod graph... | code_fim | hard | {
"lang": "rust",
"repo": "jneem/ojo",
"path": "/ojo/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Logger::with_env()
//.log_to_file()
.start()
.unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));
let result = match m.subcommand_name() {
Some("branch") => branch::run(m.subcommand_matches("branch").unwrap()),
Some("clear") => clear::run... | code_fim | medium | {
"lang": "rust",
"repo": "jneem/ojo",
"path": "/ojo/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if attributes.is_control_batch() {
log::trace!("Control batch");
}
let (value, _rest) = crate::parser::record_set().parse(I::from(bytes))?;
// debug_assert!(rest.is_empty(), "{:#?} {:?}", value, rest);
log... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/kafka-protocol",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/kafka-protocol path: /src/lib.rs
encode(&self, writer: &mut impl Buffer) {
let l = i32::try_from(self.len()).unwrap();
l.encode(writer);
for elem in self {
elem.encode(writer);
}
}
}
impl<R> Encode for Option<RecordBatch<R>>
where
R: E... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/kafka-protocol",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.