text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> Ok(())
}
/// Arguments for the initial create project command
pub struct CreateSDImageArgs {
pub output_file: String,
}
pub fn create_sd_image(args: &CreateSDImageArgs) -> Result<(), Error> {
info!(
"Creating new SDCard (FAT32 FS) image at: {}",
args.output_file
);
/*let proj = AloeVeraProject... | code_fim | hard | {
"lang": "rust",
"repo": "yeastplume/aloevera",
"path": "/src/cmd/project/command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yeastplume/aloevera path: /src/cmd/project/command.rs
// Copyright 2020 Revcore Technologies Ltd.
//
// 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://... | code_fim | hard | {
"lang": "rust",
"repo": "yeastplume/aloevera",
"path": "/src/cmd/project/command.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_sd_image(args: &CreateSDImageArgs) -> Result<(), Error> {
info!(
"Creating new SDCard (FAT32 FS) image at: {}",
args.output_file
);
/*let proj = AloeVeraProject::new(id);
let json = proj.to_json()?;*/
//crate::cmd::common::output_to_file(&args.output_file, &json.as_bytes())?;
Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "yeastplume/aloevera",
"path": "/src/cmd/project/command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let target = args().nth(1).expect("Expected a target to match against");
let pattern = format!("%{target}%");
let connection = &mut establish_connection();
let num_deleted = diesel::delete(posts.filter(title.like(pattern)))
.execute(connection)
.expect("Error deleting post... | code_fim | easy | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/examples/postgres/getting_started_step_3/src/bin/delete_post.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diesel-rs/diesel path: /examples/postgres/getting_started_step_3/src/bin/delete_post.rs
use diesel::prelude::*;
use diesel_demo_step_3_pg::*;
use std::env::args;
<|fim_suffix|> use self::schema::posts::dsl::*;
let target = args().nth(1).expect("Expected a target to match against");
... | code_fim | easy | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/examples/postgres/getting_started_step_3/src/bin/delete_post.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0x1c6c8b36
}
fn interrupt(&mut self, cpu: &mut Cpu) -> Result<InterruptDelay, ()> {
let a = cpu.registers[0];
let b = cpu.registers[1];
match Command::from_u16(a) {
Some(Command::CLEAR_BUFFER) => self.key_buffer.clear(),
Some(Command::GET_NE... | code_fim | hard | {
"lang": "rust",
"repo": "azertyfun/dcpu",
"path": "/src/device/keyboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azertyfun/dcpu path: /src/device/keyboard.rs
use std::collections::VecDeque;
use std::fmt::Debug;
use num::traits::FromPrimitive;
use cpu::Cpu;
use device::*;
enum_from_primitive! {
#[allow(non_camel_case_types)]
#[derive(Debug)]
enum Command {
CLEAR_BUFFER = 0x0,
GET_NEXT = 0x1,
... | code_fim | hard | {
"lang": "rust",
"repo": "azertyfun/dcpu",
"path": "/src/device/keyboard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/clang-ast path: /tests/clone/lib.rs
#![allow(clippy::missing_panics_doc, clippy::must_use_candidate)]
<|fim_suffix|>pub fn cxx_ast_json() -> impl Deref<Target = [u8]> {
let out_dir = env!("OUT_DIR");
let ast_json = Path::new(out_dir).join("ast.json");
let file = File::open(a... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/clang-ast",
"path": "/tests/clone/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn cxx_ast_json() -> impl Deref<Target = [u8]> {
let out_dir = env!("OUT_DIR");
let ast_json = Path::new(out_dir).join("ast.json");
let file = File::open(ast_json).unwrap();
unsafe { Mmap::map(&file) }.unwrap()
}<|fim_prefix|>// repo: isgasho/clang-ast path: /tests/clone/lib.rs
#![all... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/clang-ast",
"path": "/tests/clone/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sum = 0;
for n in 1.. {
if n % 1_000_000_000 == 0 {println!("{}:\t{}", n, sum) }
let digits = digits(n);
for (i,&digit) in digits.iter().enumerate().skip(1) {
fs_n[i] += digit;
}
for &f in fs_n.iter().skip(1) {
if f == n { sum... | code_fim | medium | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p156_counting_digits/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emerentius/ProjectEuler path: /p156_counting_digits/src/main.rs
fn digits (mut num: u64) -> [u64; 10] {
let mut digits = [0;10];
while num != 0 {
digits[(num%10) as usize] += 1;
num /= 10;
}
digits
}
<|fim_suffix|> let mut sum = 0;
for n in 1.. {
i... | code_fim | medium | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p156_counting_digits/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
let face = '\u{1F600}'; // Exemplo emoji.
println!("{:?}", face);
}<|fim_prefix|>// repo: lucassouzavieira/explorando-rust path: /3-tipos/main.rs
//
// Tipos primitivos
// Integers: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128 (number of bits they take in memory)
// Floats:... | code_fim | medium | {
"lang": "rust",
"repo": "lucassouzavieira/explorando-rust",
"path": "/3-tipos/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucassouzavieira/explorando-rust path: /3-tipos/main.rs
//
// Tipos primitivos
// Integers: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128 (number of bits they take in memory)
// Floats: f32, f64
// Boolean
// Characters
// Tuples
// Arrays
<|fim_suffix|>pub fn main() {
let face = '\u{1F6... | code_fim | medium | {
"lang": "rust",
"repo": "lucassouzavieira/explorando-rust",
"path": "/3-tipos/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scotow/advent-of-code path: /2016/src/bin/day_06.rs
advent_of_code_2016::main!();
fn generator(input: &str) -> Vec<Vec<u8>> {
input.lines().map(|l| l.as_bytes().to_vec()).collect()
}
fn part_1(input: Vec<Vec<u8>>) -> String {
solve(input, true)
}
<|fim_suffix|> solve(input, false)
... | code_fim | medium | {
"lang": "rust",
"repo": "scotow/advent-of-code",
"path": "/2016/src/bin/day_06.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn solve(input: Vec<Vec<u8>>, max: bool) -> String {
(0..input.first().unwrap().len())
.map(|i| {
let iter = input.iter().map(|l| l[i]).counts().into_iter();
if max {
iter.max_by_key(|(_, n)| *n)
} else {
iter.min_by_key(|(_, ... | code_fim | hard | {
"lang": "rust",
"repo": "scotow/advent-of-code",
"path": "/2016/src/bin/day_06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: navalanche/n2k-codegen path: /src/main.rs
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_xml_rs;
extern crate env_logger;
use std::ops::Add;
use std::path::Path;
use std::fs::File;
use std::io::Write;
mod canboatxml;
use canboatxml::*;
pub fn n2k_codegen() {
... | code_fim | hard | {
"lang": "rust",
"repo": "navalanche/n2k-codegen",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn first_char_to_upper(field_name: &str) -> String {
let start = field_name.get(0..1).unwrap().to_ascii_uppercase();
let end = field_name.get(1..).unwrap();
String::from(start).add(end)
}
fn snake_name(field_name: &str) -> String {
//everytime we encounter a capital letter, insert an _ ... | code_fim | hard | {
"lang": "rust",
"repo": "navalanche/n2k-codegen",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cybrown/rust-example-1 path: /api/src/lib.rs
mod server;
use domain::DomainError;
pub use server::*;
use warp::reject::Reject;
<|fim_suffix|> Self(err)
}
}
impl Reject for ApiError {}<|fim_middle|>#[derive(Debug)]
struct ApiError(DomainError);
impl From<DomainError> for ApiError {... | code_fim | medium | {
"lang": "rust",
"repo": "cybrown/rust-example-1",
"path": "/api/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self(err)
}
}
impl Reject for ApiError {}<|fim_prefix|>// repo: cybrown/rust-example-1 path: /api/src/lib.rs
mod server;
use domain::DomainError;
pub use server::*;
use warp::reject::Reject;
#[derive(Debug)]
struct ApiError(DomainError);
<|fim_middle|>impl From<DomainError> for ApiError {... | code_fim | medium | {
"lang": "rust",
"repo": "cybrown/rust-example-1",
"path": "/api/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub resource_file_path: Option<String>,
pub parameter_file_path: Option<String>,
pub message_file_path: Option<String>,
pub help_link: Option<String>,
pub message_id: Option<u32>,
pub channels: Vec<Channel>,
pub levels: Vec<Level>,
pub tasks: Vec<Task>,
pub opcodes: ... | code_fim | hard | {
"lang": "rust",
"repo": "lespea/wevent_dumper",
"path": "/src/pub_metadata.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lespea/wevent_dumper path: /src/pub_metadata.rs
use shared::guiddef::GUID;
pub struct Channel {
pub name: Option<String>,
pub index: Option<u32>,
pub id: Option<u32>,
pub imported: bool,
pub message_id: Option<u32>,
}
pub struct Level {
pub name: Option<String>,
pub... | code_fim | hard | {
"lang": "rust",
"repo": "lespea/wevent_dumper",
"path": "/src/pub_metadata.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub message_id: Option<u32>,
pub channels: Vec<Channel>,
pub levels: Vec<Level>,
pub tasks: Vec<Task>,
pub opcodes: Vec<OpCode>,
pub keywords: Vec<Keyword>,
}<|fim_prefix|>// repo: lespea/wevent_dumper path: /src/pub_metadata.rs
use shared::guiddef::GUID;
pub struct Channel {
... | code_fim | hard | {
"lang": "rust",
"repo": "lespea/wevent_dumper",
"path": "/src/pub_metadata.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mesh1 = crate::test_utility::cube();
let mesh2: Mesh = TriMesh {
indices: Indices::U8(vec![0, 1, 2, 0, 2, 3, 0, 3, 4]),
positions: Positions::F64(vec![
vec3(-1.0, 1.0, 1.0),
vec3(-1.0, -1.0, 1.0),
vec3(1.0, -1.0, -... | code_fim | hard | {
"lang": "rust",
"repo": "asny/tri-mesh",
"path": "/src/operations/split.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asny/tri-mesh path: /src/operations/split.rs
});
let meshes1 =
self.split(&|_, halfedge_id| is_at_intersection(self, other, halfedge_id, &map1));
let meshes2 =
other.split(&|_, halfedge_id| is_at_intersection(other, self, halfedge_id, &map2));
(me... | code_fim | hard | {
"lang": "rust",
"repo": "asny/tri-mesh",
"path": "/src/operations/split.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asny/tri-mesh path: /src/operations/split.rs
()
}
.into();
let mut mesh2: Mesh = TriMesh {
positions: Positions::F64(vec![
vec3(-2.0, 0.0, 2.0),
vec3(-2.0, 0.0, -2.0),
vec3(-2.0, 0.5, 0.0),
]),
... | code_fim | hard | {
"lang": "rust",
"repo": "asny/tri-mesh",
"path": "/src/operations/split.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osaware/rCore-N path: /os/src/task/manager.rs
use core::borrow::Borrow;
use super::{current_task, TaskControlBlock};
use alloc::collections::VecDeque;
use alloc::sync::Arc;
pub struct TaskManager {
ready_queue: VecDeque<Arc<TaskControlBlock>>,
}
/// A simple FIFO scheduler.
impl TaskManag... | code_fim | hard | {
"lang": "rust",
"repo": "osaware/rCore-N",
"path": "/os/src/task/manager.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub fn add_task(task: Arc<TaskControlBlock>) {
// TASK_MANAGER.lock().add(task);
// }
// pub fn fetch_task() -> Option<Arc<TaskControlBlock>> {
// TASK_MANAGER.lock().fetch()
// }
// pub fn find_task(pid: usize) -> Option<Arc<TaskControlBlock>> {
// let current = current_task().unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "osaware/rCore-N",
"path": "/os/src/task/manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub fn find_task(pid: usize) -> Option<Arc<TaskControlBlock>> {
// let current = current_task().unwrap();
// if current.pid == pid {
// return Some(current);
// }
// TASK_MANAGER.lock().find(pid)
// }<|fim_prefix|>// repo: osaware/rCore-N path: /os/src/task/manager.rs
use core:... | code_fim | medium | {
"lang": "rust",
"repo": "osaware/rCore-N",
"path": "/os/src/task/manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/cancel-safe-futures path: /src/sink/mod.rs
//! Alternative extensions for [`Sink`].
use futures_sink::Sink;
mod flush_reserve;
pub use flush_reserve::FlushReserve;
mod permit;
pub use permit::Permit;
mod reserve;
use crate::support::assert_future;
pub use reserve::Reserve;
///... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/cancel-safe-futures",
"path": "/src/sink/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A future that completes once the sink is flushed, and an item is ready to be sent to it.
///
/// This is similar to [`reserve`](SinkExt::reserve), except it calls
/// [`poll_flush`](Sink::poll_flush) on the sink before calling [`poll_ready`](Sink::poll_ready)
/// on it.
fn flus... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/cancel-safe-futures",
"path": "/src/sink/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Run all ready-to-execute tasks
fn run_ready_tasks(&mut self) {
// While there are tasks to process in the queue
while let Some(mut task) = self.task_queue.pop_front() {
let task_id = task.id;
// Check if the task id is already in the waker cache
... | code_fim | hard | {
"lang": "rust",
"repo": "duncanrhamill/scos",
"path": "/src/task/executor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A waker for a particular task
struct TaskWaker {
/// The ID of the task to be woken
task_id: TaskId,
/// A sharted reference to the `Executor`'s wake queue
wake_queue: Arc<ArrayQueue<TaskId>>
}
impl TaskWaker {
/// Flag this task for waking
fn wake_task(&self) {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "duncanrhamill/scos",
"path": "/src/task/executor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duncanrhamill/scos path: /src/task/executor.rs
// ---------------------------------------------------------------------------
// USE STATEMENTS
// ---------------------------------------------------------------------------
use super::{Task, TaskId};
use alloc::{collections::{BTreeMap, VecDeque}... | code_fim | hard | {
"lang": "rust",
"repo": "duncanrhamill/scos",
"path": "/src/task/executor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rozaliev/async-await-rs path: /src/apps/dataflow.rs
// use std::ops::{State, Generator};
// use std::collections::HashMap;
// use std::hash::Hash;
// #[macro_export]
// macro_rules! get {
// ($g: ident, $e: expr) => ({
// match $g.resume($e) {
// State::Yielded(i) => i,
... | code_fim | hard | {
"lang": "rust",
"repo": "rozaliev/async-await-rs",
"path": "/src/apps/dataflow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// yield inp % n;
// }
// }
// fn memo<T>(mut target: T) -> impl Generator<u64, Return = !, Yield=u64>
// where T: Generator<u64,Return=!,Yield=u64> {
// let mut hm = HashMap::<u64,u64>::new();
// loop {
// let inp = gen arg;
// if let Some(v) = hm.get(&inp) {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "rozaliev/async-await-rs",
"path": "/src/apps/dataflow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgoodenough95/substrate-runtime-dev-academy-final-assignment path: /runtime/src/weights/pallet_kitties.rs
//! Autogenerated weights for pallet_kitties
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-05-02, STEPS: [], REPEAT: 1, LOW RANGE: [], ... | code_fim | medium | {
"lang": "rust",
"repo": "sgoodenough95/substrate-runtime-dev-academy-final-assignment",
"path": "/runtime/src/weights/pallet_kitties.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> (371_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn buy() -> Weight {
(949_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weig... | code_fim | hard | {
"lang": "rust",
"repo": "sgoodenough95/substrate-runtime-dev-academy-final-assignment",
"path": "/runtime/src/weights/pallet_kitties.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Index<usize> for IndirectRows {
type Output = [u8; 64];
fn index(&self, index: usize) -> &Self::Output {
unsafe {
std::mem::transmute::<*const u8, &[u8; 64]>(
self.rows
.as_ptr()
.offset(self.indirect_offset[index] a... | code_fim | hard | {
"lang": "rust",
"repo": "mapleFU/md-snippets",
"path": "/components/indirect_visit/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> IndirectRows {
indirect_offset,
rows,
}
}
}
impl Index<usize> for DirectRows {
type Output = [u8; 64];
fn index(&self, index: usize) -> &Self::Output {
&self.rows[index].data_bytes
}
}
impl Index<usize> for IndirectRows {
type Output =... | code_fim | hard | {
"lang": "rust",
"repo": "mapleFU/md-snippets",
"path": "/components/indirect_visit/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mapleFU/md-snippets path: /components/indirect_visit/src/lib.rs
use std::ops::Index;
#[derive(Copy, Clone)]
pub struct Row {
data_bytes: [u8; 64],
}
pub struct DirectRows {
rows: Vec<Row>,
}
impl DirectRows {
pub fn new_with_size(sz: usize) -> Self {
let mut rows = Vec::wi... | code_fim | medium | {
"lang": "rust",
"repo": "mapleFU/md-snippets",
"path": "/components/indirect_visit/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flyingliang/geoengine path: /services/src/handlers/wms.rs
eference> = result_descriptor.spatial_reference.into();
let spatial_reference = spatial_reference.ok_or(error::Error::MissingSpatialReference)?;
let response = format!(
r#"<WMS_Capabilities xmlns="http://www.opengis.net/w... | code_fim | hard | {
"lang": "rust",
"repo": "flyingliang/geoengine",
"path": "/services/src/handlers/wms.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let execution_context = ctx.execution_context(session)?;
let initialized = operator
.clone()
.initialize(&execution_context)
.await
.context(error::Operator)?;
// handle request and workflow crs matching
let workflow_spatial_ref: Option<SpatialReference> =... | code_fim | hard | {
"lang": "rust",
"repo": "flyingliang/geoengine",
"path": "/services/src/handlers/wms.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tokio::test]
async fn get_map() {
let res = get_map_test_helper(Method::GET, None).await;
assert_eq!(res.status(), 200);
assert_eq!(
include_bytes!("../../../test_data/wms/get_map.png") as &[u8],
test::read_body(res).await
);
}
#[... | code_fim | hard | {
"lang": "rust",
"repo": "flyingliang/geoengine",
"path": "/services/src/handlers/wms.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: supython-coder/leetcode-rust path: /S0063-unique-paths-ii/src/main.rs
struct Solution;
impl Solution {
pub fn unique_paths_with_obstacles(obstacle_grid: Vec<Vec<i32>>) -> i32 {
let mut res = vec![vec![0;obstacle_grid[0].len()]; obstacle_grid.len()];
(0..obstacle_grid.len())... | code_fim | hard | {
"lang": "rust",
"repo": "supython-coder/leetcode-rust",
"path": "/S0063-unique-paths-ii/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = vec![vec![0,0,0],vec![0,1,0],vec![0,0,0]];
println!("{:?}", Solution::unique_paths_with_obstacles(input));
let input = vec![vec![1,0]];
println!("{:?}", Solution::unique_paths_with_obstacles(input));
}<|fim_prefix|>// repo: supython-coder/leetcode-rust path: /S0063-unique-path... | code_fim | hard | {
"lang": "rust",
"repo": "supython-coder/leetcode-rust",
"path": "/S0063-unique-paths-ii/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fyang93/rust-leetcode path: /src/p0060_permutation_sequence.rs
// factorials 0! to 9!
const factorials: [i32; 10] = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880];
pub fn get_permutation(n: i32, k: i32) -> String {
let mut n = n as usize;
let mut k = k - 1; // index starts from 0 inst... | code_fim | medium | {
"lang": "rust",
"repo": "fyang93/rust-leetcode",
"path": "/src/p0060_permutation_sequence.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(get_permutation(3, 3), "213");
}
#[test]
fn it_works_1() {
assert_eq!(get_permutation(4, 9), "2314");
}
}<|fim_prefix|>// repo: fyang93/rust-leetcode path: /src/p0060_permutation_sequence.rs
// factorials 0! to 9!
const factorials: [i32; 10] = [1, 1, 2, 6, 24, ... | code_fim | medium | {
"lang": "rust",
"repo": "fyang93/rust-leetcode",
"path": "/src/p0060_permutation_sequence.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let user_account_info = next_account_info(account_info_iter)?;
let league = root.get_leagues()?.get(args.get_league_index())?;
let accepting_user_state = league
.get_user_states()?
.get_by_id(args.get_accepting_user_id())?;
let proposing_user_state = league
.get_... | code_fim | hard | {
"lang": "rust",
"repo": "moobaaclub/solana-fantasy-app",
"path": "/contracts/solana-fantasy-sports/src/processor/process_reject_swap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moobaaclub/solana-fantasy-app path: /contracts/solana-fantasy-sports/src/processor/process_reject_swap.rs
//! Program state processor
use crate::{
error::SfsError,
instructions,
instructions::{arguments::*, instruction::*},
processor::helpers,
state::*,
};
use arrayref::{arr... | code_fim | hard | {
"lang": "rust",
"repo": "moobaaclub/solana-fantasy-app",
"path": "/contracts/solana-fantasy-sports/src/processor/process_reject_swap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let league = root.get_leagues()?.get(args.get_league_index())?;
let accepting_user_state = league
.get_user_states()?
.get_by_id(args.get_accepting_user_id())?;
let proposing_user_state = league
.get_user_states()?
.get_by_id(args.get_proposing_user_id())?;
... | code_fim | medium | {
"lang": "rust",
"repo": "moobaaclub/solana-fantasy-app",
"path": "/contracts/solana-fantasy-sports/src/processor/process_reject_swap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(print(3), Some(" *\n***\n *\n".to_string()) );
assert_eq!(print(5), Some(" *\n ***\n*****\n ***\n *\n".to_string()) );
assert_eq!(print(-3),None);
assert_eq!(print(2),None);
assert_eq!(print(0),None);
assert_eq!(print(1), Some("*\n".to_string()) );
assert_eq!(print... | code_fim | medium | {
"lang": "rust",
"repo": "KamilFCB/Studies",
"path": "/Rust/Lista6/src/zad3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KamilFCB/Studies path: /Rust/Lista6/src/zad3.rs
fn print(n: i32) -> Option<String> {
if n < 1 || n % 2 == 0 {
return None;
}
let mut result: String = "".to_string();
let mut spaces: i32 = (n-1) / 2;
let mut asterisks: i32 = 1;
for i in 1..=n {
let mut line... | code_fim | medium | {
"lang": "rust",
"repo": "KamilFCB/Studies",
"path": "/Rust/Lista6/src/zad3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canadadry/rust-ray-tracer path: /src/engine/tracer.rs
use crate::engine::camera::Camera;
use crate::math::vector3::Vec3;
use crate::math::matrix3::Mat3;
use indicatif::{ProgressBar, ProgressStyle};
#[derive(Copy, Clone)]
pub struct Pixel(pub u8,pub u8,pub u8,pub u8);
impl Pixel {
pub fn w... | code_fim | hard | {
"lang": "rust",
"repo": "Canadadry/rust-ray-tracer",
"path": "/src/engine/tracer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_triangle_distance() {
let line_point = Vec3::new(0.0,0.0,0.0);
let line_dir = Vec3::new(7.0,3.0,1.0);
let p0 = Vec3::new(7.0,0.0,0.0);
let p1 = Vec3::new(7.0,5.0,0.0);
let p2 = Vec3::new(7.0,0.0,3.0);
let triangle = [p0,p1,p2];
let expected = ... | code_fim | hard | {
"lang": "rust",
"repo": "Canadadry/rust-ray-tracer",
"path": "/src/engine/tracer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exonum/exonum path: /services/supervisor/src/errors.rs
// Copyright 2020 The Exonum Team
//
// 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.... | code_fim | hard | {
"lang": "rust",
"repo": "exonum/exonum",
"path": "/services/supervisor/src/errors.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Instance-related errors group.
/// Error codes 32-47.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(ExecutionFail)]
#[non_exhaustive]
pub enum ServiceError {
/// Instance with the given name already exists.
InstanceExists = 32,
/// Instance name is incorrect.... | code_fim | hard | {
"lang": "rust",
"repo": "exonum/exonum",
"path": "/services/supervisor/src/errors.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eric-Arellano/advent_of_code_2020 path: /02/src/main.rs
/// Find the number of valid passwords.
struct PasswordPolicy {
letter: char,
num1: u8,
num2: u8,
}
impl PasswordPolicy {
fn new(letter: char, num1: u8, num2: u8) -> PasswordPolicy {
PasswordPolicy { letter, num1, ... | code_fim | hard | {
"lang": "rust",
"repo": "Eric-Arellano/advent_of_code_2020",
"path": "/02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let data = read_data();
let num_valid_pt1 = data
.iter()
.filter(|(policy, s)| policy.is_valid_policy1(s))
.count();
let num_valid_pt2 = data
.iter()
.filter(|(policy, s)| policy.is_valid_policy2(s))
.count();
println!("Num valid ... | code_fim | hard | {
"lang": "rust",
"repo": "Eric-Arellano/advent_of_code_2020",
"path": "/02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data.write_u32::<LittleEndian>(params.associated_data.len() as u32)
.unwrap();
data.append(&mut params.associated_data);
data.write_u32::<LittleEndian>(params.salt.len() as u32)
.unwrap();
data.append(&mut params.salt);
data
}
}
impl T... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/devolutions-crypto",
"path": "/devolutions-crypto/src/argon2parameters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/devolutions-crypto path: /devolutions-crypto/src/argon2parameters.rs
use std::{
convert::TryFrom,
io::{Cursor, Read},
};
use argon2::{Config, ThreadMode, Variant, Version};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use rand::rngs::OsRng;
use rand::Rng;
#[c... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/devolutions-crypto",
"path": "/devolutions-crypto/src/argon2parameters.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Generates the Rust code from the CapnProto schema.
fn main() {
::capnpc::CompilerCommand::new()
.file("addressbook.capnp")
.run()
.unwrap();
}<|fim_prefix|>// repo: drahnr/tokio-capnp-example path: /capnp_schema/src/main.rs
extern crate tokio;
extern crate tokio_core;
exte... | code_fim | easy | {
"lang": "rust",
"repo": "drahnr/tokio-capnp-example",
"path": "/capnp_schema/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drahnr/tokio-capnp-example path: /capnp_schema/src/main.rs
extern crate tokio;
extern crate tokio_core;
extern crate mio_uds;
extern crate capnp;
extern crate capnpc;
extern crate capnp_futures;
extern crate futures;
pub mod addressbook_capnp;
<|fim_suffix|> ::capnpc::CompilerCommand::new()... | code_fim | medium | {
"lang": "rust",
"repo": "drahnr/tokio-capnp-example",
"path": "/capnp_schema/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Prepares the command module enum.
#[doc(hidden)]
#[proc_macro_derive(CommandModule, attributes(cmd))]
pub fn derive_command_module(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
command_module::generate_run_fn(input)
}
/// Adds a `run` method to an enum... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri-macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tauri path: /core/tauri-macros/src/lib.rs
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use crate::context::ContextItems;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveIn... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri-macros/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Adds a `run` method to an enum (one of the tauri endpoint modules).
/// The `run` method takes a `tauri::endpoints::InvokeContext`
/// and returns a `tauri::Result<tauri::endpoints::InvokeResponse>`.
/// It matches on each enum variant and call a method with name equal to the variant name, lowercased ... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri-macros/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcarton/rust-gpg path: /tests/lib.rs
extern crate gnupg;
use gnupg::gpgme;
use gnupg::keys;
<|fim_suffix|> gpgme::init();
gpgme::init();
}
#[test]
fn test_key_list() {
let init = gpgme::init();
let mut it = keys::KeyIterator::new(init);
while it.next().is_some() {}
}<|fim_m... | code_fim | medium | {
"lang": "rust",
"repo": "mcarton/rust-gpg",
"path": "/tests/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcarton/rust-gpg path: /tests/lib.rs
extern crate gnupg;
use gnupg::gpgme;
use gnupg::keys;
#[test]
fn test_init() {
gpgme::init();
}
<|fim_suffix|> let mut it = keys::KeyIterator::new(init);
while it.next().is_some() {}
}<|fim_middle|>#[test]
fn test_init_twice() {
gpgme::init(... | code_fim | medium | {
"lang": "rust",
"repo": "mcarton/rust-gpg",
"path": "/tests/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut it = keys::KeyIterator::new(init);
while it.next().is_some() {}
}<|fim_prefix|>// repo: mcarton/rust-gpg path: /tests/lib.rs
extern crate gnupg;
use gnupg::gpgme;
use gnupg::keys;
#[test]
fn test_init() {
gpgme::init();
}
#[test]
fn test_init_twice() {
gpgme::init();
gpgme::... | code_fim | medium | {
"lang": "rust",
"repo": "mcarton/rust-gpg",
"path": "/tests/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tafia/calamine path: /src/datatype.rs
use std::fmt;
#[cfg(feature = "dates")]
use once_cell::sync::OnceCell;
use serde::de::Visitor;
use serde::{self, Deserialize};
use super::CellErrorType;
#[cfg(feature = "dates")]
static EXCEL_EPOCH: OnceCell<chrono::NaiveDateTime> = OnceCell::new();
#[cf... | code_fim | hard | {
"lang": "rust",
"repo": "tafia/calamine",
"path": "/src/datatype.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn visit_f64<E>(self, value: f64) -> Result<DataType, E> {
Ok(DataType::Float(value))
}
#[inline]
fn visit_str<E>(self, value: &str) -> Result<DataType, E>
where
E: serde::de::Error,
... | code_fim | hard | {
"lang": "rust",
"repo": "tafia/calamine",
"path": "/src/datatype.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(res_num) = id.try_to_integer() {
Ok(SpriteCursor {
id: Id::Resource(res_num.unwrap_into()),
..<_>::default()
})
} else if id.is_list() {
lingo_todo!(vm, "list-style sprite cursor")
// let data = movie.fix_up_d4_id(MemberId::from(c... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/earthquake-rust",
"path": "/libearthquake/src/lingo/kernel/system.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(super) fn kw_quit(vm: &mut Lingo, movie: &mut Movie, _: [Variant; 4]) -> VmResult<Variant> {
vm.quit_impl(movie);
vm.halt_impl(movie).map(|_| Variant::Void)
}
pub(super) fn kw_ticks(_: &mut Lingo, _: &mut Movie, _: [Variant; 4]) -> VmResult<Variant> {
Ok(Variant::Integer(
with_tim... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/earthquake-rust",
"path": "/libearthquake/src/lingo/kernel/system.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csnover/earthquake-rust path: /libearthquake/src/lingo/kernel/system.rs
//! Operating system related kernel calls.
use crate::{
event::cursor::{with_cursor_mut, Id, SpriteCursor},
lingo::{lingo_todo, prelude::*, SpriteNum},
movie::Movie,
platform::with_platform,
util::with_t... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/earthquake-rust",
"path": "/libearthquake/src/lingo/kernel/system.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let range_md_kind_id = tcx.llvm_md_kind_id_for_name("range");
let record_class_id_range_md = LLVMMDNodeInContext2(
tcx.llx,
llvm_range_values.as_mut_ptr(),
llvm_range_values.len(),
);
for llvm_value in self.re... | code_fim | hard | {
"lang": "rust",
"repo": "etaoins/arret",
"path": "/compiler/codegen/mod_gen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etaoins/arret path: /compiler/codegen/mod_gen.rs
use std::collections::HashMap;
use llvm_sys::core::*;
use llvm_sys::prelude::*;
use llvm_sys::target::*;
use llvm_sys::target_machine::*;
use llvm_sys::LLVMLinkage;
use arret_runtime::boxed::RecordClassId;
use arret_runtime::intern;
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "etaoins/arret",
"path": "/compiler/codegen/mod_gen.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxbyz/svgbob path: /packages/svgbob/src/buffer/fragment_buffer.rs
use crate::{buffer::Settings, Cell};
pub use direction::Direction;
pub use fragment::Fragment;
pub use fragment_tree::FragmentTree;
use itertools::Itertools;
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
p... | code_fim | hard | {
"lang": "rust",
"repo": "maxbyz/svgbob",
"path": "/packages/svgbob/src/buffer/fragment_buffer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FragmentBuffer {
pub fn new() -> Self {
FragmentBuffer(BTreeMap::new())
}
/// dump for debugging purpose only
/// printling the fragments on this fragment buffer
pub fn dump(&self) -> String {
let mut buff = String::new();
for (cell, shapes) in self.iter()... | code_fim | hard | {
"lang": "rust",
"repo": "maxbyz/svgbob",
"path": "/packages/svgbob/src/buffer/fragment_buffer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>;
impl_unary
!
(
f32x16
[
g
]
:
simd_fsqrt
)
;
impl_unary
!
(
f64x8
[
g
]
:
simd_fsqrt
)
;
impl_unary
!
(
f32x4
[
g
]
:
simd_fsqrt
)
;
impl_unary
!
(
f32x8
[
g
]
:
simd_fsqrt
)
;
impl_unary
!
(
f64x2
[
g
]
:
simd_fsqrt
)
;
impl_unary
!
(
f64x4
[
g
]
:
simd_fsqrt
)
;
}
}
}
else
{
impl_unary
!
(
f32x2
[
g
]... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/packed_simd_2/src/codegen/math/float/sqrte.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/packed_simd_2/src/codegen/math/float/sqrte.rs
/
/
!
Vertical
floating
-
point
sqrt
#
!
[
allow
(
unused
)
]
/
/
FIXME
64
-
bit
1
elem
vectors
sqrte
use
crate
:
:
llvm
:
:
simd_fsqrt
;
use
crate
:
:
*
;
pub
(
crate
)
trait
Sqrte
{
fn
sqrte
(
sel... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/packed_simd_2/src/codegen/math/float/sqrte.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::Solution;
#[test]
fn q048() {
{
let mut input = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
let output = vec![vec![7, 4, 1], vec![8, 5, 2], vec![9, 6, 3]];
Solution::rotate(&mut input);
assert_eq... | code_fim | hard | {
"lang": "rust",
"repo": "chux0519/leetcode-rust",
"path": "/archived/q048_rotate_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut input = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
let output = vec![vec![7, 4, 1], vec![8, 5, 2], vec![9, 6, 3]];
Solution::rotate(&mut input);
assert_eq!(input, output);
}
{
let mut input = vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "chux0519/leetcode-rust",
"path": "/archived/q048_rotate_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chux0519/leetcode-rust path: /archived/q048_rotate_image.rs
struct Solution;
impl Solution {
pub fn rotate(matrix: &mut Vec<Vec<i32>>) {
// use square and cycles( n / 2 )
let n = matrix.len();
let cycles = n / 2;
let mut top_left = (0, 0);
let mut to... | code_fim | hard | {
"lang": "rust",
"repo": "chux0519/leetcode-rust",
"path": "/archived/q048_rotate_image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = vec![self.config.path.clone()];
let uid = self.uid;
task::spawn(async move {
if let Err(e) = tx.send(SourceReply::StartStream(0)).await {
error!("Unix Socket Error: {}", e);
return;
}
let origin_uri = E... | code_fim | hard | {
"lang": "rust",
"repo": "devajithvs/tremor-runtime",
"path": "/src/source/unix_socket.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "json"
}
}
impl onramp::Impl for UnixSocket {
fn from_config(id: &TremorUrl, config: &Option<YamlValue>) -> Result<Box<dyn Onramp>> {
if let Some(config) = config {
let config: Config = Config::new(config)?;
Ok(Box::new(Self {
config,
... | code_fim | hard | {
"lang": "rust",
"repo": "devajithvs/tremor-runtime",
"path": "/src/source/unix_socket.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devajithvs/tremor-runtime path: /src/source/unix_socket.rs
// Copyright 2020-2021, The Tremor Team
//
// 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:/... | code_fim | hard | {
"lang": "rust",
"repo": "devajithvs/tremor-runtime",
"path": "/src/source/unix_socket.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
S: serde::ser::Serializer,
{
self.mode.serialize(serializer)
}
}
#[cfg(feature = "serialization")]
impl<'de> Deserialize<'de> for Kdf {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let mode ... | code_fim | hard | {
"lang": "rust",
"repo": "grafica/hpke-rs",
"path": "/src/kdf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grafica/hpke-rs path: /src/kdf.rs
#[cfg(feature = "serialization")]
pub(crate) use serde::{Deserialize, Serialize};
use crate::hkdf;
use crate::util::concat;
use std::fmt::Debug;
const HPKE_VERSION: &[u8] = b"HPKE-v1";
/// KDF Modes
#[derive(PartialEq, Copy, Clone, Debug)]
#[cfg_attr(feature... | code_fim | hard | {
"lang": "rust",
"repo": "grafica/hpke-rs",
"path": "/src/kdf.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samurailobster/rust-blockchain-1 path: /peer/src/handlers.rs
use blockchain_file::blocks::Block;
use blockchain_hooks::{EventCodes, Hooks};
use blockchain_protocol::BlockchainProtocol;
use blockchain_protocol::enums::status::StatusCodes;
use blockchain_protocol::payload::{FoundBlockPayload, Ping... | code_fim | hard | {
"lang": "rust",
"repo": "samurailobster/rust-blockchain-1",
"path": "/peer/src/handlers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hasher = Sha3::sha3_256();
hasher.input_str(generated_block.as_str());
let mut answer = BlockchainProtocol::<ValidatedHashPayload>::new().set_event_code(EventCodes::ValidatedHash);
answer.payload.index = message.payload.index;
answer.payload.hash = hasher.r... | code_fim | hard | {
"lang": "rust",
"repo": "samurailobster/rust-blockchain-1",
"path": "/peer/src/handlers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
::core::mem::transmute(RegDeleteKeyW(hkey.into_param().abi(), lpsubkey.into_param().abi()))
}
#[cfg(not(windows))]
unimplemented!("Unsupported target OS");
}
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn RegDeleteTreeA<'a, Param0: ::windows::core::IntoParam<'a,... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Win32/System/Registry/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/Registry/mod.rs
.field("wMilliseconds", &self.wMilliseconds)
.field("wResult", &self.wResult)
.finish()
}
}
impl ::core::cmp::PartialEq for DSKTLSYSTEMTIME {
fn eq(&self, other: &Self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Win32/System/Registry/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
::core::mem::transmute(RegCreateKeyExA(
hkey.into_param().abi(),
lpsubkey.into_param().abi(),
::core::mem::transmute(reserved),
lpclass.into_param().abi(),
::core::mem::transmute(dwoptions),
::core::mem::transmute(sa... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Win32/System/Registry/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panstromek/intellij-rust path: /src/test/resources/org/rust/ide/refactoring/move/fixtures/add_import_if_there_are_many_usages/before/usages1.rs
use crate::mod1::*;
<|fim_suffix|>fn test2() {
use crate::mod1;
mod1::foo::func();
}<|fim_middle|>// replace with absolute path if there is one... | code_fim | medium | {
"lang": "rust",
"repo": "panstromek/intellij-rust",
"path": "/src/test/resources/org/rust/ide/refactoring/move/fixtures/add_import_if_there_are_many_usages/before/usages1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::mod1;
mod1::foo::func();
}<|fim_prefix|>// repo: panstromek/intellij-rust path: /src/test/resources/org/rust/ide/refactoring/move/fixtures/add_import_if_there_are_many_usages/before/usages1.rs
use crate::mod1::*;
<|fim_middle|>// replace with absolute path if there is one usage
fn tes... | code_fim | medium | {
"lang": "rust",
"repo": "panstromek/intellij-rust",
"path": "/src/test/resources/org/rust/ide/refactoring/move/fixtures/add_import_if_there_are_many_usages/before/usages1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Blue-Pix/ezio path: /src/cookbook/development_tools/build_time_tooling/build.rs
fn main() {
// cc::Build::new()
// .file("src/cookbook/development_tools/build_time_tooling/hello.c")
// .compile("hello");
<|fim_suffix|>e("foo");
cc::Build::new()
.define("A... | code_fim | medium | {
"lang": "rust",
"repo": "Blue-Pix/ezio",
"path": "/src/cookbook/development_tools/build_time_tooling/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e("foo");
cc::Build::new()
.define("APP_NAME", "\"foo\"")
.define("VERSION", format!("\"{}\"", env!("CARGO_PKG_VERSION")).as_str())
.define("WELCOME", None)
.file("src/cookbook/development_tools/build_time_tooling/foo.c")
.compile("foo");
}<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "Blue-Pix/ezio",
"path": "/src/cookbook/development_tools/build_time_tooling/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cz-fish/advent-of-code path: /2016/src/03.rs
use std::fs::File;
use std::io::Read;
fn is_triangle(edges: &[i32; 3]) -> bool {
let m = edges.iter().max().unwrap();
edges.iter().sum::<i32>() - *m > *m
}
fn part1(maybe_triangles: &Vec<[i32; 3]>) -> usize {
maybe_triangles.iter().filte... | code_fim | hard | {
"lang": "rust",
"repo": "cz-fish/advent-of-code",
"path": "/2016/src/03.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_get_numbers() {
assert_eq!(get_numbers(" 100 25 11"),
vec![[100, 25, 11]])
}
#[test]
fn test1() {
assert_eq!(is_triangle(&[5, 10, 25]), false);
assert_eq!(is_triangle(&[3, 4, 5]), true);
}
#[test]
#[should_panic]
fn test2_wrong_size() {
// Length of the v... | code_fim | hard | {
"lang": "rust",
"repo": "cz-fish/advent-of-code",
"path": "/2016/src/03.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// --- Tests ---
#[test]
fn test_get_numbers() {
assert_eq!(get_numbers(" 100 25 11"),
vec![[100, 25, 11]])
}
#[test]
fn test1() {
assert_eq!(is_triangle(&[5, 10, 25]), false);
assert_eq!(is_triangle(&[3, 4, 5]), true);
}
#[test]
#[should_panic]
fn test2_wrong_size() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cz-fish/advent-of-code",
"path": "/2016/src/03.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noble-Mushtak/Advent-of-Code path: /2022/day25/src/lib.rs
use std::collections::VecDeque;
use std::error::Error;
use std::fs;
peg::parser! {
grammar parser() for str {
rule digit() -> isize
= c:($(['=' | '-' | '0' | '1' | '2'])) {
match c {
"=" => -... | code_fim | hard | {
"lang": "rust",
"repo": "Noble-Mushtak/Advent-of-Code",
"path": "/2022/day25/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.