text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: numtide/treefmt path: /benches/bench.rs
use criterion::{criterion_group, criterion_main, Criterion};
use std::path::PathBuf;
use treefmt::config;
<|fim_suffix|> assert!(root.is_ok());
})
});
}
criterion_group!(benches, bench_group);
criterion_main!(benches);<|fim_middle|... | code_fim | hard | {
"lang": "rust",
"repo": "numtide/treefmt",
"path": "/benches/bench.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: https-github-com-lolo4633/cargo-deny path: /src/cargo-deny/init.rs
use anyhow::{ensure, Context, Error};
use std::path::PathBuf;
use structopt::StructOpt;
use crate::common::make_absolute_path;
#[derive(StructOpt, Debug, Clone)]
pub struct Args {
/// The path to create
///
/// Defa... | code_fim | hard | {
"lang": "rust",
"repo": "https-github-com-lolo4633/cargo-deny",
"path": "/src/cargo-deny/init.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // make sure the path does not terminate in '..'; we need a file name.
ensure!(
cfg_file.file_name().is_some(),
"unable to create cargo-deny config: '{}' has an invalid filename",
cfg_file.display(),
);
std::fs::write(&cfg_file, CONTENTS).context("unable to write c... | code_fim | hard | {
"lang": "rust",
"repo": "https-github-com-lolo4633/cargo-deny",
"path": "/src/cargo-deny/init.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // make sure the file does not exist yet
ensure!(
std::fs::metadata(&cfg_file).is_err(),
"unable to initialize cargo-deny config: '{}' already exists",
cfg_file.display(),
);
// make sure the path does not terminate in '..'; we need a file name.
ensure!(
... | code_fim | hard | {
"lang": "rust",
"repo": "https-github-com-lolo4633/cargo-deny",
"path": "/src/cargo-deny/init.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: truchi/lay path: /generation/src/utils/ident.rs
use crate::*;
#[derive(Clone, PartialEq, Default)]
pub struct Ident {
pub pascal: Str,
pub snake: Str,
}
derefs!(self Ident {
deref Str { &self.pascal }
tokens { self.pascal.to_tokens(tokens) }
f { <Str as Display>::fmt(&self... | code_fim | hard | {
"lang": "rust",
"repo": "truchi/lay",
"path": "/generation/src/utils/ident.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Debug for Ident {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "({:#?}, {:#?})", self.pascal, self.snake)
}
}<|fim_prefix|>// repo: truchi/lay path: /generation/src/utils/ident.rs
use crate::*;
#[derive(Clone, PartialEq, Default)]
pub struct Ident {
pub pascal: St... | code_fim | hard | {
"lang": "rust",
"repo": "truchi/lay",
"path": "/generation/src/utils/ident.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn pascal(parts: &[&str]) -> Str {
Str::new(&parts.join(""))
}
pub fn snake(parts: &[&str]) -> Str {
Str::new(
&parts
.iter()
.map(|part| part.to_lowercase())
.collect::<Vec<_>>()
.join("_"),
... | code_fim | hard | {
"lang": "rust",
"repo": "truchi/lay",
"path": "/generation/src/utils/ident.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn append_request_timeout(mut self, timeout: f64) -> Self::Output {
if !timeout.is_sign_positive() {
panic!("`timeout` should be positive 64bit float number.")
}
let string = format!("{}", timeout);
self.argume... | code_fim | hard | {
"lang": "rust",
"repo": "cosmo0920/ruroonga_command",
"path": "/src/request_timeoutable/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !timeout.is_sign_positive() {
panic!("`timeout` should be positive 64bit float number.")
}
let string = format!("{}", timeout);
self.arguments.insert("request_timeout".to_string(), string.to_owned());
se... | code_fim | hard | {
"lang": "rust",
"repo": "cosmo0920/ruroonga_command",
"path": "/src/request_timeoutable/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cosmo0920/ruroonga_command path: /src/request_timeoutable/mod.rs
pub trait RequestTimeoutable {
type Output;
/// Specify `timeout` value. Unit: `seconds`
///
/// Panics if specified negative float value.
fn append_request_timeout(self, timeout: f64) -> Self::Output;
}
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "cosmo0920/ruroonga_command",
"path": "/src/request_timeoutable/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/libproc_macro/bridge/closure.rs
//! Closure type (equivalent to `&mut dyn FnMut(A) -> R`) that's `repr(C)`.
#[repr(C)]
pub struct Closure<'a, A, R> {
call: unsafe extern "C" fn(&mut Env, A) -> R,
env: &'a mut Env,
}
<|fim_suffix|>impl<'a, A, R... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/libproc_macro/bridge/closure.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
fn from(f: &'a mut F) -> Self {
unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: &mut Env, arg: A) -> R {
(*(env as *mut _ as *mut F))(arg)
}
Closure {
call: call::<A, R, F>,
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/libproc_macro/bridge/closure.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iotaledger/bee path: /bee-network/bee-gossip/src/network/meta.rs
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use std::fmt;
/// Meta information about an established connection.
#[derive(Clone, Debug)]
pub struct ConnectionInfo {
/// Whether the connection is... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-network/bee-gossip/src/network/meta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> origin = Origin::Outbound;
assert!(origin.is_outbound());
}
#[test]
fn display() {
assert_eq!(&Origin::Inbound.to_string(), "inbound");
assert_eq!(&Origin::Outbound.to_string(), "outbound");
}
}<|fim_prefix|>// repo: iotaledger/bee path: /bee-network/bee-g... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-network/bee-gossip/src/network/meta.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<M> InnerPool<M> where M: PoolManager {}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-19631.rs
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// pretty-expanded FIXME #23616
<|fim_middle|>trait PoolManager {
type C;
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-19631.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-19631.rs
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// pretty-expanded FIXME #23616
<|fim_suffix|>impl<M> InnerPool<M> where M: PoolManager {}
fn main() {}<|fim_middle|>trait PoolManager {
type C;
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-19631.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
struct InnerPool<M> {
manager: M,
}
impl<M> InnerPool<M> where M: PoolManager {}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-19631.rs
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// pretty-expanded FIXME #23616
<|... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-19631.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if luma_pixel.data[0] < 30 {
if start_height == 0 {
// println!("setting start height {:?}", row);
start_height = row;
}
}
if start_height != 0 {
if luma_pixel.data[0] < 50 {
end_height = row;
}
if end_height != row ||... | code_fim | hard | {
"lang": "rust",
"repo": "JamesLinus/piano-breaker",
"path": "/vision/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesLinus/piano-breaker path: /vision/src/main.rs
extern crate image;
use std::path::Path;
use std::env;
use image::{
GenericImage,
Pixel
};
fn main() {
let piano_image: String = match env::args().nth(1) {
Some(piano_image) => piano_image,
None => panic!("No image... | code_fim | hard | {
"lang": "rust",
"repo": "JamesLinus/piano-breaker",
"path": "/vision/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Ignore all bindings that have `#[collect(require_static)]`
// For each binding with `#[collect(require_static)]`, we
// push a bound of the form `FieldType: 'static` to `static_bindings`,
// which will be added to the genererated `Collect` impl.
// The presence o... | code_fim | hard | {
"lang": "rust",
"repo": "Techcable/gc-arena",
"path": "/src/gc-arena-derive/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut errors = vec![];
let collect_impl = if mode == Mode::RequireStatic {
s.clone().add_bounds(AddBounds::None).gen_impl(quote! {
gen unsafe impl gc_arena::Collect for @Self #where_clause {
#[inline]
fn needs_trace() -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "Techcable/gc-arena",
"path": "/src/gc-arena-derive/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Techcable/gc-arena path: /src/gc-arena-derive/src/lib.rs
use proc_macro2::{Span, TokenStream};
use quote::{quote, quote_spanned, ToTokens};
use syn::spanned::Spanned;
use synstructure::{decl_derive, AddBounds};
fn collect_derive(mut s: synstructure::Structure) -> TokenStream {
// Deriving `... | code_fim | hard | {
"lang": "rust",
"repo": "Techcable/gc-arena",
"path": "/src/gc-arena-derive/src/lib.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut i, mut j, mut d) = (0, 0, -1);
let (n, m) = (a.len(), b.len());
while i < n && j < m {
if a[i] == b[j] {
i += 1;
j += 1;
} else {
d = a[i];
i += 1;
}
}
(j == m - 1) && (b[j] != d)
}<|fim_prefix|>// repo: q... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/leetcode/faulty-sensor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qeedquan/challenges path: /leetcode/faulty-sensor.rs
/*
An experiment is being conducted in a lab. To ensure accuracy, there are two sensors collecting data simultaneously. You are given 2 arrays sensor1 and sensor2, where sensor1[i] and sensor2[i] are the ith data points collected by the two s... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/leetcode/faulty-sensor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bad(a: &Vec<isize>, b: &Vec<isize>) -> isize {
let r0 = replaceable(b, a);
let r1 = replaceable(a, b);
match (r0, r1) {
(true, true) => -1,
(false, false) => -1,
(true, false) => 1,
(false, true) => 2,
}
}
fn replaceable(a: &Vec<isize>, b: &Vec<isize>) -... | code_fim | hard | {
"lang": "rust",
"repo": "qeedquan/challenges",
"path": "/leetcode/faulty-sensor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> static RedisModule_CallReplyStringPtr:
extern "C" fn(str: *mut RedisModuleCallReply, len: *mut size_t) -> *const u8;
static RedisModule_CallReplyLength:
extern "C" fn(reply: *mut RedisModuleCallReply) -> size_t;
static RedisModule_CallReplyArrayElement:
extern "C" fn(... | code_fim | hard | {
"lang": "rust",
"repo": "yutapok/redis-mod-rs",
"path": "/redis-mod/src/redis/raw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn reply_with_null(
ctx: *mut RedisModuleCtx
){ unsafe { RedisModule_ReplyWithNull(ctx) } }
pub fn free_string(ctx: *mut RedisModuleCtx, str: *mut RedisModuleString) {
unsafe { RedisModule_FreeString(ctx, str) }
}
pub fn log(ctx: *mut RedisModuleCtx, level: *const u8, fmt: *const u8) {
... | code_fim | hard | {
"lang": "rust",
"repo": "yutapok/redis-mod-rs",
"path": "/redis-mod/src/redis/raw.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutapok/redis-mod-rs path: /redis-mod/src/redis/raw.rs
// Allow dead code in here in case I want to publish it as a crate at some
// point.
#![allow(dead_code)]
extern crate libc;
use libc::{c_int, c_long, c_longlong, size_t};
use std::os::raw::c_void;
// Rust can't link against C macros (#de... | code_fim | hard | {
"lang": "rust",
"repo": "yutapok/redis-mod-rs",
"path": "/redis-mod/src/redis/raw.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl ExistingAccounts {
#[cfg(target_arch = "wasm32")]
pub fn new(title: String, json: &str) -> Self {
Self {
title,
json_b64: data_encoding::BASE64.encode(json.as_bytes()),
..Default::default()
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "vbarrielle/aaacs",
"path": "/src/gui_iced/file_selector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vbarrielle/aaacs path: /src/gui_iced/file_selector.rs
//! A file selector for local storage
#[cfg(target_arch = "wasm32")]
use iced::Row;
use iced::{button, text_input, Button, Column, Element, Text, TextInput};
#[cfg(target_arch = "wasm32")]
use crate::gui_iced::file_input::FileInput;
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "vbarrielle/aaacs",
"path": "/src/gui_iced/file_selector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: camallo/appc-rs path: /tests/pod.rs
extern crate appc;
extern crate serde_json;
<|fim_suffix|>#[test]
fn test_pod_manifest_example() {
let f = fs::File::open("tests/fixtures/example-pod-manifest.json").expect("Missing fixture");
let bufrd = io::BufReader::new(f);
let _manif: appc::s... | code_fim | easy | {
"lang": "rust",
"repo": "camallo/appc-rs",
"path": "/tests/pod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let f = fs::File::open("tests/fixtures/example-pod-manifest.json").expect("Missing fixture");
let bufrd = io::BufReader::new(f);
let _manif: appc::schema::PodManifest = serde_json::from_reader(bufrd).unwrap();
}<|fim_prefix|>// repo: camallo/appc-rs path: /tests/pod.rs
extern crate appc;
exte... | code_fim | medium | {
"lang": "rust",
"repo": "camallo/appc-rs",
"path": "/tests/pod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
fn digest(self) -> Vec<u8> {
let mut out = Vec::from_elem(16, 0u8);
store_32h!(self.a, out.mut_slice(0, 4));
store_32h!(self.b, out.mut_slice(4, 8));
store_32h!(self.c, out.mut_slice(8, 12));
store_32h!(self.d, out.mut_slice(12, 16));
re... | code_fim | medium | {
"lang": "rust",
"repo": "jmgrosen/crusty-crypto",
"path": "/src/md5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmgrosen/crusty-crypto path: /src/md5.rs
use HashFn;
pub struct Md5 {
a: u32,
b: u32,
c: u32,
d: u32,
total: [u32, ..2],
buflen: u32,
buffer: [u32, ..32]
}
<|fim_suffix|> }
}
fn digest(self) -> Vec<u8> {
let mut out = Vec::from_elem(16, 0u8);... | code_fim | hard | {
"lang": "rust",
"repo": "jmgrosen/crusty-crypto",
"path": "/src/md5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut out = Vec::from_elem(16, 0u8);
store_32h!(self.a, out.mut_slice(0, 4));
store_32h!(self.b, out.mut_slice(4, 8));
store_32h!(self.c, out.mut_slice(8, 12));
store_32h!(self.d, out.mut_slice(12, 16));
return out;
}
}<|fim_prefix|>// repo: jmgrosen/c... | code_fim | medium | {
"lang": "rust",
"repo": "jmgrosen/crusty-crypto",
"path": "/src/md5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub struct Config {
pub file_path: PathBuf,
pub cache_dir: PathBuf,
pub settings: Settings,
}
impl Config {
// TODO: Change some of the panics in this function to returning errors.
pub fn load(opts: &Opts) -> Result<Self, ()> {
let config_file_name = "c... | code_fim | hard | {
"lang": "rust",
"repo": "cdepillabout/break-time",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cdepillabout/break-time path: /src/config.rs
mod default;
use std::default::Default;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use crate::opts::Opts;
use default::DEFAULT_CONFIG_SETTINGS;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(transparent)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "cdepillabout/break-time",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Try reading the config file to see whether it exists or not.
let res_config_file = std::fs::read_to_string(&config_file_path);
let settings = match res_config_file {
// TODO: I should probably check here the reason we are getting an
// error. If there is... | code_fim | hard | {
"lang": "rust",
"repo": "cdepillabout/break-time",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /crates/wasi/src/preview2/filesystem.rs
use crate::preview2::{StreamRuntimeError, StreamState, Table, TableError};
use bytes::{Bytes, BytesMut};
use std::sync::Arc;
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct FilePerms: u... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/wasi/src/preview2/filesystem.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn read(&mut self, size: usize) -> anyhow::Result<(Bytes, StreamState)> {
use system_interface::fs::FileIoExt;
let f = Arc::clone(&self.file);
let p = self.position;
let (r, mut buf) = tokio::task::spawn_blocking(move || {
let mut buf = BytesMut::z... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/crates/wasi/src/preview2/filesystem.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cleech/adventofcode2016 path: /src/bin/day11.rs
#[macro_use]
extern crate lazy_static;
use std::fmt;
use std::fmt::Display;
use std::collections::VecDeque;
use std::collections::HashSet;
extern crate arrayvec;
use arrayvec::ArrayVec;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode2016",
"path": "/src/bin/day11.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> WorldState {
moves: 0,
elevator: 0,
stuff: ArrayVec::new(),
}
}
fn key(&self) -> ArrayVec<[usize; 16]> {
let mut key = ArrayVec::new();
key.push(self.elevator);
for &Stuff(m, g, _) in self.stuff.iter() {
key.p... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode2016",
"path": "/src/bin/day11.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> world.stuff.clear();
world.stuff.push(Stuff(0, 0, 'P'));
world.stuff.push(Stuff(0, 0, 'S'));
world.stuff.push(Stuff(1, 1, 'C'));
world.stuff.push(Stuff(1, 1, 'R'));
world.stuff.push(Stuff(2, 1, 'T'));
world.stuff.sort();
}
#[allow(dead_code)]
fn load_part_two(world: &mut World... | code_fim | hard | {
"lang": "rust",
"repo": "cleech/adventofcode2016",
"path": "/src/bin/day11.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DocumentBlock {
pub fn build_add_action_object(block_id: i64) -> ActionObject {
ActionObject::method(Self::build_add_method_object(block_id))
}
pub fn build_add_method_object(block_id: i64) -> MethodObject {
MethodObject {
block_type: Self::name(),
block_id: block_id.to_string(),
meth... | code_fim | hard | {
"lang": "rust",
"repo": "loop-revolution/document-block",
"path": "/methods/add.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loop-revolution/document-block path: /methods/add.rs
use crate::blocks::document_block::DocumentBlock;
use block_tools::{
auth::{
permissions::{has_perm_level, PermLevel},
require_token, validate_token,
},
blocks::BlockType,
blocks::Context,
display_api::{ActionObject, MethodObject},
m... | code_fim | medium | {
"lang": "rust",
"repo": "loop-revolution/document-block",
"path": "/methods/add.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate quick_error;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate slog_global;
#[allow(unused_extern_crates)]
extern crate tikv_alloc;
mod config;
mod errors;
pub mod metrics;
mod util;
#[macro_use]
pub mod service;
pub mod imp... | code_fim | medium | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/sst_importer/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: innerr/tikv path: /components/sst_importer/src/lib.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
//! Importing RocksDB SST files into TiKV
<|fim_suffix|>mod config;
mod errors;
pub mod metrics;
mod util;
#[macro_use]
pub mod service;
pub mod import_mode;
pub mod sst_imp... | code_fim | hard | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/sst_importer/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::config::Config;
pub use self::errors::{error_inc, Error, Result};
pub use self::sst_importer::{SSTImporter, SSTWriter};
pub use self::util::prepare_sst_for_ingestion;<|fim_prefix|>// repo: innerr/tikv path: /components/sst_importer/src/lib.rs
// Copyright 2018 TiKV Project Authors. Licensed... | code_fim | medium | {
"lang": "rust",
"repo": "innerr/tikv",
"path": "/components/sst_importer/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> //计算耗费的时间,并延迟
let elapsed_ms = (start_time.elapsed().subsec_nanos()/1_000_000) as u64;
//println!("time:{}", elapsed_ms);
if elapsed_ms<1000/fps as u64{
thread::sleep(Duration::from_... | code_fim | hard | {
"lang": "rust",
"repo": "zeroows/webcam_demo",
"path": "/src/webcam.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zeroows/webcam_demo path: /src/webcam.rs
extern crate rscam;
extern crate ws;
use x264_encoder::X264Encoder;
use ws::{Message, Sender};
use rscam::{Camera};
use std::thread;
use std::collections::HashMap;
use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{Arc, Mutex};
use std::time::... | code_fim | hard | {
"lang": "rust",
"repo": "zeroows/webcam_demo",
"path": "/src/webcam.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/smallvec/src/lib.rs
assert
!
(
new_cap
>
=
len
)
;
if
new_cap
<
=
self
.
inline_size
(
)
{
if
unspilled
{
return
Ok
(
(
)
)
;
}
self
.
data
=
SmallVecData
:
:
from_inline
(
MaybeUninit
:
:
uninit
(
)
)
;
ptr
:
:
copy_nonoverlapping
(
ptr
self
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/smallvec/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/smallvec/src/lib.rs
kip
.
contains
(
&
i
)
{
unsafe
{
ptr
:
:
drop_in_place
(
self
.
start
.
add
(
i
)
)
;
}
}
}
}
}
}
/
/
/
Convert
a
SmallVec
to
a
Vec
without
reallocating
if
the
SmallVec
has
already
spilled
onto
/
/
/
the
heap
.
pub
fn
into_... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/smallvec/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ine
variant
is
used
and
capacity
holds
the
current
length
of
the
vector
(
number
of
elements
actually
in
use
)
.
/
/
If
capacity
>
Self
:
:
inline_capacity
(
)
then
the
heap
variant
is
used
and
capacity
holds
the
size
of
the
memory
allocation
.
capacity
:
usize
data
:
SmallVecData
<
A
>
}
impl
<
A
:
Array... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/smallvec/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a: Value = Value { data: 4.5, unit: Unit {
ampere: 1,
..Default::default()
}};
let b: Value = Value { data: 2.0, unit: Unit {
candela: 1,
..Default::default()
}};
let c: Value = Value { data: 1.2, unit: Unit {
candela: 1,
ampere: 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "larsborn/siru",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: larsborn/siru path: /src/main.rs
#[macro_use]
extern crate nom;
extern crate lib;
use nom::digit;
use std::str::FromStr;
use lib::Value;
use lib::Unit;
fn from_digit(input: &str) -> Result<f64, std::num::ParseFloatError> {
FromStr::from_str(input)
}
fn from_unit(input: &str) -> Result<Unit... | code_fim | hard | {
"lang": "rust",
"repo": "larsborn/siru",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecafkoob/linkerd2-proxy path: /linkerd/cache/src/lib.rs
#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
use linkerd_stack::{layer, NewService};
use parking_lot::RwLock;
use std::{
collections::{hash_map::Entry, HashMap},
hash::Hash,
sync::{Arc, Weak},
task::{Context... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/linkerd2-proxy",
"path": "/linkerd/cache/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Wait for either the reset to be notified or the idle timeout to
// elapse.
loop {
tokio::select! {
biased;
// If the reset was notified, restart the timer.
_ = reset.notified() => {
trace!("Reset");... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/linkerd2-proxy",
"path": "/linkerd/cache/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_service(&mut self, target: T) -> Cached<N::Service> {
// We expect the item to be available in most cases, so initially obtain
// only a read lock.
if let Some((svc, weak)) = self.services.read().get(&target) {
if let Some(handle) = weak.upgrade() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/linkerd2-proxy",
"path": "/linkerd/cache/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Some(HitResult {
point,
normal,
front_face,
t: root,
material: None,
});
}
}<|fim_prefix|>// repo: TateKennington/rust-tracer path: /src/geometry/sphere.rs
use super::hittable::{HitResult, Hittable};
use super::ray::Ra... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/rust-tracer",
"path": "/src/geometry/sphere.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TateKennington/rust-tracer path: /src/geometry/sphere.rs
use super::hittable::{HitResult, Hittable};
use super::ray::Ray;
use super::vector3::Vector3;
pub struct Sphere {
pub origin: Vector3,
pub radius: f64,
}
impl Sphere {
pub fn new(origin: Vector3, radius: f64) -> Sphere {
... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/rust-tracer",
"path": "/src/geometry/sphere.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sphere_to_ray = ray.origin - self.origin;
let half_b = Vector3::dot(&ray.direction, &sphere_to_ray);
let direction_sq = ray.direction.len_sq();
let determinant =
half_b * half_b - direction_sq * (sphere_to_ray.len_sq() - self.radius * self.radius);
... | code_fim | medium | {
"lang": "rust",
"repo": "TateKennington/rust-tracer",
"path": "/src/geometry/sphere.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use charactor::*;
use piston_window::*;
use std::f64;
impl Bullet {
pub fn new(pos: [f64; 2], angle: f64) -> Box<Bullet> {
box Bullet {
position: pos,
angle: angle,
}
}
}
impl Charactor for Bullet {
fn update(&mut self) {
self.position[0] += 2... | code_fim | medium | {
"lang": "rust",
"repo": "akitsu-sanae/sakana",
"path": "/src/bullet.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> rectangle([1.0, 0.2, 0.2, 0.7],
[self.position[0] - 4.0, self.position[1] - 8.0,
8.0, 16.0],
c.transform, g);
}
fn position(&self) -> [f64; 2] { self.position }
fn on_collided(&mut self, _other: &Box<Charactor>) { }
fn is_coll... | code_fim | hard | {
"lang": "rust",
"repo": "akitsu-sanae/sakana",
"path": "/src/bullet.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akitsu-sanae/sakana path: /src/bullet.rs
/*============================================================================
Copyright (C) 2016 akitsu sanae
https://github.com/akitsu-sanae/sakana
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE or copy... | code_fim | hard | {
"lang": "rust",
"repo": "akitsu-sanae/sakana",
"path": "/src/bullet.rs",
"mode": "psm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ((secs as Time) * 1000) + (millis as Time)
} else {
0
}
}
}<|fim_prefix|>// repo: tzizi/opensrme path: /src/common/src/time.rs
use super::types::Time;
static mut INSTANT: Option<std::time::Instant> = None;
pub fn instant_init() {
unsafe {
INSTANT = Some(std::time::Instant::n... | code_fim | hard | {
"lang": "rust",
"repo": "tzizi/opensrme",
"path": "/src/common/src/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tzizi/opensrme path: /src/common/src/time.rs
use super::types::Time;
static mut INSTANT: Option<std::time::Instant> = None;
<|fim_suffix|>pub fn instant_get_millis() -> Time {
unsafe {
if let Some(instant_uw) = INSTANT {
let diff = instant_uw.elapsed();
let secs = diff.as_sec... | code_fim | medium | {
"lang": "rust",
"repo": "tzizi/opensrme",
"path": "/src/common/src/time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lavers/g815-driver path: /src/device/rgb.rs
use serde::{Serialize, Deserialize};
use crate::device::scancode::Scancode;
use crate::config::Keygroups;
pub use crate::device::color::Color;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum Effect
{
Off,
Static,
Cycl... | code_fim | hard | {
"lang": "rust",
"repo": "lavers/g815-driver",
"path": "/src/device/rgb.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct ColorAssignment
{
color: Color,
keys: Vec<KeySelection>
}
impl ColorAssignment
{
pub fn scancodes(&self, keygroups: &Keygroups) -> Vec<Scancode>
{
self.keys
.iter()
.map(|selection| selection.scancodes(keygroups))
.f... | code_fim | hard | {
"lang": "rust",
"repo": "lavers/g815-driver",
"path": "/src/device/rgb.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ColorAssignment
{
pub fn scancodes(&self, keygroups: &Keygroups) -> Vec<Scancode>
{
self.keys
.iter()
.map(|selection| selection.scancodes(keygroups))
.flatten()
.collect()
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Theme
{
Static... | code_fim | hard | {
"lang": "rust",
"repo": "lavers/g815-driver",
"path": "/src/device/rgb.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn exec(&self, writer: &mut Writer, args: String) -> Result<()> {
let bin_dir = format!("{}/bin", self.conf.datafuse_dir.clone());
let paths = fs::read_dir(bin_dir)?;
let mut exists = false;
for path in paths {
let path = path.unwrap().path();
... | code_fim | medium | {
"lang": "rust",
"repo": "andyli029/datafuse",
"path": "/cli/src/cmds/packages/switch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyli029/datafuse path: /cli/src/cmds/packages/switch.rs
// Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apa... | code_fim | hard | {
"lang": "rust",
"repo": "andyli029/datafuse",
"path": "/cli/src/cmds/packages/switch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg = WeightConfig { share_mode: DimCheckMode::Strict, ..WeightConfig::default() };
let blob_one = Blob::<f32>::of_shape(Some(backend().device()), &[2, 3, 3]);
let blob_two = Blob::<f32>::of_shape(Some(backend().device()), &[3, 2, 3]);
let param_name = "foo".to_owned();... | code_fim | hard | {
"lang": "rust",
"repo": "dirvine/leaf",
"path": "/tests/layer_specs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dirvine/leaf path: /tests/layer_specs.rs
extern crate leaf;
extern crate phloem;
extern crate collenchyma as co;
#[cfg(test)]
mod layer_spec {
use leaf::layer::*;
use phloem::Blob;
use std::rc::Rc;
use co::backend::{Backend, BackendConfig};
use co::frameworks::Native;
u... | code_fim | hard | {
"lang": "rust",
"repo": "dirvine/leaf",
"path": "/tests/layer_specs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg = WeightConfig { share_mode: DimCheckMode::Permissive, ..WeightConfig::default() };
let blob_one = Blob::<f32>::of_shape(Some(backend().device()), &[2, 3, 3]);
let blob_two = Blob::<f32>::of_shape(Some(backend().device()), &[3, 2, 3]);
let blob_three = Blob::<f32>::... | code_fim | hard | {
"lang": "rust",
"repo": "dirvine/leaf",
"path": "/tests/layer_specs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmiyaguchi/rust-xcb path: /src/ffi/shape.rs
i16,
pub y_offset : i16
}
pub struct mask_request {
pub major_opcode : u8,
pub minor_opcode : u8,
pub length : u16,
pub operation : op,
pub destination_kind : ... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/shape.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmiyaguchi/rust-xcb path: /src/ffi/shape.rs
[u8;..11]
}
pub struct query_version_cookie {
sequence : c_uint
}
pub struct query_version_request {
pub major_opcode : u8,
pub minor_opcode : u8,
pub length : u16
}
pub struct query_version_reply {
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/shape.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/**
*
* @param c The connection
* @return A cookie
*
* Delivers a request to the X server.
*
*/
pub fn xcb_shape_query_extents (c : *mut ffi::base::connection,
destination_window : ffi::xproto::window) -> query_extents_cookie;
/**
*
* @param c The connection
... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/shape.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BalzGuenat/rustcache path: /src/msg/test.rs
#[cfg(test)]
use std::str;
fn int_to_bytes(val: usize) -> [u8; 2] {
[(val / 256) as u8, val as u8]
}
fn get(key: &str) -> Vec<u8> {
let key_bytes = key.as_bytes();
let mut vec = int_to_bytes(key_bytes.len()).to_vec();
vec.push(0x00);... | code_fim | hard | {
"lang": "rust",
"repo": "BalzGuenat/rustcache",
"path": "/src/msg/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_view_range() {
let s0 = "abc".as_bytes();
let s1 = "xyz".as_bytes();
let v = super::ContiguousView::new(vec![s0, s1]);
println!("{:X?}", v);
assert_eq!("abc".as_bytes(), &v[0..3]);
assert_eq!("xyz".as_bytes(), &v[3..6]);
assert_eq!("ab".as_bytes(), &v[0..2]);
... | code_fim | hard | {
"lang": "rust",
"repo": "BalzGuenat/rustcache",
"path": "/src/msg/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn sym_fun<T: BfTapeOps>(character: char, ops: &mut T) {
match character {
'+' => ops.incr_data(),
'-' => ops.decr_data(),
'>' => ops.incr_ptr(),
'<' => ops.decr_ptr(),
',' => ops.input(),
'.' => ops.output(),
/*
'[' => ops.,
']' ... | code_fim | hard | {
"lang": "rust",
"repo": "taubo/rustfuck",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn sym_fun<T: BfTapeOps>(character: char, ops: &mut T) {
match character {
'+' => ops.incr_data(),
'-' => ops.decr_data(),
'>' => ops.incr_ptr(),
'<' => ops.decr_ptr(),
',' => ops.input(),
'.' => ops.output(),
/*
'[' => ops.,
'... | code_fim | hard | {
"lang": "rust",
"repo": "taubo/rustfuck",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taubo/rustfuck path: /src/main.rs
use std::fs;
use std::env;
use std::io::*;
#[derive(Debug)]
pub enum BfSym {
IncrData,
DecrData,
IncrPtr,
DecrPtr,
LoopStart,
LoopEnd,
Input,
Output,
Comment,
}
fn match_sym(character: char) -> BfSym {
match character {
... | code_fim | hard | {
"lang": "rust",
"repo": "taubo/rustfuck",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn always_increasing(digits: &[u8]) -> bool {
digits.windows(2).all(|sl| sl[0] <= sl[1])
}
fn has_exactly_two_consecutive(digits: &[u8]) -> bool {
digits.iter().map(|d| {
digits.iter().filter(|c| *c == d).count()
}).any(|n| n == 2)
}<|fim_prefix|>// repo: alexd6631/aoc2019 path: /src... | code_fim | hard | {
"lang": "rust",
"repo": "alexd6631/aoc2019",
"path": "/src/bin/day4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexd6631/aoc2019 path: /src/bin/day4.rs
use std::ops::Range;
fn main() {
let input = 240920..789857;
let res = solve_part1(input.clone());
println!("{:?}", res);
<|fim_suffix|>fn has_exactly_two_consecutive(digits: &[u8]) -> bool {
digits.iter().map(|d| {
digits.iter()... | code_fim | hard | {
"lang": "rust",
"repo": "alexd6631/aoc2019",
"path": "/src/bin/day4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> digits.windows(2).all(|sl| sl[0] <= sl[1])
}
fn has_exactly_two_consecutive(digits: &[u8]) -> bool {
digits.iter().map(|d| {
digits.iter().filter(|c| *c == d).count()
}).any(|n| n == 2)
}<|fim_prefix|>// repo: alexd6631/aoc2019 path: /src/bin/day4.rs
use std::ops::Range;
fn main() {... | code_fim | hard | {
"lang": "rust",
"repo": "alexd6631/aoc2019",
"path": "/src/bin/day4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vmanucharyan/nprs path: /src/extract/extractor.rs
use image::Image;
use extract::structures::NumberPlate;
<|fim_suffix|> return vec![];
}
}
pub struct PlateExtractor;<|fim_middle|>pub trait ExtractPlate {
fn extract<T>(_: &Image<u8>) -> Vec<NumberPlate> {
| code_fim | medium | {
"lang": "rust",
"repo": "vmanucharyan/nprs",
"path": "/src/extract/extractor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return vec![];
}
}
pub struct PlateExtractor;<|fim_prefix|>// repo: vmanucharyan/nprs path: /src/extract/extractor.rs
use image::Image;
use extract::structures::NumberPlate;
<|fim_middle|>pub trait ExtractPlate {
fn extract<T>(_: &Image<u8>) -> Vec<NumberPlate> {
| code_fim | medium | {
"lang": "rust",
"repo": "vmanucharyan/nprs",
"path": "/src/extract/extractor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reinterpretcat/vrp path: /rosomaxa/src/hyper/dynamic_selective.rs
ollection of heuristic search operators with their name and initial weight.
pub type HeuristicSearchOperators<C, O, S> =
Vec<(Arc<dyn HeuristicSearchOperator<Context = C, Objective = O, Solution = S> + Send + Sync>, String, f6... | code_fim | hard | {
"lang": "rust",
"repo": "reinterpretcat/vrp",
"path": "/rosomaxa/src/hyper/dynamic_selective.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reinterpretcat/vrp path: /rosomaxa/src/hyper/dynamic_selective.rs
Feedback, SlotMachine};
use crate::utils::{compare_floats, random_argmax, DefaultDistributionSampler};
use crate::Timer;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt::Formatter;
use std::hash::Hash;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "reinterpretcat/vrp",
"path": "/rosomaxa/src/hyper/dynamic_selective.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let median_ratio = match median_ratio.clamp(0.5, 2.) {
ratio if ratio < 0.75 => 1.5, // Allegro
ratio if ratio < 1. => 1.25, // Allegretto
ratio if ratio > 1.5 => 0.75, // Andante
_ => 1., // Moderato
};
let improvement_ratio = match (impr... | code_fim | hard | {
"lang": "rust",
"repo": "reinterpretcat/vrp",
"path": "/rosomaxa/src/hyper/dynamic_selective.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openathena/server path: /src/api/route.rs
use rocket_contrib::Json;
use rocket::State;
use std::sync::{Arc, Mutex};
use game::Game;
use super::error_handlers::ApiError;
use actions::ActionMap;
use serde_json::Value as JsonValue;
<|fim_suffix|>#[post("/", data = "<rpc_request>")]
pub fn rpc_requ... | code_fim | medium | {
"lang": "rust",
"repo": "openathena/server",
"path": "/src/api/route.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
pub struct RequestEnvelope {
#[serde(rename = "type")]
pub request_type: String,
pub data: Option<JsonValue>
}
#[post("/", data = "<rpc_request>")]
pub fn rpc_request(rpc_request: Json<RequestEnvelope>, game: State<GameMutex>, action_map: State<ActionMap>)
-> ... | code_fim | medium | {
"lang": "rust",
"repo": "openathena/server",
"path": "/src/api/route.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>esult.append(&mut factors(n / x));
}
result
}<|fim_prefix|>// repo: mattjperez/exercism path: /rust/prime-factors/src/lib.rs
pub fn factors(n: u64) -> Vec<u64> {
let mut res<|fim_middle|>ult = Vec::new();
if let Some(x) = (2..=n).find(|x| n % x == 0) {
result.push(x);
r | code_fim | medium | {
"lang": "rust",
"repo": "mattjperez/exercism",
"path": "/rust/prime-factors/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattjperez/exercism path: /rust/prime-factors/src/lib.rs
pub fn factors(n: u64) -> Vec<u64> {
let mut res<|fim_suffix|>(|x| n % x == 0) {
result.push(x);
result.append(&mut factors(n / x));
}
result
}<|fim_middle|>ult = Vec::new();
if let Some(x) = (2..=n).find | code_fim | easy | {
"lang": "rust",
"repo": "mattjperez/exercism",
"path": "/rust/prime-factors/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /onnx/src/ops/random.rs
use crate::model::ParsingContext;
use crate::ops::OnnxOpRegister;
use crate::pb::*;
use tract_hir::internal::*;
use tract_onnx_opl::random::Dist;
pub fn register_all_ops(reg: &mut OnnxOpRegister) {
reg.insert("RandomUniform", random);
reg.insert... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/onnx/src/ops/random.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
prefix: &str,
model: &mut TypedModel,
_inputs: &[OutletId],
) -> TractResult<TVec<OutletId>> {
model.wire_node(
prefix,
tract_onnx_opl::random::Random {
dist: self.dist.clone(),
fact: self.dt.fact(&s... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/onnx/src/ops/random.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diogox/Raven-Launcher path: /src/server/deferred_result_renderer.rs
use std::sync::{
Arc,
Mutex,
mpsc,
};
use relm_core::Sender;
use timer::{
Timer,
Guard,
};
use ::ui::windows::launcher::msg::Msg as LauncherMsg;
use ::api::response::Response;
use ::api::events::base_event::... | code_fim | hard | {
"lang": "rust",
"repo": "diogox/Raven-Launcher",
"path": "/src/server/deferred_result_renderer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn on_query_change(&mut self) {
self.cancel_loading();
self.active_event = None;
self.active_extension = None;
}
}
impl DeferredResultRenderer {
fn cancel_loading(&mut self) {
if self.loading.is_some() {
self.loading = None;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "diogox/Raven-Launcher",
"path": "/src/server/deferred_result_renderer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kennytm/libimobiledevice-rust path: /libimobiledevice-sys/src/lib.rs
#![allow(non_camel_case_types)]
<|fim_suffix|> unsafe {
// Just to check if libimobiledevice is linked.
idevice_set_debug_level(0);
}
}<|fim_middle|>extern crate libplist_sys;
pub mod idevice;
pub mod l... | code_fim | medium | {
"lang": "rust",
"repo": "kennytm/libimobiledevice-rust",
"path": "/libimobiledevice-sys/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_validity() {
unsafe {
// Just to check if libimobiledevice is linked.
idevice_set_debug_level(0);
}
}<|fim_prefix|>// repo: kennytm/libimobiledevice-rust path: /libimobiledevice-sys/src/lib.rs
#![allow(non_camel_case_types)]
extern crate libplist_sys;
<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "kennytm/libimobiledevice-rust",
"path": "/libimobiledevice-sys/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.