text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> {
#[doc = "Bits 0:31 - Nonce1 from software for CTR, for region1. Nonce1={Nonce13,Nonce12,Nonce11,Nonce10}"]
#[inline(always)]
pub fn nonce11(&mut self) -> NONCE11_W {
NONCE11_W { w: self }
}
}<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-bee/src/ctr_no... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-bee/src/ctr_nonce1_w1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sstk.rs
pub unsafe fn sstk(incr: i32) -> Result<(), Errno> {
// TODO(Shaohua): Check <|fim_suffix|>
syscall1(SYS_SSTK, incr).map(drop)
}<|fim_middle|>return type
let incr = incr as usize; | code_fim | easy | {
"lang": "rust",
"repo": "XuShaohua/nc",
"path": "/src/calls/sstk.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sstk.rs
pub unsafe fn sstk(incr: i32) -> Result<<|fim_suffix|>return type
let incr = incr as usize;
syscall1(SYS_SSTK, incr).map(drop)
}<|fim_middle|>(), Errno> {
// TODO(Shaohua): Check | code_fim | easy | {
"lang": "rust",
"repo": "XuShaohua/nc",
"path": "/src/calls/sstk.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
syscall1(SYS_SSTK, incr).map(drop)
}<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sstk.rs
pub unsafe fn sstk(incr: i32) -> Result<<|fim_middle|>(), Errno> {
// TODO(Shaohua): Check return type
let incr = incr as usize; | code_fim | medium | {
"lang": "rust",
"repo": "XuShaohua/nc",
"path": "/src/calls/sstk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wking/cincinnati path: /vendor/pgp/src/packet/sym_encrypted_protected_data.rs
use std::{fmt, io};
use crate::crypto::SymmetricKeyAlgorithm;
use crate::errors::Result;
use crate::packet::PacketTrait;
use crate::ser::Serialize;
use crate::types::{Tag, Version};
use rand::{thread_rng, CryptoRng, R... | code_fim | hard | {
"lang": "rust",
"repo": "wking/cincinnati",
"path": "/vendor/pgp/src/packet/sym_encrypted_protected_data.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Tag::SymEncryptedProtectedData
}
}
impl fmt::Debug for SymEncryptedProtectedData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SymEncryptedProtectedData")
.field("packet_version", &self.packet_version)
.field("data", &hex::enc... | code_fim | hard | {
"lang": "rust",
"repo": "wking/cincinnati",
"path": "/vendor/pgp/src/packet/sym_encrypted_protected_data.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rgreenblatt/yew_router path: /src/matcher/mod.rs
//! Logic for matching and capturing route strings.
<|fim_suffix|>mod route_matcher;
pub use self::route_matcher::{MatcherSettings, RouteMatcher};<|fim_middle|>pub use yew_router_route_parser::{CaptureVariant, Captures, MatcherToken};
| code_fim | medium | {
"lang": "rust",
"repo": "rgreenblatt/yew_router",
"path": "/src/matcher/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod route_matcher;
pub use self::route_matcher::{MatcherSettings, RouteMatcher};<|fim_prefix|>// repo: rgreenblatt/yew_router path: /src/matcher/mod.rs
//! Logic for matching and capturing route strings.
<|fim_middle|>pub use yew_router_route_parser::{CaptureVariant, Captures, MatcherToken};
| code_fim | medium | {
"lang": "rust",
"repo": "rgreenblatt/yew_router",
"path": "/src/matcher/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HadrienG2/parallel-histograms-bench path: /src/lib.rs
pub mod impls;
pub mod thread_id;
pub mod traits;
#[cfg(test)]
mod tests {
use rand::SeedableRng;
use rand_xoshiro::Xoshiro128Plus;
use rayon::prelude::*;
use std::{
sync::Mutex,
time::Instant,
};
use... | code_fim | hard | {
"lang": "rust",
"repo": "HadrienG2/parallel-histograms-bench",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Run user-specified microbench, return number of nanosecs per iteration
fn microbench(runner: impl FnOnce() -> usize) {
let start = Instant::now();
let num_hits = runner();
let duration = start.elapsed();
assert_eq!(num_hits, NUM_ROLLS);
let nanosecs = du... | code_fim | hard | {
"lang": "rust",
"repo": "HadrienG2/parallel-histograms-bench",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn sequential_thread_local() {
let histogram = ThreadLocalHistogram::new(NUM_BINS);
sequential_microbench(histogram)
}
#[test]
fn parallel_atomic() {
let histogram = AtomicHistogram::new(NUM_BINS);
parallel_microbench(histogram)
}
#[tes... | code_fim | hard | {
"lang": "rust",
"repo": "HadrienG2/parallel-histograms-bench",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = &self.name;
let description = &self.description;
let extract_stream_type = TypeId::of::<Operation>() != TypeId::of::<Query>();
let fields_meta = self
.fields
.iter()
.map(|f| f.method_meta_tokens(extract_stream_type.then_some(... | code_fim | hard | {
"lang": "rust",
"repo": "grounzero/juniper",
"path": "/juniper_codegen/src/graphql_object/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grounzero/juniper path: /juniper_codegen/src/graphql_object/mod.rs
)
.map(|f| f.method_mark_tokens(coerce_result, scalar));
let interface_tys = self.interfaces.iter();
quote! {
#[automatically_derived]
impl #impl_generics ::juniper::marker::I... | code_fim | hard | {
"lang": "rust",
"repo": "grounzero/juniper",
"path": "/juniper_codegen/src/graphql_object/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grounzero/juniper path: /juniper_codegen/src/graphql_object/mod.rs
lue
/// [1]: https://spec.graphql.org/October2021#sec-Objects
pub(crate) scalar: scalar::Type,
/// Defined [GraphQL fields][2] of this [GraphQL object][1].
///
/// [1]: https://spec.graphql.org/October2021#se... | code_fim | hard | {
"lang": "rust",
"repo": "grounzero/juniper",
"path": "/juniper_codegen/src/graphql_object/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// the DP version is embarassingly easy
pub fn number_of_arithmetic_slices_dp(a: Vec<i32>) -> i32 {
let mut t = vec![0; a.len()];
let mut total = 0;
for i in 2..a.len() {
if a[i] - a[i - 1] == a[i - 1] - a[i - 2] {
t[i] = 1 + t[i - 1];
total += t[i];
}
... | code_fim | hard | {
"lang": "rust",
"repo": "leshow/exercism",
"path": "/hackerrank/src/arithmetic_slices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leshow/exercism path: /hackerrank/src/arithmetic_slices.rs
// 413. Arithmetic Slices
// Medium
// A sequence of number is called arithmetic if it consists of at least three
// elements and if the difference between any two consecutive elements is the
// same.
//
// For example, these are arithme... | code_fim | hard | {
"lang": "rust",
"repo": "leshow/exercism",
"path": "/hackerrank/src/arithmetic_slices.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hst/hst path: /hst-processes/src/lib.rs
// -*- coding: utf-8 -*-
// ------------------------------------------------------------------------------------------------
// Copyright © 2020, HST authors.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file e... | code_fim | medium | {
"lang": "rust",
"repo": "hst/hst",
"path": "/hst-processes/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use csp::CSP;
pub use event::DisjointSum;
pub use event::EventSet;
pub use maximal_traces::maximal_finite_traces;
pub use maximal_traces::MaximalTraces;
pub use primitives::Tau;
pub use primitives::Tick;
#[cfg(test)]
mod test_support;<|fim_prefix|>// repo: hst/hst path: /hst-processes/src/lib.rs
// ... | code_fim | medium | {
"lang": "rust",
"repo": "hst/hst",
"path": "/hst-processes/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schacker/actix-node-benchmark path: /actix-bench/src/routes.rs
use actix_web::{get, web::{Query, Data}, HttpResponse};
use crate::{errors::BenchError, db};
use deadpool_postgres::Pool;
use serde::Deserialize;
<|fim_suffix|> let tasks = db::get_tasks(db_pool.into_inner(), query.into_inner()).... | code_fim | hard | {
"lang": "rust",
"repo": "schacker/actix-node-benchmark",
"path": "/actix-bench/src/routes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tasks = db::get_tasks(db_pool.into_inner(), query.into_inner()).await?;
Ok(HttpResponse::Ok().json(tasks))
}<|fim_prefix|>// repo: schacker/actix-node-benchmark path: /actix-bench/src/routes.rs
use actix_web::{get, web::{Query, Data}, HttpResponse};
use crate::{errors::BenchError, db};
use d... | code_fim | hard | {
"lang": "rust",
"repo": "schacker/actix-node-benchmark",
"path": "/actix-bench/src/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Get tasks data matching criteria:
/// - assignee_name LIKE :assignee_name
/// - summary LIKE :summary
/// - LIMIT :limit
/// - full=true will return task.description
#[get("/tasks")]
pub async fn get_tasks(
query: Query<GetTasksQuery>, db_pool: Data<Pool>
) -> Result<HttpResponse, BenchError> {
... | code_fim | medium | {
"lang": "rust",
"repo": "schacker/actix-node-benchmark",
"path": "/actix-bench/src/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// "latest" is the latest calculated SMA values to omit recalculation.
fn sma_re(&self, period: usize, latest: &[f64]) -> Vec<f64>;
}<|fim_prefix|>// repo: taku-n/trta path: /src/lib.rs
mod imp;
pub mod trta;
pub trait TrTA {
fn sum(&self) -> f64;
fn avg(&self) -> f64;
// (1 2 3 4 ... | code_fim | hard | {
"lang": "rust",
"repo": "taku-n/trta",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // (1 2 3 4 5) => ((0) (0) (1 2 3) (2 3 4) (3 4 5))
fn window_under_zero(&self, period: usize) -> Vec<Vec<f64>>;
// (1 2 3 4 5) => ((0 0 1) (0 1 2) (1 2 3) (2 3 4) (3 4 5))
fn window_under_zero_with(&self, period: usize) -> Vec<Vec<f64>>;
// (1 2 3 4 5) => ((1 1 1) (1 1 2) (1 2 3) (2... | code_fim | hard | {
"lang": "rust",
"repo": "taku-n/trta",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taku-n/trta path: /src/lib.rs
mod imp;
pub mod trta;
pub trait TrTA {
fn sum(&self) -> f64;
fn avg(&self) -> f64;
// (1 2 3 4 5) => ((1 2 3) (2 3 4) (3 4 5))
fn window(&self, period: usize) -> Vec<Vec<f64>>;
<|fim_suffix|>
// "latest" is the latest calculated SMA values to ... | code_fim | hard | {
"lang": "rust",
"repo": "taku-n/trta",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn for_inc16() {
assert_eq!(
inc16(Word::new([O; 16])),
Word::new([O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, I])
);
assert_eq!(
inc16(Word::new([O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, I])),
Word::new([O, O, O,... | code_fim | hard | {
"lang": "rust",
"repo": "cola119/nand2tetris-rs",
"path": "/hardware/src/base/arithmetic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cola119/nand2tetris-rs path: /hardware/src/base/arithmetic.rs
#![allow(dead_code)]
use crate::base::logic::bit::{I, O};
use crate::base::logic::*;
pub fn half_adder(a: bit, b: bit) -> [bit; 2] {
[and(a, b), xor(a, b)]
}
pub fn full_adder(a: bit, b: bit, c: bit) -> [bit; 2] {
let bc = h... | code_fim | hard | {
"lang": "rust",
"repo": "cola119/nand2tetris-rs",
"path": "/hardware/src/base/arithmetic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn for_inc() {
assert_eq!(inc(O), [O, I]);
assert_eq!(inc(I), [I, O]);
}
#[test]
fn for_inc16() {
assert_eq!(
inc16(Word::new([O; 16])),
Word::new([O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, I])
);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "cola119/nand2tetris-rs",
"path": "/hardware/src/base/arithmetic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rtyler/azure-functions-rs path: /azure-functions/src/lib.rs
//!
//! # Example
//!
//! Start by installing the Azure Functions for Rust SDK:
//!
//! ```bash
//! $ cargo install azure-functions-sdk
//! ```
//!
//! Create a new Azure Functions for Rust application:
//!
//! ```bash
//! $ cargo func... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !Command::new("dotnet")
.args(&[
"msbuild",
"/t:_GenerateFunctionsExtensionsMetadataPostPublish",
"/v:q",
"/nologo",
"/restore",
"-p:Configuration=Release",
&format!("-p:PublishDir={}/", output_directory.to_... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rtyler/azure-functions-rs path: /azure-functions/src/lib.rs
Example
//!
//! Start by installing the Azure Functions for Rust SDK:
//!
//! ```bash
//! $ cargo install azure-functions-sdk
//! ```
//!
//! Create a new Azure Functions for Rust application:
//!
//! ```bash
//! $ cargo func new-app h... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoYouEvenCpp/aoc2015 path: /day18/src/main.rs
use std::fs;
type Map = Vec<Vec<char>>;
fn pase_input(input: &str) -> Map {
let mut data = Map::new();
for line in input.lines() {
data.push(vec![]);
for c in line.chars() {
data.last_mut().unwrap().push(c);
... | code_fim | hard | {
"lang": "rust",
"repo": "DoYouEvenCpp/aoc2015",
"path": "/day18/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut tmp = input.clone();
for _ in 0..100 {
input[0][0] = '#';
input[99][0] = '#';
input[0][99] = '#';
input[99][99] = '#';
for x in 0..100 {
for y in 0..100 {
let number_of_neighbours = get_number_of_neighbours(x, y, &input);
... | code_fim | hard | {
"lang": "rust",
"repo": "DoYouEvenCpp/aoc2015",
"path": "/day18/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.write(buf)
}
#[inline(always)]
fn flush(&mut self) -> io::Result<()> {
self.0.flush()
}
}
impl<W: Write> Close for NopCloser<W> {
#[inline(always)]
fn close(&mut self) -> io::Result<()> {
self.flush()
}
}
impl<W: Write> AsRef<W> for NopCloser<W... | code_fim | hard | {
"lang": "rust",
"repo": "secure-io/sio-rs",
"path": "/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: secure-io/sio-rs path: /src/utils.rs
use super::writer::Close;
use std::io;
use std::io::Write;
impl<T: Close + ?Sized> Close for &mut T {
#[inline(always)]
fn close(&mut self) -> io::Result<()> {
Close::close(*self)
}
}
impl Close for Vec<u8> {
#[inline(always)]
fn... | code_fim | hard | {
"lang": "rust",
"repo": "secure-io/sio-rs",
"path": "/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: corka149/jarvis path: /jarvis-backend/src/dto.rs
use chrono::DateTime;
use crate::model;
use chrono::serde::ts_seconds;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Product {
pub(crate) name: String,
pub(crate) amount: i32,
}
impl From<model::Produ... | code_fim | hard | {
"lang": "rust",
"repo": "corka149/jarvis",
"path": "/jarvis-backend/src/dto.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(prods) = model.products {
for prod in prods {
let mdl = prod.into();
products.push(mdl);
}
}
List {
id,
organization_uuid: orga_id,
no: model.no,
reason: model.reaso... | code_fim | medium | {
"lang": "rust",
"repo": "corka149/jarvis",
"path": "/jarvis-backend/src/dto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<model::List> for List {
fn from(model: model::List) -> Self {
let id: Option<String> = model._id.map(|id| id.to_string());
let orga_id = model.organization_uuid.map(|orga_id| orga_id.to_string());
let mut products: Vec<Product> = Vec::new();
if let Some(pro... | code_fim | hard | {
"lang": "rust",
"repo": "corka149/jarvis",
"path": "/jarvis-backend/src/dto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let x = array![1., 2., 3., 4., 5.];
println!("||x||_2 = {}", l2_norm(x.view()));
println!("||x||_1 = {}", l1_norm(x.view()));
println!("Normalizing x yields {:?}", normalize(x));
}<|fim_prefix|>// repo: d-z-h/rust-guide path: /examples/science/mathematics/linear-algebra/exampl... | code_fim | hard | {
"lang": "rust",
"repo": "d-z-h/rust-guide",
"path": "/examples/science/mathematics/linear-algebra/examples/vector-norm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn normalize(mut x: Array1<f64>) -> Array1<f64> {
let norm = l2_norm(x.view());
x.mapv_inplace(|e| e/norm);
x
}
fn main() {
let x = array![1., 2., 3., 4., 5.];
println!("||x||_2 = {}", l2_norm(x.view()));
println!("||x||_1 = {}", l1_norm(x.view()));
println!("Normalizing x yie... | code_fim | medium | {
"lang": "rust",
"repo": "d-z-h/rust-guide",
"path": "/examples/science/mathematics/linear-algebra/examples/vector-norm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d-z-h/rust-guide path: /examples/science/mathematics/linear-algebra/examples/vector-norm.rs
use ndarray::{array, Array1, ArrayView1};
fn l1_norm(x: ArrayView1<f64>) -> f64 {
x.fold(0., |acc, elem| acc + elem.abs())
}
fn l2_norm(x: ArrayView1<f64>) -> f64 {
x.dot(&x).sqrt()
}
fn normal... | code_fim | medium | {
"lang": "rust",
"repo": "d-z-h/rust-guide",
"path": "/examples/science/mathematics/linear-algebra/examples/vector-norm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackwener/leetcode path: /728.自除数.rs
/*
* @lc app=leetcode.cn id=728 lang=rust
*
* [728] 自除数
*/
<|fim_suffix|> for i in left..(right + 1) {
ans.push(i);
let mut x = i;
while 0 != x { // 判断是否自然数
let tmp = x % 10;
if 0... | code_fim | hard | {
"lang": "rust",
"repo": "jackwener/leetcode",
"path": "/728.自除数.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in left..(right + 1) {
ans.push(i);
let mut x = i;
while 0 != x { // 判断是否自然数
let tmp = x % 10;
if 0 != tmp && 0 == (i % tmp) {
x /= 10;
} else {
ans.pop();
... | code_fim | hard | {
"lang": "rust",
"repo": "jackwener/leetcode",
"path": "/728.自除数.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeJane/rust path: /v1/src/facades/gems.rs
use super::versions;
use crate::{models::gems::Gem, FrontDisplayMetaVersion};
use anyhow::Result;
use diesel::prelude::PgConnection;
pub fn get_gem_lis<|fim_suffix|>
versions::get_meta_version_relation_type_data::<Gem>(conn, version_id)
}<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "LeJane/rust",
"path": "/v1/src/facades/gems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
versions::get_meta_version_relation_type_data::<Gem>(conn, version_id)
}<|fim_prefix|>// repo: LeJane/rust path: /v1/src/facades/gems.rs
use super::versions;
use crate::{models::gems::Gem, FrontDisplayMetaVersion};
use anyhow::Result;
use diesel::prelude::PgConnection;
pub fn get_gem_lis<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "LeJane/rust",
"path": "/v1/src/facades/gems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t(conn: &PgConnection, version_id: i64) -> Result<FrontDisplayMetaVersion> {
versions::get_meta_version_relation_type_data::<Gem>(conn, version_id)
}<|fim_prefix|>// repo: LeJane/rust path: /v1/src/facades/gems.rs
use super::versions;
use crate::{models::gems::Gem, FrontDisplayMetaVersion}<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "LeJane/rust",
"path": "/v1/src/facades/gems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<GetUserDetailsError> for wamp_async::WampError {
fn from(err: GetUserDetailsError) -> Self {
Self::UnknownError(format!("Failed to get user details: {}", err))
}
}<|fim_prefix|>// repo: qbit-org-ua/dots-wamp-api-server path: /src/users/errors.rs
#[derive(Debug, thiserror::Error)... | code_fim | medium | {
"lang": "rust",
"repo": "qbit-org-ua/dots-wamp-api-server",
"path": "/src/users/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qbit-org-ua/dots-wamp-api-server path: /src/users/errors.rs
#[derive(Debug, thiserror::Error)]
pub enum GetUserDetailsError {
#[error("Internal error: {error_message}")]
InternalError { error_message: String },
#[error("Authentication error: {error}")]
Auth {
#[from]
... | code_fim | hard | {
"lang": "rust",
"repo": "qbit-org-ua/dots-wamp-api-server",
"path": "/src/users/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filecoin-project/filecoin-ffi path: /rust/src/util/types.rs
use std::{fmt::Display, mem::MaybeUninit, ops::Deref, panic, path::PathBuf, str::Utf8Error};
use safer_ffi::prelude::*;
use super::api::init_log;
#[derive_ReprC]
#[repr(i32)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum FCPR... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/filecoin-ffi",
"path": "/rust/src/util/types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn catch_panic_response_raw_no_log<F, T>(callback: F) -> repr_c::Box<Result<T>>
where
T: Sized + Default,
F: FnOnce() -> Result<T> + std::panic::UnwindSafe,
{
let result = match panic::catch_unwind(callback) {
Ok(t) => t,
Err(panic) => {
let error_msg = match pa... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/filecoin-ffi",
"path": "/rust/src/util/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Sized + Default> Result<T> {
pub fn err(err: impl Into<c_slice::Box<u8>>) -> Self {
Result {
status_code: FCPResponseStatus::UnclassifiedError,
error_msg: err.into(),
value: Default::default(),
}
}
}
pub type GpuDeviceResponse = Result<c... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/filecoin-ffi",
"path": "/rust/src/util/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // slot_full 42
c += reporter.process(42, None, PohTimingPoint::FullSlotReceived(120)) as i32;
// slot_full 43
c += reporter.process(43, None, PohTimingPoint::FullSlotReceived(140)) as i32;
// skip slot 42, jump to slot 43
// slot start 43
c += rep... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/core/src/poh_timing_reporter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /core/src/poh_timing_reporter.rs
//! A poh_timing_reporter module implement poh timing point and timing reporter
//! structs.
use {
solana_metrics::{datapoint_info, poh_timing_point::PohTimingPoint},
solana_sdk::clock::Slot,
std::{collections::HashMap, fmt},
... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/core/src/poh_timing_reporter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, Eq)]
pub struct BlockRewardInfo {
pub seed: U256,
pub online_target: U256,
pub compute_target: U256,
}
bind_topic!(WorkerReportEvent, b"^phala/system/report");
#[derive(Encode, Decode, Clone, Debug)]
... | code_fim | hard | {
"lang": "rust",
"repo": "trustex/phala-blockchain",
"path": "/common/types/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trustex/phala-blockchain path: /common/types/src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::vec::Vec;
use codec::{Decode, Encode};
use core::fmt::Debug;
// Messages: Phase Wallet
pub mod messaging {
use alloc::string::String;
use alloc::vec::Vec;
... | code_fim | hard | {
"lang": "rust",
"repo": "trustex/phala-blockchain",
"path": "/common/types/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcaddeo/docdoc path: /src/document.rs
use std::fs::{create_dir_all, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use serde_yaml;
use serde_yaml::Mapping;
use markdown::Markdown;
use tera::Context;
use theme::Theme;
use ::errors::*;
#[derive(Serialize, Debug)]
pub struct Doc... | code_fim | hard | {
"lang": "rust",
"repo": "marcaddeo/docdoc",
"path": "/src/document.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn render_document(
theme: &Theme,
template: &str,
document: &Document
) -> Result<String> {
// Merge document metadata into theme metadata
let mut theme_metadata = theme.get_metadata().clone();
let document_metadata_iter = document.get_metadata().iter();
for (key, value) ... | code_fim | hard | {
"lang": "rust",
"repo": "marcaddeo/docdoc",
"path": "/src/document.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fr0benius/contest-lib path: /rust/template.rs
#![allow(unused_imports)]
#![allow(unused_must_use)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::comparison... | code_fim | hard | {
"lang": "rust",
"repo": "Fr0benius/contest-lib",
"path": "/rust/template.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub struct $name<F, $($type, )*Output>
where
F: FnMut(&mut dyn $trait<$($type, )*Output>, $($type, )*) -> Output,
{
f: F,
$($arg: PhantomData<$type>,
)*
phantom_output: PhantomData<Output>,
}
impl<F, $($ty... | code_fim | hard | {
"lang": "rust",
"repo": "Fr0benius/contest-lib",
"path": "/rust/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self { reader, buf_str: vec![], buf_iter: "".split_whitespace() }
}
fn tok<T: str::FromStr>(&mut self) -> T {
loop {
if let Some(token) = self.buf_iter.next() {
return token.parse().ok().expect("Failed parse");
}
self.buf_str.clea... | code_fim | hard | {
"lang": "rust",
"repo": "Fr0benius/contest-lib",
"path": "/rust/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use client::*;
pub use behaviour::*;
pub use event::*;
pub use error::*;
pub use protocolconfig::*;
pub use protocol::*;<|fim_prefix|>// repo: libdist-rs/libchatter-rs path: /consensus/libp2p-experiment/client/mod.rs
mod handler;
mod client;
mod behaviour;
mod event;
mod error<|fim_middle|>;
mod protoco... | code_fim | medium | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/consensus/libp2p-experiment/client/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use error::*;
pub use protocolconfig::*;
pub use protocol::*;<|fim_prefix|>// repo: libdist-rs/libchatter-rs path: /consensus/libp2p-experiment/client/mod.rs
mod handler;
mod client;
mod behaviour;
mod event;
mod error;
mod protocolconfig;
mod protocol;
pub use handler::*;
pub<|fim_middle|> use client::... | code_fim | medium | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/consensus/libp2p-experiment/client/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libdist-rs/libchatter-rs path: /consensus/libp2p-experiment/client/mod.rs
mod handler;
mod client;
mod behaviour;
mod event;
mod error;
mod protocolconfig;
mod protocol;
pub use handler::*;
pub<|fim_suffix|>use error::*;
pub use protocolconfig::*;
pub use protocol::*;<|fim_middle|> use client::... | code_fim | medium | {
"lang": "rust",
"repo": "libdist-rs/libchatter-rs",
"path": "/consensus/libp2p-experiment/client/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(ret)
}
fn ask(list: &Vec<(String, String)>) {
let mut rng = rand::thread_rng();
let dist = rand::distributions::Uniform::new(0, list.len());
let (question, answer) = &list[dist.sample(&mut rng)];
print!("{}\n> ", question);
std::io::stdout().flush().unwrap();
let mut input ... | code_fim | hard | {
"lang": "rust",
"repo": "fiveseven-lambda/memorizer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiveseven-lambda/memorizer path: /src/main.rs
use rand::distributions::Distribution;
use std::io::{BufRead, BufReader, Write};
fn main() {
let mut args = std::env::args();
args.next();
if let Some(filename) = args.next() {
match read(filename) {
Ok(list) => loop ... | code_fim | hard | {
"lang": "rust",
"repo": "fiveseven-lambda/memorizer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pierrechevalier83/cards_ui path: /src/assets/mod.rs
extern crate cards;
extern crate conrod;
extern crate find_folder;
extern crate piston_window;
use std::path::PathBuf;
use piston_window::{Flip, G2dTexture, PistonWindow, Texture, TextureSettings};
pub fn hidden_card(window: &mut PistonWindow... | code_fim | hard | {
"lang": "rust",
"repo": "pierrechevalier83/cards_ui",
"path": "/src/assets/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match value {
Value::Two => "2",
Value::Three => "3",
Value::Four => "4",
Value::Five => "5",
Value::Six => "6",
Value::Seven => "7",
Value::Eight => "8",
Value::Nine => "9",
Value::Ten => "10",
Value::Jack => "J",
... | code_fim | hard | {
"lang": "rust",
"repo": "pierrechevalier83/cards_ui",
"path": "/src/assets/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: internetmusic/serum-dex path: /registry/src/accounts/pending_withdrawal.rs
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use serum_common::pack::Pack;
use serum_common::pack::*;
use solana_client_gen::solana_sdk::pubkey::Pubkey;
<|fim_suffix|>#[derive(Debug, Default, BorshSerializ... | code_fim | medium | {
"lang": "rust",
"repo": "internetmusic/serum-dex",
"path": "/registry/src/accounts/pending_withdrawal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Default, BorshSerialize, BorshDeserialize, BorshSchema)]
pub struct PendingWithdrawal {
pub initialized: bool,
/// Member this account belongs to.
pub member: Pubkey,
/// One time token. True if the withdrawal has been completed.
pub burned: bool,
/// The pool being... | code_fim | medium | {
"lang": "rust",
"repo": "internetmusic/serum-dex",
"path": "/registry/src/accounts/pending_withdrawal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn write_binary_file_if_changed(
path: impl AsRef<Path>,
content: impl AsRef<[u8]>,
) -> Result<(), Box<dyn Error>> {
let s = match fs::read(path.as_ref()) {
Ok(s) => s,
Err(_) => {
return fs::write(path.as_ref(), content.as_ref())
... | code_fim | hard | {
"lang": "rust",
"repo": "JoNil/loka-n64",
"path": "/game-pipeline/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoNil/loka-n64 path: /game-pipeline/src/utils.rs
use std::{error::Error, fs, path::Path};
pub(crate) fn write_file_if_changed(
path: impl AsRef<Path>,
content: impl AsRef<str>,
) -> Result<(), Box<dyn Error>> {
let s = match fs::read_to_string(path.as_ref()) {
Ok(s) =... | code_fim | hard | {
"lang": "rust",
"repo": "JoNil/loka-n64",
"path": "/game-pipeline/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if s != content.as_ref() {
return fs::write(path.as_ref(), content.as_ref())
.map_err(|e| format!("Unable to write {:?}: {}", path.as_ref(), e).into());
}
Ok(())
}<|fim_prefix|>// repo: JoNil/loka-n64 path: /game-pipeline/src/utils.rs
use std::{error::Error, fs, pat... | code_fim | hard | {
"lang": "rust",
"repo": "JoNil/loka-n64",
"path": "/game-pipeline/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/fnm.rs path: /src/choose_version_for_user_input.rs
use crate::config::FnmConfig;
use crate::installed_versions;
use crate::system_version;
use crate::user_version::UserVersion;
use crate::version::Version;
use colored::Colorize;
use log::info;
use snafu::{ensure, ResultExt, Snafu};
use s... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/fnm.rs",
"path": "/src/choose_version_for_user_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(ApplicableVersion {
path,
candidates: applicable_versions,
})
}
}
};
Ok(result)
}
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Can't find requested version: {}", requested_version))]... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/fnm.rs",
"path": "/src/choose_version_for_user_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: f5xs-0000a/yasc_project path: /src/song_player/lanes.rs
use crate::{
environment::{
actor_wrapper::{
ActorWrapper,
ContextWrapper,
RenderDetails,
RenderPayload,
RenderableActorWrapper,
UpdatePayload,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "f5xs-0000a/yasc_project",
"path": "/src/song_player/lanes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> texture: Texture<Resources>,
}
impl ActorWrapper for Lanes {
type Payload = ();
fn update(
&mut self,
_payload: UpdatePayload<Self::Payload>,
_ctx: &ContextWrapper<Self>,
)
{
// do nothing. this doesn't even need to update
}
}
impl RenderableActor... | code_fim | hard | {
"lang": "rust",
"repo": "f5xs-0000a/yasc_project",
"path": "/src/song_player/lanes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mathiasmagnusson/wrath path: /wrath-engine/src/events.rs
use crate::Overlay;
mod application_events;
mod keyboard_events;
mod mouse_events;
<|fim_suffix|>pub trait Event {
fn is_handled(&self) -> bool;
fn dispatch(&mut self, overlay: &mut dyn Overlay);
fn event_type(&self) -> EventType;
}
... | code_fim | medium | {
"lang": "rust",
"repo": "mathiasmagnusson/wrath",
"path": "/wrath-engine/src/events.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(PartialEq, Eq, Clone, Copy)]
pub enum EventType {
WindowCloseRequested,
WindowResized,
KeyPressed,
KeyReleased,
TextWritten,
MouseDown,
MouseUp,
MouseMove,
MouseScrolled,
}<|fim_prefix|>// repo: mathiasmagnusson/wrath path: /wrath-engine/src/events.rs
use crate::Overlay;
mod applicatio... | code_fim | hard | {
"lang": "rust",
"repo": "mathiasmagnusson/wrath",
"path": "/wrath-engine/src/events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inner
.poll_ready(cx)
.map(|result| result.map_err(|e| e.into()))
}
fn call(&mut self, req: R1) -> Self::Future {
let req = (self.f)(req);
self.inner.call(req).map_err(Into::into)
}
}
impl<S: Clone, R1, R2> Clone for Map<S, R1, R2> {
f... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/sinks/util/service2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn call(&mut self, req: R1) -> Self::Future {
let req = (self.f)(req);
self.inner.call(req).map_err(Into::into)
}
}
impl<S: Clone, R1, R2> Clone for Map<S, R1, R2> {
fn clone(&self) -> Self {
Self {
f: Arc::clone(&self.f),
inner: self.inner.clon... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/sinks/util/service2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alakahakai/vector path: /src/sinks/util/service2.rs
use super::retries2::{FixedRetryPolicy, RetryLogic};
use super::sink::Response;
use super::{Batch, BatchSink};
use crate::buffers::Acker;
use futures::TryFutureExt;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use std::task::Poll;
u... | code_fim | hard | {
"lang": "rust",
"repo": "alakahakai/vector",
"path": "/src/sinks/util/service2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match (req.method(), req.uri().path()) {
(&Method::GET, "/") => handlers::handle_root(),
(&Method::POST, "/echo") => handlers::handle_echo(req),
(&Method::POST, "/echo/uppercase") => handlers::handle_uppercase(req),
(&Method::POST, "/echo/reverse") => handlers::handle_r... | code_fim | medium | {
"lang": "rust",
"repo": "qubyte/rust-echo-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn router(req: Request<Body>) -> handlers::BoxFutResponse {
match (req.method(), req.uri().path()) {
(&Method::GET, "/") => handlers::handle_root(),
(&Method::POST, "/echo") => handlers::handle_echo(req),
(&Method::POST, "/echo/uppercase") => handlers::handle_uppercase(req),
... | code_fim | medium | {
"lang": "rust",
"repo": "qubyte/rust-echo-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qubyte/rust-echo-server path: /src/main.rs
extern crate hyper;
use hyper::{Body, Request, Server, Method};
use hyper::rt::{Future};
use hyper::service::service_fn;
extern crate futures;
#[macro_use]
extern crate serde_derive;
mod handlers;
<|fim_suffix|>fn main() {
let addr = ([127, 0, ... | code_fim | hard | {
"lang": "rust",
"repo": "qubyte/rust-echo-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: N2D4/advent-of-code-2020 path: /src/d12p1_rain_risk.rs
use crate::util;
fn solve(input: impl IntoIterator<Item = impl AsRef<str>>) -> i32 {
let mut pos: (i32, i32) = (0, 0);
let mut dir = 0;
for line in input {
let mut spl = (
line.as_ref().chars().next().unwrap(... | code_fim | medium | {
"lang": "rust",
"repo": "N2D4/advent-of-code-2020",
"path": "/src/d12p1_rain_risk.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(solve(vec!["F10", "N3", "F7", "R90", "F11"]), 25);
}
#[test]
fn test_example2() {
assert_eq!(solve(vec!["F10", "L90", "F3", "L270", "F7", "S11"]), 25);
}
#[test]
fn test() {
let input = util::read_input("d12_rain_risk.txt");
assert_eq!(solve(input.lines()), 879);
}<|fim_prefi... | code_fim | medium | {
"lang": "rust",
"repo": "N2D4/advent-of-code-2020",
"path": "/src/d12p1_rain_risk.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test() {
let input = util::read_input("d12_rain_risk.txt");
assert_eq!(solve(input.lines()), 879);
}<|fim_prefix|>// repo: N2D4/advent-of-code-2020 path: /src/d12p1_rain_risk.rs
use crate::util;
fn solve(input: impl IntoIterator<Item = impl AsRef<str>>) -> i32 {
let mut pos: (i32... | code_fim | medium | {
"lang": "rust",
"repo": "N2D4/advent-of-code-2020",
"path": "/src/d12p1_rain_risk.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub static SDL_HINT_FRAMEBUFFER_ACCELERATION: &'static str = "SDL_FRAMEBUFFER_ACCELERATION";
pub static SDL_HINT_RENDER_DRIVER: &'static str = "SDL_RENDER_DRIVER";
pub static SDL_HINT_RENDER_OPENGL_SHADERS: &'static str = "SDL_RENDER_OPENGL_SHADERS";... | code_fim | medium | {
"lang": "rust",
"repo": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/hints.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pakoito/sdl2-rs path: /src/sdl2/ffi/hints.rs
// Copyright 2014 The sdl2-rs Developers.
//
// 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": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/hints.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub enum SDL_HintPriority {
SDL_HINT_DEFAULT,
SDL_HINT_NORMAL,
SDL_HINT_OVERRIDE,
}
pub type SDL_HintCallback = extern "C" fn(userdata: *c_void, name: *c_char, oldValue: *c_char, newValue: *c_char);
extern "C" {
pub fn SDL_SetHintWithPriority(name: *c_char, value: *c_char, pri... | code_fim | hard | {
"lang": "rust",
"repo": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/hints.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: planet0104/rust_examples path: /neat-sweepers/src/win/ui.rs
use std::ptr::null_mut;
use winapi::shared::minwindef::{DWORD, HINSTANCE, LPARAM, LRESULT, UINT, WPARAM};
use winapi::shared::windef::{RECT, HBRUSH, HDC, HGDIOBJ, HICON, HMENU, HPEN, HWND, LPPOINT, POINT};
use winapi::um::wingdi::{PS_SO... | code_fim | hard | {
"lang": "rust",
"repo": "planet0104/rust_examples",
"path": "/neat-sweepers/src/win/ui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn start_game_loop(&mut self, game_loop: unsafe fn(&mut Window)) {
// 消息循环
while !self.done {
unsafe {
while winuser::PeekMessageW(&mut self.st_msg, 0 as HWND, 0, 0, PM_REMOVE) == 1 {
if self.st_msg.message == WM_QUIT {
... | code_fim | hard | {
"lang": "rust",
"repo": "planet0104/rust_examples",
"path": "/neat-sweepers/src/win/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A Function Call is an invocation of a function, passing arguments to produce work and output.
///
/// # Grammar
///
/// ```pest,no_run
/// FunctionCall =
/// { Identifier
/// ~ "("
/// ~ CommaSeparated(FunctionCallArgument)?
/// ~ ")"
/// ~ FunctionExpression?
/// }
/// ```
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-nafi",
"path": "/ast/src/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Function Declaration Arguments are the types and optional labels used to call the function.
///
/// # Grammar
///
/// ```pest,no_run
/// FunctionDeclarationArgument =
/// { ( Identifier
/// ~ TypeAscription
/// )
/// | Path
/// }
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
#... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-nafi",
"path": "/ast/src/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/rust-nafi path: /ast/src/functions.rs
//! Functions are units of behavior. They take input, do some work, and produce output.
use crate::{
containers::{Expression, Statement},
parser::Rule,
paths::Path,
terminals::Identifier,
Span, Spanned,
};
use pest_ast::FromPest;... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/rust-nafi",
"path": "/ast/src/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ktvoelker/GtkRust path: /functor/functor.rs
iface functor<T, U, V> {
fn fmap(f: fn(T) -> U) -> V;
}
<|fim_suffix|> ret alt self {
left(err) -> { left(err) }
right(val) -> { right(f(val)) }
};
}
}<|fim_middle|>impl<T, U> of functor<T, U, option<U>> for option<T> {
fn fm... | code_fim | hard | {
"lang": "rust",
"repo": "ktvoelker/GtkRust",
"path": "/functor/functor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret alt self {
left(err) -> { left(err) }
right(val) -> { right(f(val)) }
};
}
}<|fim_prefix|>// repo: ktvoelker/GtkRust path: /functor/functor.rs
iface functor<T, U, V> {
fn fmap(f: fn(T) -> U) -> V;
}
impl<T, U> of functor<T, U, option<U>> for option<T> {
fn fmap(f: fn(T) ->... | code_fim | medium | {
"lang": "rust",
"repo": "ktvoelker/GtkRust",
"path": "/functor/functor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KonishchevDmitry/investments path: /src/quotes/tinkoff/tinkoff.public.invest.api.contract.v1.rs
ate).
#[prost(message, tag = "7")]
ClearingCertificate(super::AssetClearingCertificate),
}
}
/// Акция.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::... | code_fim | hard | {
"lang": "rust",
"repo": "KonishchevDmitry/investments",
"path": "/src/quotes/tinkoff/tinkoff.public.invest.api.contract.v1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>EEDED" => Some(Self::LimitIsExceeded),
"SUBSCRIPTION_STATUS_INTERNAL_ERROR" => Some(Self::InternalError),
"SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS" => Some(Self::TooManyRequests),
"SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND" => {
Some(Self::SubscriptionNot... | code_fim | hard | {
"lang": "rust",
"repo": "KonishchevDmitry/investments",
"path": "/src/quotes/tinkoff/tinkoff.public.invest.api.contract.v1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>::String,
/// Признак доступности для ИИС.
#[prost(bool, tag = "36")]
pub for_iis_flag: bool,
/// Флаг отображающий доступность торговли инструментом только для квалифицированных инвесторов.
#[prost(bool, tag = "37")]
pub for_qual_investor_flag: bool,
/// Флаг отображающий дост... | code_fim | hard | {
"lang": "rust",
"repo": "KonishchevDmitry/investments",
"path": "/src/quotes/tinkoff/tinkoff.public.invest.api.contract.v1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-client-api/tests/headers.rs
#![cfg(feature = "client")]
use http::HeaderMap;
use ruma_client_api::discovery::discover_homeserver;
use ruma_common::api::{MatrixVersion, OutgoingRequest as _, SendAccessToken};
<|fim_suffix|> assert_eq!(*req.headers(), HeaderMap::d... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-client-api/tests/headers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.