text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: MitchellTesla/vit-servicing-station path: /vit-servicing-station-lib/src/db/models/proposals/community_choice.rs
use crate::db::schema::proposal_community_choice_challenge;
use diesel::ExpressionMethods;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug,... | code_fim | hard | {
"lang": "rust",
"repo": "MitchellTesla/vit-servicing-station",
"path": "/vit-servicing-station-lib/src/db/models/proposals/community_choice.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: AsQuery> Paginate for T {}
const DEFAULT_PER_PAGE: i64 = 10;
#[derive(QueryId)]
pub struct Paginated<T> {
query: T,
page: i64,
per_page: i64,
}
impl<T> Paginated<T> {
pub fn set_per_page(self, per_page: i64) -> Self {
Paginated { per_page, ..self }
}
}
impl<T> Pagin... | code_fim | hard | {
"lang": "rust",
"repo": "Oodachi/delicate",
"path": "/delicate-scheduler/src/db/mysql/extension.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> Paginated<T> {
fn load_pages<U>(self, conn: &MysqlConnection) -> QueryResult<Vec<U>>
where
Self: LoadQuery<MysqlConnection, U>,
{
self.load::<U>(conn)
}
}<|fim_prefix|>// repo: Oodachi/delicate path: /delicate-scheduler/src/db/mysql/extension.rs
use super::prelude:... | code_fim | hard | {
"lang": "rust",
"repo": "Oodachi/delicate",
"path": "/delicate-scheduler/src/db/mysql/extension.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Oodachi/delicate path: /delicate-scheduler/src/db/mysql/extension.rs
use super::prelude::*;
impl<T> QueryFragment<Mysql> for Paginated<T>
where
T: QueryFragment<Mysql>,
{
fn walk_ast(&self, mut out: AstPass<'_, Mysql>) -> QueryResult<()> {
self.query.walk_ast(out.reborrow())?;
... | code_fim | hard | {
"lang": "rust",
"repo": "Oodachi/delicate",
"path": "/delicate-scheduler/src/db/mysql/extension.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feather-rs/feather path: /feather/common/src/entities/skeleton_horse.rs
use base::EntityKind;
use ecs::EntityBuilder;
use quill_common::entities::SkeletonHorse;
pub fn build_default(builder: <|fim_suffix|> builder.add(SkeletonHorse).add(EntityKind::SkeletonHorse);
}<|fim_middle|>&mut EntityBuil... | code_fim | medium | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/common/src/entities/skeleton_horse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> builder.add(SkeletonHorse).add(EntityKind::SkeletonHorse);
}<|fim_prefix|>// repo: feather-rs/feather path: /feather/common/src/entities/skeleton_horse.rs
use base::EntityKind;
use ecs::EntityBuilder;
use quill_comm<|fim_middle|>on::entities::SkeletonHorse;
pub fn build_default(builder: &mut EntityBuil... | code_fim | medium | {
"lang": "rust",
"repo": "feather-rs/feather",
"path": "/feather/common/src/entities/skeleton_horse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kayru/rush-rs path: /rush-sys/src/rush_ffi.rs
pub scroll: [f32; 2usize],
}
impl Default for rush_window_event {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
extern "C" {
pub fn rush_platform_get_main_window() -> *mut rush_window;
}
extern "C" {
pub fn rus... | code_fim | hard | {
"lang": "rust",
"repo": "kayru/rush-rs",
"path": "/rush-sys/src/rush_ffi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct rush_gfx_depth_stencil_desc {
pub compare_func: rush_gfx_compare_func,
pub enable: bool,
pub write_enable: bool,
}
impl Default for rush_gfx_depth_stencil_desc {
fn default() -> S... | code_fim | hard | {
"lang": "rust",
"repo": "kayru/rush-rs",
"path": "/rush-sys/src/rush_ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { ::std::mem::zeroed() }
}
}
extern "C" {
pub fn rush_platform_get_main_window() -> *mut rush_window;
}
extern "C" {
pub fn rush_window_get_keyboard_state(
window: *mut rush_window,
) -> *const rush_window_keyboard_state;
}
extern "C" {
pub fn rush_window_get_mou... | code_fim | hard | {
"lang": "rust",
"repo": "kayru/rush-rs",
"path": "/rush-sys/src/rush_ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let src = r#"
#[derive(Template)]
#[template(path = "no-exist.html")]
struct Test;
"#;
let i = parse_str::<syn::DeriveInput>(src).unwrap();
let config = Config::new("");
let _ = visit_derive(&i, &config);
}
#[test]
fn... | code_fim | hard | {
"lang": "rust",
"repo": "The-Peso-G/yarte",
"path": "/yarte_hir/src/visit_derive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: The-Peso-G/yarte path: /yarte_hir/src/visit_derive.rs
use std::path::PathBuf;
use quote::quote;
use syn::visit::Visit;
use yarte_config::Config;
use proc_macro2::TokenStream;
use syn::{parse_str, ItemEnum};
pub fn visit_derive<'a>(i: &'a syn::DeriveInput, config: &Config) -> Struct<'a> {
... | code_fim | hard | {
"lang": "rust",
"repo": "The-Peso-G/yarte",
"path": "/yarte_hir/src/visit_derive.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>//#[account(seeds = [authority])]
//#[account(seeds)]
//#[account(seeds = [authority, usdc_mint])]
#[associated]
pub struct UserData {
pub first_deposit: i64,
}
impl Default for UserData {
fn default() -> UserData {
UserData{
__nonce: 0,
first_deposit: 0,
}
}
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "AuroraLantean/SolanaAnchorDemo1",
"path": "/dog-money/programs/dog-money/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AuroraLantean/SolanaAnchorDemo1 path: /dog-money/programs/dog-money/src/lib.rs
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Mint, TokenAccount, Transfer, MintTo};
use anchor_lang::solana_program::program_option::COption;
#[program]
pub mod dog_money {
use super::*;
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "AuroraLantean/SolanaAnchorDemo1",
"path": "/dog-money/programs/dog-money/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikkolundgren/rust-api path: /src/routes.rs
use super::db::Conn as DbConn;
use rocket_contrib::json::Json;
use super::models::{Album, NewAlbum};
use serde_json::Value;
use crate::models::AlbumData;
<|fim_suffix|>#[post["/albums", format = "application/json", data = "<new_album>"]]
pub fn new_al... | code_fim | hard | {
"lang": "rust",
"repo": "mikkolundgren/rust-api",
"path": "/src/routes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[post["/albums", format = "application/json", data = "<new_album>"]]
pub fn new_album(conn: DbConn, new_album: Json<NewAlbum>) -> Json<Value> {
Json(json!({
"status": Album::insert_album(new_album.into_inner(), &conn),
"result": Album::get_all_albums(&conn).first(),
}))
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "mikkolundgren/rust-api",
"path": "/src/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futile/ncollide path: /ncollide_entities/bounding_volume/aabb_segment.rs
use bounding_volume::{HasBoundingVolume, AABB};
use bounding_volume;
use shape::Segment;
use math::Matrix;
use math::{Scalar, Point, Vect};
<|fim_suffix|> // FIXME: optimize that
bounding_volume::implicit_sh... | code_fim | medium | {
"lang": "rust",
"repo": "futile/ncollide",
"path": "/ncollide_entities/bounding_volume/aabb_segment.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // FIXME: optimize that
bounding_volume::implicit_shape_aabb(m, self)
}
}<|fim_prefix|>// repo: futile/ncollide path: /ncollide_entities/bounding_volume/aabb_segment.rs
use bounding_volume::{HasBoundingVolume, AABB};
use bounding_volume;
use shape::Segment;
use math::Matrix;
use math:... | code_fim | medium | {
"lang": "rust",
"repo": "futile/ncollide",
"path": "/ncollide_entities/bounding_volume/aabb_segment.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darwins-challenge/nadezhda path: /src/population.rs
//! A population of individuals
//!
//! The fitness of a population in an environment is tracked over multiple
//! generations.
//!
//! # Examples
//! Below we show how to generate a initial population, and access the
//! underlying individuals... | code_fim | hard | {
"lang": "rust",
"repo": "darwins-challenge/nadezhda",
"path": "/src/population.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..size {
let program: Program = rand::random();
population.push(program);
}
Population(population)
}
}<|fim_prefix|>// repo: darwins-challenge/nadezhda path: /src/population.rs
//! A population of individuals
//!
//! The fitness of a populat... | code_fim | hard | {
"lang": "rust",
"repo": "darwins-challenge/nadezhda",
"path": "/src/population.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut queue = VecDeque::new();
queue.push_back(root);
while let Some(node) = queue.pop_front() {
for n in self.edges[node].iter().cloned() {
if parents[n].is_none() {
parents[n] = Some(node);
queue.push_back(n.clone());
}
}
}
parents
... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/rust-skiena",
"path": "/ch5_graph_traversal/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asolove/rust-skiena path: /ch5_graph_traversal/src/lib.rs
#![feature(test)]
extern crate rand;
extern crate test;
use rand::Rng;
use std::collections::VecDeque;
use rand::distributions::{IndependentSample, Range};
use test::Bencher;
#[test]
fn test_init_graph() {
let mut g = AdjacencyList::... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/rust-skiena",
"path": "/ch5_graph_traversal/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut g = AdjacencyList::new(false, vertices);
let range = Range::new(0, vertices-1);
let mut rng = rand::thread_rng();
for _ in 0..edges {
g.add_edge(range.ind_sample(&mut rng), range.ind_sample(&mut rng));
}
g
}
fn make_random_sparse_graph(edges: usize) -> () {
random_sparse_graph(... | code_fim | hard | {
"lang": "rust",
"repo": "asolove/rust-skiena",
"path": "/ch5_graph_traversal/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baco16g/leetcode-rust path: /solutions/14.longest-common-prefix.rs
/*
* @lc app=leetcode id=14 lang=rust
*
* [14] Longest Common Prefix
*/
// @lc code=start
impl Solution {
pub fn longest_common_pref<|fim_suffix|>ring::new(),
};
strs.iter().skip(0).fold(first, |acc, str|... | code_fim | medium | {
"lang": "rust",
"repo": "baco16g/leetcode-rust",
"path": "/solutions/14.longest-common-prefix.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> .take_while(|(a, b)| a == b)
.map(|(x, _)| x)
.collect::<String>()
})
}
}
// @lc code=end<|fim_prefix|>// repo: baco16g/leetcode-rust path: /solutions/14.longest-common-prefix.rs
/*
* @lc app=leetcode id=14 lang=rust
*
* [14] Longest Common Prefix
... | code_fim | medium | {
"lang": "rust",
"repo": "baco16g/leetcode-rust",
"path": "/solutions/14.longest-common-prefix.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaphar/win-utils path: /winapi-perf-wrapper/src/constants.rs
// Copyright 2020 Jeremy Wall
//
// 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.apa... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/win-utils",
"path": "/winapi-perf-wrapper/src/constants.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// PDH formatting constants
/// Format the pdh counter as a f64
pub const PDH_FMT_DOUBLE: u32 = 0x00000200;
/// Format the pdh counter as an i32
pub const PDH_FMT_LONG: u32 = 0x00000100;
/// Format the pdh counter as an i64
pub const PDH_FMT_LARGE: u32 = 0x00000400;
pub const PDH_FMT_RAW: u32 = 0x00000010... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/win-utils",
"path": "/winapi-perf-wrapper/src/constants.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let end_position = reader.virtual_position();
let chunk = Chunk::new(start_position, end_position);
builder.add_record(&record, chunk);
start_position = end_position;
}
let index = builder.build(header.reference_sequences().len());
let stdout = io::stdout();... | code_fim | hard | {
"lang": "rust",
"repo": "slazicoicr/noodles",
"path": "/noodles-bam/examples/bam_index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match reader.read_record(&mut record) {
Ok(0) => break,
Ok(_) => {}
Err(e) => return Err(e.into()),
}
let end_position = reader.virtual_position();
let chunk = Chunk::new(start_position, end_position);
builder.add_rec... | code_fim | hard | {
"lang": "rust",
"repo": "slazicoicr/noodles",
"path": "/noodles-bam/examples/bam_index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slazicoicr/noodles path: /noodles-bam/examples/bam_index.rs
//! Builds and writes a BAM index from a BAM file.
use std::{env, fs::File, io};
use noodles_bam::{
self as bam,
bai::{self, index::reference_sequence::bin::Chunk},
};
use noodles_sam as sam;
fn main() -> Result<(), Box<dyn s... | code_fim | medium | {
"lang": "rust",
"repo": "slazicoicr/noodles",
"path": "/noodles-bam/examples/bam_index.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn try_get_slurm_info() -> anyhow::Result<ManagerInfo> {
log::debug!("Detecting SLURM environment");
let manager_job_id = std::env::var("SLURM_JOB_ID")
.or_else(|_| std::env::var("SLURM_JOBID"))
.map_err(|_| {
anyhow!("SLURM_JOB_ID/SLURM_JOBID not found. The proces... | code_fim | hard | {
"lang": "rust",
"repo": "It4innovations/hyperqueue",
"path": "/crates/hyperqueue/src/worker/bootstrap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: It4innovations/hyperqueue path: /crates/hyperqueue/src/worker/bootstrap.rs
use std::future::Future;
use std::path::Path;
use std::pin::Pin;
use std::sync::Arc;
use anyhow::{anyhow, Context};
use signal_hook::consts::{SIGINT, SIGTERM, SIGTSTP};
use signal_hook::iterator::Signals;
use tako::Error... | code_fim | hard | {
"lang": "rust",
"repo": "It4innovations/hyperqueue",
"path": "/crates/hyperqueue/src/worker/bootstrap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let time_limit = match pbs::get_remaining_timelimit(&manager_job_id) {
Ok(time_limit) => Some(time_limit),
Err(error) => {
log::warn!("Cannot get time-limit from PBS: {error:?}");
None
}
};
log::info!("PBS environment detected");
Ok(Manager... | code_fim | hard | {
"lang": "rust",
"repo": "It4innovations/hyperqueue",
"path": "/crates/hyperqueue/src/worker/bootstrap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: n1toxyz/aoc2019 path: /day07/src/lib.rs
pub mod icm {
use std::convert::TryInto;
use std::sync::mpsc::{Receiver, Sender};
#[derive(Debug)]
enum Param {
Position(usize),
Immediate(i32),
}
/*
Parses a parameter.
nth - Number of the parameter, beg... | code_fim | hard | {
"lang": "rust",
"repo": "n1toxyz/aoc2019",
"path": "/day07/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_input(&mut self, input: Receiver<i32>) {
self.input = input;
}
pub fn get_input(&self) -> &Receiver<i32> {
return &self.input;
}
pub fn set_output(&mut self, output: Sender<i32>) {
self.output = output;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "n1toxyz/aoc2019",
"path": "/day07/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let start = SystemTime::now();
let zone: Vec<Segment> = influence_zone::compute(&query_point, &interest_points, k, bound);
let intersect: bool = influence_zone::query(&query_point, &zone, &object);
println!("{:?}", start.elapsed().unwrap());
}<|fim_prefix|>// repo: alvinmatias69/influence-... | code_fim | hard | {
"lang": "rust",
"repo": "alvinmatias69/influence-zone",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alvinmatias69/influence-zone path: /src/main.rs
mod lib;
use lib::data::{Point, Segment};
use lib::influence_zone;
use std::time::SystemTime;
fn main() {
<|fim_suffix|> let start = SystemTime::now();
let zone: Vec<Segment> = influence_zone::compute(&query_point, &interest_points, k, boun... | code_fim | hard | {
"lang": "rust",
"repo": "alvinmatias69/influence-zone",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let query_point: Point = Point { x: 3.0, y: 3.0 };
let interest_points = vec![
Point { x: 1.0, y: 1.0 },
Point { x: 5.0, y: 5.0 },
Point { x: 5.0, y: 1.0 },
];
let bound = 10.0;
let k = 2;
let object: Point = Point { x: 6.0, y: 1.0 };
let start = System... | code_fim | medium | {
"lang": "rust",
"repo": "alvinmatias69/influence-zone",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rexhoffman/cargo-guppy path: /guppy/src/graph/proptest09.rs
// Copyright (c) The cargo-guppy Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::graph::{DependencyLink, PackageGraph};
use crate::PackageId;
use petgraph::prelude::*;
use proptest::prelude::*;
/// ## Helpers for... | code_fim | hard | {
"lang": "rust",
"repo": "rexhoffman/cargo-guppy",
"path": "/guppy/src/graph/proptest09.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>trategy` that generates random dependency links from this graph.
///
/// Requires the `proptest09` feature to be enabled.
///
/// ## Panics
///
/// Panics if there are no dependency edges in this `PackageGraph`.
pub fn prop09_link_strategy<'g>(&'g self) -> impl Strategy<Value =... | code_fim | hard | {
"lang": "rust",
"repo": "rexhoffman/cargo-guppy",
"path": "/guppy/src/graph/proptest09.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the path to the config directory
/// If the directory does not exist, this will create it.
fn mk_config_dir() -> Result<PathBuf> {
let mut path = dirs::config_dir()
.ok_or(StoreErr::MissingConfig)?;
path.push("unicode_util");
if !path.is_dir() {
... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/unicode_util",
"path": "/src/store.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Loads a store from the path
pub fn load_file() -> Result<Store> {
let path = Store::store_path()?;
if path.is_file() {
let file_data = fs::read_to_string(path)
.map_err(|e| StoreErr::Io(e))?;
toml::from_str(file_data.as_str())
... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/unicode_util",
"path": "/src/store.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blargg/unicode_util path: /src/store.rs
use std::{
collections::HashMap,
fs,
io,
path::PathBuf,
};
use serde::{Deserialize, Serialize};
use toml;
#[derive(Serialize, Deserialize)]
/// Stores variables and data for later use
pub struct Store {
pub saved: HashMap<String, char>... | code_fim | hard | {
"lang": "rust",
"repo": "blargg/unicode_util",
"path": "/src/store.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(error.reason(), Some(reason));
assert_eq!(error.class(), Some(Class::Error { arguments: None }));
}
#[test]
fn with_arguments_stores_some() {
let reason = atom!("badarg");
let arguments = Term::NIL;
let error =... | code_fim | hard | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/liblumen_alloc/src/erts/exception/runtime.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaneutt/lumen path: /liblumen_alloc/src/erts/exception/runtime.rs
use core::convert::TryFrom;
use thiserror::Error;
use crate::erts::term::prelude::*;
use super::{ArcError, Exception, SystemException, UnexpectedExceptionError};
#[derive(Error, Debug, Clone)]
pub enum RuntimeException {
... | code_fim | hard | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/liblumen_alloc/src/erts/exception/runtime.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /vendor/ring/src/ec/suite_b/ops/elem.rs
// Copyright 2017 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permis... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/ring/src/ec/suite_b/ops/elem.rs",
"mode": "psm",
"license": "OpenSSL",
"source": "the-stack-v2"
} |
<|fim_suffix|>// a := f(a);
#[inline]
pub fn unary_op_assign<M, E: Encoding>(
f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb),
a: &mut Elem<M, E>,
) {
unsafe { f(a.limbs.as_mut_ptr(), a.limbs.as_ptr()) }
}
// a := f(a, a);
#[inline]
pub fn unary_op_from_binary_op_assign<M, E: Encoding>(
f: unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/ring/src/ec/suite_b/ops/elem.rs",
"mode": "spm",
"license": "OpenSSL",
"source": "the-stack-v2"
} |
<|fim_suffix|> let op = op_code.get_op();
let res = op.execute(a,b);
//println!("op={:?}, res={},a={},b={}, to register={}",op_code,res,a,b,c_in);
self.registers[c_in] = res;
}
pub fn run_program(&mut self, program:Vec<Vec<usize>>) {
for instr in program {
let... | code_fim | hard | {
"lang": "rust",
"repo": "RaymondK99/advent_of_code_2018",
"path": "/src/util/opcode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RaymondK99/advent_of_code_2018 path: /src/util/opcode.rs
use std::collections::{HashMap};
use regex::Regex;
#[derive(Eq, PartialEq,Debug,Clone,Copy,Ord, PartialOrd)]
pub enum OpCode {
ADDR,
ADDI,
MULTR,
MULTI,
SETR,
SETI,
BANR,
BANI,
BORR,
BORI,
GTIR,... | code_fim | hard | {
"lang": "rust",
"repo": "RaymondK99/advent_of_code_2018",
"path": "/src/util/opcode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Vec::iter_ref(Ref::map(this, |vec| &**vec))
}
/// Removes the last element from a vector and returns it, or [`None`] if it is
/// empty.
///
/// If you'd like to pop the first element, consider using
/// [`VecDeque::pop_front`] instead.
///
/// [`VecDeque::pop_front`]: crate::collections::VecDeque::p... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/modules/vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/modules/vec.rs
//! The `std::vec` module.
use core::cmp::Ordering;
use core::fmt;
use crate as rune;
#[cfg(feature = "std")]
use crate::runtime::Hasher;
use crate::runtime::{
EnvProtocolCaller, Formatter, Function, Iterator, Ref, TypeOf, Value, Vec, VmEr... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/modules/vec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Vec::iter_ref(Ref::map(this, |vec| &**vec))
}
/// Returns a reference to an element or subslice depending on the type of
/// index.
///
/// - If given a position, returns a reference to the element at that position
/// or `None` if out of bounds.
/// - If given a range, returns the subslice corresp... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/modules/vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = re.window.get_framebuffer_size();
reshape_framebuffer(&mut re, size.0, size.1);
let size = re.window.get_size();
reshape_window(&mut re, size.0, size.1);
re.window.set_framebuffer_size_polling(true);
re.window.set_size_polling(true);
re.window.set_key_polli... | code_fim | hard | {
"lang": "rust",
"repo": "zelixir/scenic_driver_glfw_rust",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zelixir/scenic_driver_glfw_rust path: /src/types.rs
use crate::event::*;
use glfw::Window;
use nanovg::Image;
use std::collections::HashMap;
use crate::comms::*;
pub type Script = Vec<u8>;
pub type NanoContext = ::nanovg::Context;
pub struct Context<'ctx: 'tx, 'tx> {
pub textures: Ha... | code_fim | hard | {
"lang": "rust",
"repo": "zelixir/scenic_driver_glfw_rust",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(result) = cache.get(&pos) {
return result.clone();
}
if pos == path.len() {
return Some(Vector::new());
}
let mut best: Option<Vector<usize>> = None;
// compare best to any possible subroutine replacement
for (i... | code_fim | hard | {
"lang": "rust",
"repo": "tyehle/advent-of-code",
"path": "/2019/d17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyehle/advent-of-code path: /2019/d17/src/main.rs
use num_complex::Complex;
use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use im::Vector;
use itertools::Itertools;
mod intcode;
use intcode::*;
type C = Complex<i64>;
fn output_string(controller: &mut State) -> String {
... | code_fim | hard | {
"lang": "rust",
"repo": "tyehle/advent-of-code",
"path": "/2019/d17/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> blake3::derive_key("sidefuzz", &key_material, &mut output);
output
}<|fim_prefix|>// repo: phayes/sidefuzz-targets path: /blake3_derive_key_key_material/src/lib.rs
#[no_mangle]
pub extern "C" fn fuzz() {
let key_material = sidefuzz::fe<|fim_middle|>tch_input(8);
sidefuzz::black_box(fuzz_b... | code_fim | medium | {
"lang": "rust",
"repo": "phayes/sidefuzz-targets",
"path": "/blake3_derive_key_key_material/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fuzz_blake3(key_material: &[u8]) -> [u8; 8] {
let mut output = [0; 8];
blake3::derive_key("sidefuzz", &key_material, &mut output);
output
}<|fim_prefix|>// repo: phayes/sidefuzz-targets path: /blake3_derive_key_key_material/src/lib.rs
#[no_mangle]
pub extern "C" fn fuzz() {
let key_mater... | code_fim | medium | {
"lang": "rust",
"repo": "phayes/sidefuzz-targets",
"path": "/blake3_derive_key_key_material/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phayes/sidefuzz-targets path: /blake3_derive_key_key_material/src/lib.rs
#[no_mangle]
pub extern "C" fn fuzz() {
let key_material = sidefuzz::fe<|fim_suffix|>fuzz_blake3(key_material: &[u8]) -> [u8; 8] {
let mut output = [0; 8];
blake3::derive_key("sidefuzz", &key_material, &mut outp... | code_fim | medium | {
"lang": "rust",
"repo": "phayes/sidefuzz-targets",
"path": "/blake3_derive_key_key_material/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/grail-rs path: /src/lib.rs
#![no_std]
#![forbid(unsafe_code)]
// The main file the synth is in
// first, define some constants
/// default sample rate all voices use
/// Resampling to a different sample rate is possible
pub const DEFAULT_SAMPLE_RATE: usize = 44100;
/// the number of f... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/grail-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// underlying iterator
iter: T,
/// filter state a
filter_state_a: Array,
/// filter state b
filter_state_b: Array,
/// antiresonator state a
antiresonator_state_a: f32,
/// antiresonator state b
antiresonator_state_b: f32,
/// phase for the current pulse
phase: f32,
/// noise state
s... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/grail-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oraichain/hackathon-ibc path: /smart-contracts/marketplace/src/msg.rs
use cosmwasm_std::{Binary, Decimal, Uint128};
use cw721::Cw721ReceiveMsg;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Insta... | code_fim | medium | {
"lang": "rust",
"repo": "oraichain/hackathon-ibc",
"path": "/smart-contracts/marketplace/src/msg.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krisaoe/peacock path: /src/graphics.rs
mod animation;
mod color;
mod font;
mod sprite_batch;
mod text;
mod texture_atlas;
pub use sfml::graphics::{
Color as SfColor, IntRect, Sprite, Texture, Transformable, VertexArray, View, ViewRef,
};
use sfml::graphics::{
Font as SfFont, RenderState... | code_fim | hard | {
"lang": "rust",
"repo": "krisaoe/peacock",
"path": "/src/graphics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Draws a [`VertexArray`] to the current render target.
pub(crate) fn draw_vertex_array(ctx: &mut Context, vertex_array: &VertexArray, texture: &Texture) {
ctx.window.draw_vertex_array(
vertex_array,
SfRenderStates {
texture: Some(&texture),
..Default::default... | code_fim | hard | {
"lang": "rust",
"repo": "krisaoe/peacock",
"path": "/src/graphics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo3p-pac path: /src/ctimer/cmprauxb1.rs
#[doc = "Reader of register CMPRAUXB1"]
pub type R = crate::R<u32, super::CMPRAUXB1>;
#[doc = "Writer for register CMPRAUXB1"]
pub type W = crate::W<u32, super::CMPRAUXB1>;
#[doc = "Register CMPRAUXB1 `reset()`'s with value 0"]
impl crate... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/cmprauxb1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>]
pub fn cmpr2b1(&self) -> CMPR2B1_R {
CMPR2B1_R::new((self.bits & 0xffff) as u16)
}
}
impl W {
#[doc = "Bits 16:31 - Counter/Timer B1 Compare Register 3. Holds the upper limit for timer half B."]
#[inline(always)]
pub fn cmpr3b1(&mut self) -> CMPR3B1_W {
CMPR3B1_W { w:... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/ctimer/cmprauxb1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MayDetach::wrap("Debug symbol upload", |handle| {
// Optionally detach if run from Xcode
if !matches.get_flag("force_foreground") {
handle.may_detach()?;
}
// Execute the upload
let (uploaded, has_processing_errors) = upload.upload()?;
let a... | code_fim | hard | {
"lang": "rust",
"repo": "getsentry/sentry-cli",
"path": "/src/commands/debug_files/upload.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: getsentry/sentry-cli path: /src/commands/debug_files/upload.rs
use std::collections::BTreeSet;
use std::str::{self, FromStr};
use anyhow::{bail, format_err, Result};
use clap::{builder::PossibleValuesParser, Arg, ArgAction, ArgMatches, Command};
use console::style;
use itertools::Itertools;
use... | code_fim | hard | {
"lang": "rust",
"repo": "getsentry/sentry-cli",
"path": "/src/commands/debug_files/upload.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nehalem501/ke04z4-pac path: /src/adc/apctl1.rs
#[doc = "Register `APCTL1` reader"]
pub struct R(crate::R<APCTL1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<APCTL1_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<A... | code_fim | hard | {
"lang": "rust",
"repo": "nehalem501/ke04z4-pac",
"path": "/src/adc/apctl1.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "ADC Pin Control\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u16)]
pub enum ADPC_A {
#[doc = "0: ADx pin I/O control enabled."]
_0 = 0,
#[doc = "1: ADx pin I/O control disabled."]
_1 = 1,
}
impl From<ADPC_A> for u16 {
#[inlin... | code_fim | hard | {
"lang": "rust",
"repo": "nehalem501/ke04z4-pac",
"path": "/src/adc/apctl1.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sitegui/cubique path: /src/main.rs
mod divider;
mod heuristic_cache;
mod plan;
use crate::divider::Divider;
use crate::heuristic_cache::HeuristicCache;
use itertools::Itertools;
use plan::{Plan, PlanBranch};
use std::collections::{HashSet, VecDeque};
use std::fmt::{Display, Formatter};
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/cubique",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> plan
}
fn best_solver(start: State, mut heuristic: impl FnMut(State) -> f64) -> Plan {
let mut visited_plans = HashSet::new();
let divider = Divider::new(start.target);
let mut pending = VecDeque::new();
let base_plan = Rc::new(Plan::new(start));
for (state, action) in base_plan.... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/cubique",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// This is a two bit integer and 12 bit fractional representation (##
pub mod XSCALE {
/// Offset (0 bits)
pub const offset: u32 = 0;
/// Mask (15 bits: 0x7fff << 0)
pub const mask: u32 = 0x7fff << offset;
/// Read-only values (empty)
pub mod R {}
... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/imxrt1052/pxp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-ral/src/imxrt105/imxrt1052/pxp.rs
always set to zero.
pub mod RSVD2 {
/// Offset (9 bits)
pub const offset: u32 = 9;
/// Mask (7 bits: 0x7f << 9)
pub const mask: u32 = 0x7f << offset;
/// Read-only values (empty)
... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/imxrt1052/pxp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Processed Surface Lower Right Coordinate
pub mod OUT_PS_LRC {
pub use super::OUT_LRC::RSVD0;
pub use super::OUT_LRC::RSVD1;
pub use super::OUT_LRC::X;
pub use super::OUT_LRC::Y;
}
/// Alpha Surface Upper Left Coordinate
pub mod OUT_AS_ULC {
pub use super::OUT_LRC::RSVD0;
pub u... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-ral/src/imxrt105/imxrt1052/pxp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/amethyst_tron path: /src/prefabs/gltf_prefabs.rs
use std::collections::HashMap;
use std::fs::read_dir;
use crate::prefabs::GltfScenePrefabData;
use amethyst::{
assets::{AssetStorage, Handle, Prefab, PrefabLoader, ProgressCounter, RonFormat},
ecs::World,
utils::application_ro... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/amethyst_tron",
"path": "/src/prefabs/gltf_prefabs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_prefabs(&mut self, prefabs: HashMap<String, Handle<Prefab<GltfScenePrefabData>>>) {
self.prefabs = prefabs;
}
}
fn make_name(subdirectory: &str, entry: &std::fs::DirEntry) -> String {
let path_buffer = entry.path();
let filename = path_buffer.file_name().unwrap();
f... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/amethyst_tron",
"path": "/src/prefabs/gltf_prefabs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Configuration {
name: "Test Tool",
version: "0.1",
about: "blabla",
options: vec![
TestConfig::TEST_PARAM,
TestConfig::TEST_PARAM2,
TestConfig::TEST_SWITCH,
... | code_fim | hard | {
"lang": "rust",
"repo": "datenkollektiv/common",
"path": "/config/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(matcher.is_present(TestConfig::TEST_PARAM.name));
assert_eq!(
matcher.value_of(TestConfig::TEST_PARAM.name).unwrap(),
"param1"
);
assert!(matcher.is_present(TestConfig::TEST_PARAM2.name));
assert_eq!(
matcher.value_of(Tes... | code_fim | hard | {
"lang": "rust",
"repo": "datenkollektiv/common",
"path": "/config/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datenkollektiv/common path: /config/src/lib.rs
//! This crate provides functionality to parse configuration from command line options and
//! optionally an external file.
//!
//! The configuration handling was heavily inspired by the way that ripgrep handles configuration
//! and roughly works a... | code_fim | hard | {
"lang": "rust",
"repo": "datenkollektiv/common",
"path": "/config/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let polygons = mesh
.indices()
.chunks(3)
.map(|tri| format!("[{},{},{}]", tri[0], tri[1], tri[2]))
.collect::<Vec<String>>()
.join(",");
if first {
first = false;
} else {
writeln!(out, ",")?;
... | code_fim | hard | {
"lang": "rust",
"repo": "dparnell/gobs",
"path": "/gobs-cli/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dparnell/gobs path: /gobs-cli/src/main.rs
extern crate dot_vox;
extern crate structopt;
use structopt::StructOpt;
use dot_vox::load;
use gobs::cubic_surface_extractor::extract_cubic_mesh;
use gobs::raw_volume::RawVolume;
use gobs::raw_volume_sampler::RawVolumeSampler;
use gobs::region::Region;... | code_fim | hard | {
"lang": "rust",
"repo": "dparnell/gobs",
"path": "/gobs-cli/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hamishgibbs/rust_dsa path: /src/bin/cocktail_shaker_sort.rs
/*
How it works:
Iterate up and down the array & swap elements if they are >
than the following element.
Example iterations where x = [4, 3, 2, 1]
i == 0: x = [1, 3, 2, 4]
i == 1: x = [1, 2, 3, 4]
*/
pub fn cocktail_shaker_sort<T: ... | code_fim | hard | {
"lang": "rust",
"repo": "hamishgibbs/rust_dsa",
"path": "/src/bin/cocktail_shaker_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut arr = Vec::<i32>::new();
cocktail_shaker_sort(&mut arr);
assert_eq!(arr, vec![])
}
#[test]
fn one_element() {
let mut arr = vec![1];
cocktail_shaker_sort(&mut arr);
assert_eq!(arr, vec![1]);
}
#[test]
fn pre_sorted() {
... | code_fim | hard | {
"lang": "rust",
"repo": "hamishgibbs/rust_dsa",
"path": "/src/bin/cocktail_shaker_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_range() {
assert_eq!(
ParseOnce::<_, CaptureInput<&str>>::parse_once(range(.., tag('.')), "...input"),
Ok(("input", vec!["."; 3]))
);
assert_eq!(
ParseOnce::<_, CaptureInput<&str>>::parse_once(range(..2, tag('.')), "...inp... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/dec",
"path": "/dec/src/imp/fold.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustyYato/dec path: /dec/src/imp/fold.rs
use dec_core::{
error::{Error, ErrorKind, PResult, ParseError},
Parse, ParseExt, ParseMut, ParseOnce,
};
use crate::{imp::ranged::Ranged, map::Map, try_fold::TryFold};
use core::ops::RangeBounds;
pub fn fold<P, A: Clone, F>(acc: A, parser: P, f... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/dec",
"path": "/dec/src/imp/fold.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parser = FoldRange {
parser: tag("."),
mk_acc: || 0,
func: |acc, _| acc + 1,
range: 2..=4,
};
let _: Error<CaptureInput<_>> = parser.parse(".").unwrap_err();
let (input, value) = parser.parse("..")?;
assert_eq!(i... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/dec",
"path": "/dec/src/imp/fold.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sanbox-irl/advent-of-code-2019 path: /src/day10/main.rs
const FIELD_WIDTH: usize = 10;
fn main() {
let mut input: Vec<Option<Asteroid>> = include_str!("input.txt")
.trim()
.lines()
.enumerate()
.flat_map(|(y, line_str)| {
line_str.chars().enumerat... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/advent-of-code-2019",
"path": "/src/day10/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn make_relationship(asteroid: &mut Asteroid, other: &Asteroid) {
let distance_vec2 = (
other.position.0 as f64 - asteroid.position.0 as f64,
asteroid.position.1 as f64 - other.position.1 as f64,
);
let distance = (distance_vec2.0 * distance_vec2.0 + distance_vec2.1 * distance_... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/advent-of-code-2019",
"path": "/src/day10/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a i32, j: &'b i32) -> i32 {
*i + *j
}<|fim_prefix|>// repo: mukulrawat1986/Rust-In-Action path: /add_with_lifetimes/src/main.rs
fn main() {
let res = add_with_lifet<|fim_middle|>imes(&10, &20);
println!("{}", res);
}
fn add_with_lifetimes <'a, 'b>(i: &' | code_fim | medium | {
"lang": "rust",
"repo": "mukulrawat1986/Rust-In-Action",
"path": "/add_with_lifetimes/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mukulrawat1986/Rust-In-Action path: /add_with_lifetimes/src/main.rs
fn main() {
let res = add_with_lifet<|fim_suffix|>a i32, j: &'b i32) -> i32 {
*i + *j
}<|fim_middle|>imes(&10, &20);
println!("{}", res);
}
fn add_with_lifetimes <'a, 'b>(i: &' | code_fim | medium | {
"lang": "rust",
"repo": "mukulrawat1986/Rust-In-Action",
"path": "/add_with_lifetimes/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Field `PLLI2SSRC` reader - PLLI2S entry clock source"]
pub struct PLLI2SSRC_R(crate::FieldReader<bool, PLLI2SSRC_A>);
impl PLLI2SSRC_R {
pub(crate) fn new(bits: bool) -> Self {
PLLI2SSRC_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumer... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f413/rcc/plli2scfgr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f413/rcc/plli2scfgr.rs
#[doc = "Register `PLLI2SCFGR` reader"]
pub struct R(crate::R<PLLI2SCFGR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PLLI2SCFGR_SPEC>;
#[inline(always)]
fn deref(&... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f413/rcc/plli2scfgr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `PLLI2SN` writer - PLLI2S multiplication factor for VCO"]
pub struct PLLI2SN_W<'a> {
w: &'a mut W,
}
impl<'a> PLLI2SN_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u16) -> &'a mut W {
self.w... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f413/rcc/plli2scfgr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Vote your stake through a proxy
#[derive(StructOpt, Debug)]
pub struct Proxy {
/// The voting account
pub voter: AccountName,
/// The proxy account
pub proxy: AccountName,
#[structopt(flatten)]
pub transaction_opts: super::TransactionOpts,
}
/// Vote for one or more producers
... | code_fim | hard | {
"lang": "rust",
"repo": "7db9a/scabere",
"path": "/eosio-rust/crates/eosio_cli/src/opts/system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 7db9a/scabere path: /eosio-rust/crates/eosio_cli/src/opts/system.rs
use eosio::{AccountName, Asset, PermissionName};
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
pub enum System {
/// Create a new account on the blockchain with initial resources
Newaccount(Newaccount),
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "7db9a/scabere",
"path": "/eosio-rust/crates/eosio_cli/src/opts/system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bytes = ledger_agent
.execute_update(
self.ledger_canister_id,
"send_pb",
ProtoBuf(send_args.clone())
.into_bytes()
.map_err(|err| (err, None))?,
get_nonce(),
)
... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/rosetta-api/cycles_minting_client/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let notify_args = NotifyCanisterArgs::new_from_send(
&send_args,
block_idx,
*self.cycles_canister_id,
Some(subaccount),
)
.map_err(|err| (err, None))?;
let bytes = agent
.execute_update(
self.ledge... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/rosetta-api/cycles_minting_client/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x0402/rosetta-node path: /rosetta-api/cycles_minting_client/src/lib.rs
use cycles_minting_canister::{
create_canister_txn, top_up_canister_txn, CreateCanisterResult, TopUpCanisterResult,
};
use dfn_protobuf::ProtoBuf;
use ic_canister_client::{Agent, HttpClient, Sender};
use ic_types::{Canis... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/rosetta-api/cycles_minting_client/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xieren58/zmodem path: /src/consts.rs
pub const ZPAD: u8 = b'*';
pub const ZLDE: u8 = 0x18;
pub const ZLDEE: u8 = 0x58;
pub const ZBIN: u8 = b'A'; // 0x41
pub const ZHEX: u8 = b'B'; // 0x42
pub const ZBIN32: u8 = b'C'; // 0x43
pub const ESC_FF: u8 = b'm';
pub const ESC_7F: u8 = b'l';
<... | code_fim | hard | {
"lang": "rust",
"repo": "xieren58/zmodem",
"path": "/src/consts.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/* ZDLE sequences */
pub const ZCRCE: u8 = b'h'; /* CRC next, frame ends, header packet follows */
pub const ZCRCG: u8 = b'i'; /* CRC next, frame continues nonstop */
pub const ZCRCQ: u8 = b'j'; /* CRC next, frame continues, ZACK expected */
pub const ZCRCW: u8 = b'k'; /* CRC next, ZACK expected, end of f... | code_fim | hard | {
"lang": "rust",
"repo": "xieren58/zmodem",
"path": "/src/consts.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.