text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: ulysseB/telamon path: /src/codegen/name_map.rs
/ alias so we know the alias is already in `vars_names`.
variables[&alias.other_variable()].create_alias(alias.dim_mapping())
}
};
variables.insert(var.id(), names);
}
let ... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/src/codegen/name_map.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the name of the address of a memory block.
pub fn name_addr(&self, id: ir::MemId) -> Register<'a> {
self.mem_blocks[&id]
}
/// Assigns a name to an induction variable.
// TODO(cleanup): split into name induction var and name induction level
pub fn name_inductio... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/src/codegen/name_map.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Names an instruction, vectorized on the given dimensions.
pub fn vector_inst(
&self,
vector_levels: &[Vec<Dimension>; 2],
inst: ir::InstId,
) -> llir::RegVec<'a> {
self.vectorize(vector_levels, |indices| {
self.indexed_inst_name(inst, indices)
... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/src/codegen/name_map.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut args = env::args_os();
args.next();
let mut global_variables = HashMap::new();
for filename in args {
let mut file = match File::open(filename) {
Ok(file) => file,
Err(e) => {
println!("Error {}", e);
continue;
... | code_fim | medium | {
"lang": "rust",
"repo": "GreenPix/aariba",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GreenPix/aariba path: /examples/demo.rs
extern crate aariba;
use std::env;
use std::fs::File;
use std::io::Read;
use std::collections::HashMap;
<|fim_suffix|> let mut args = env::args_os();
args.next();
let mut global_variables = HashMap::new();
for filename in args {
le... | code_fim | medium | {
"lang": "rust",
"repo": "GreenPix/aariba",
"path": "/examples/demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Change to use median
let darks_stack = mean::process_mean(darks).unwrap();
let flats_stack = mean::process_mean(flats).unwrap();
let mut stack = imagebuffer::ImageBuffer::new(1, 1).unwrap();
let mut cnt = 0;
for in_file in lights.iter() {
if path::file_exists(in_f... | code_fim | hard | {
"lang": "rust",
"repo": "kmgill/cr2_to_tiff_halpha",
"path": "/bin/proc_ha.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kmgill/cr2_to_tiff_halpha path: /bin/proc_ha.rs
use cr2_to_tiff_halpha::{constants, print, vprintln, path, imagebuffer, raw_to_tiff, mean};
#[macro_use]
extern crate clap;
use clap::{Arg, App};
fn main() {
let matches = App::new(crate_name!())
.version(crate_v... | code_fim | hard | {
"lang": "rust",
"repo": "kmgill/cr2_to_tiff_halpha",
"path": "/bin/proc_ha.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut new_tiles = HashMap::new();
for (coordinate, neighbor_count) in neighbors {
let will_be_black = match self.tiles.get(&coordinate).unwrap_or(&Tile::White) {
Tile::White => {
neighbor_count == 2
},
Tile::... | code_fim | hard | {
"lang": "rust",
"repo": "sbaldwin621/adventofcode2020",
"path": "/day24/tiles2/src/lobby.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbaldwin621/adventofcode2020 path: /day24/tiles2/src/lobby.rs
use std::collections::HashMap;
use crate::instructions::{Direction, InstructionSet};
#[derive(Debug)]
pub enum Tile {
White,
Black
}
impl Tile {
pub fn flip(&self) -> Tile {
match self {
Tile::White ... | code_fim | hard | {
"lang": "rust",
"repo": "sbaldwin621/adventofcode2020",
"path": "/day24/tiles2/src/lobby.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kurnos/adventofcode2020 path: /src/day10.rs
use crate::infra::Problem;
use itertools::Itertools;
pub struct Day10;
impl Problem<String, String, u16, usize, 10> for Day10 {
fn first(contents: String) -> u16 {
<|fim_suffix|> for d in data {
counts2.push((
d... | code_fim | hard | {
"lang": "rust",
"repo": "kurnos/adventofcode2020",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut data = parse(&contents);
data.sort_unstable();
let target = data[data.len() - 1] + 3;
data.push(target);
let mut counts2 = vec![(0, 1)];
for d in data {
counts2.push((
d,
counts2
.iter... | code_fim | hard | {
"lang": "rust",
"repo": "kurnos/adventofcode2020",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn open(
&self,
_ctx: Context,
inode: Self::Inode,
flags: u32,
) -> io::Result<(Option<Self::Handle>, fuse::sys::OpenOptions)> {
// Since file handle is not really used in later operations (which use Inode directly),
// return None as the handle.
... | code_fim | hard | {
"lang": "rust",
"repo": "ZYHGOD-1/Aosp11",
"path": "/packages/modules/Virtualization/authfs/src/fusefs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZYHGOD-1/Aosp11 path: /packages/modules/Virtualization/authfs/src/fusefs.rs
/*
* Copyright (C) 2021 The Android Open Source Project
*
* 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 ... | code_fim | hard | {
"lang": "rust",
"repo": "ZYHGOD-1/Aosp11",
"path": "/packages/modules/Virtualization/authfs/src/fusefs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(() == ());
let u = ret_unit();
assert!(u == ());
let s = S { f: () };
assert!(s.f == ());
let u = U { f: () };
unsafe {
assert!(u.f == ());
}
// TODO: determine whether we can say anything sensible about u.g
// i.e., assert!(u.g == ???)
// TODO:... | code_fim | medium | {
"lang": "rust",
"repo": "bdalrhm/rmc",
"path": "/src/test/cbmc/Unit/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bdalrhm/rmc path: /src/test/cbmc/Unit/main.rs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
/// Test using the unit type
/// - As a void function return
/// - As a variable type in a struct or union
struct S {
f: (),
... | code_fim | hard | {
"lang": "rust",
"repo": "bdalrhm/rmc",
"path": "/src/test/cbmc/Unit/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize)]
struct Comic {
title: String,
num: usize,
date: String,
desc: String,
img_url: String,
}
impl From<ComicResponse> for Comic {
fn from(cr: ComicResponse) -> Self {
Comic {
title: cr.title,
num: cr.num,
date: format!("... | code_fim | hard | {
"lang": "rust",
"repo": "ambantis/grab-xkcd",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ambantis/grab-xkcd path: /src/main.rs
use anyhow::Result;
use clap::Clap;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::fmt;
use std::time::Duration;
use url::Url;
/// A utility to grab XKCD comics
#[derive(Clap)]
pub struct Args {
/// Set a connection timeout
... | code_fim | hard | {
"lang": "rust",
"repo": "ambantis/grab-xkcd",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: servo/rust-http-client path: /connection.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT... | code_fim | hard | {
"lang": "rust",
"repo": "servo/rust-http-client",
"path": "/connection.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_stop_(&self, read_port: @ReadPort) -> Result<(), TcpErrData> {
(self.read_stop_fn)(read_port)
}
}
pub struct MockConnectionFactory {
connect_fn: @fn(IpAddr, uint) -> Result<MockConnection, TcpConnectErrData>
}
impl ConnectionFactory<MockConnection> for MockConnectionFactory {... | code_fim | hard | {
"lang": "rust",
"repo": "servo/rust-http-client",
"path": "/connection.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_STM32F412").is_some() {
"src/stm32f412/device.x"
} else if env::var_os("CARGO_FEATURE_STM32F413").is_some() {
"src/stm32f413/device.x"
} else if env::var_os("CARGO_FEATURE_STM32F427").is_some() {
"src/stm32f427/device.x"
} else if env::var_os("C... | code_fim | hard | {
"lang": "rust",
"repo": "Disasm/stm32-rs",
"path": "/stm32f4/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Disasm/stm32-rs path: /stm32f4/build.rs
use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
if env::var_os("CARGO_FEATURE_RT").is_some() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("cargo:rustc-link-search={}", out.display());
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Disasm/stm32-rs",
"path": "/stm32f4/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
assert_eq!(
Solution::num_islands(vec![
vec!['1', '1', '1', '1', '0'],
vec!['1', '1', '0', '1', '0'],
vec!['1', '1', '0', '0', '0'],
vec!['0', '0', '0', '0', '0']
]),
... | code_fim | hard | {
"lang": "rust",
"repo": "icub3d/puzzles",
"path": "/leetcode/number-of-islands/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icub3d/puzzles path: /leetcode/number-of-islands/src/lib.rs
pub struct Solution;
use std::collections::HashSet;
impl Solution {
pub fn num_islands(grid: Vec<Vec<char>>) -> i32 {
let mut visited: HashSet<(usize, usize)> = HashSet::new();
let mut islands = 0;
let heigh... | code_fim | hard | {
"lang": "rust",
"repo": "icub3d/puzzles",
"path": "/leetcode/number-of-islands/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iqlusioninc/yubihsm.rs path: /src/session/guard.rs
//! MutexGuard wrapper protecting an optional session which is always true
use super::Session;
use std::ops::{Deref, DerefMut};
use std::sync::MutexGuard;
/// Mutex-guarded wrapper type containing a locked session
pub struct Guard<'mutex>(Mute... | code_fim | hard | {
"lang": "rust",
"repo": "iqlusioninc/yubihsm.rs",
"path": "/src/session/guard.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'mutex> Deref for Guard<'mutex> {
type Target = Session;
fn deref(&self) -> &Session {
self.0.deref().as_ref().unwrap()
}
}
impl<'mutex> DerefMut for Guard<'mutex> {
fn deref_mut(&mut self) -> &mut Session {
self.0.deref_mut().as_mut().unwrap()
}
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "iqlusioninc/yubihsm.rs",
"path": "/src/session/guard.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn handler() -> response::Json<Hello> {
response::Json(Hello {
hello: "world".to_string(),
})
}
#[derive(Serialize)]
struct Hello {
hello: String,
}<|fim_prefix|>// repo: vovacodes/try-axum path: /src/main.rs
//! Run with
//! ```not_rust
//! RUST_LOG=info cargo run
//! ```
use ... | code_fim | hard | {
"lang": "rust",
"repo": "vovacodes/try-axum",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let middleware_stack = ServiceBuilder::new()
.timeout(Duration::from_secs(15))
.layer(TraceLayer::new_for_http())
.layer(CompressionLayer::new())
.into_inner();
let app = route("/", get(handler)).layer(middleware_stack);
let addr = std::net::SocketAddr::from((... | code_fim | medium | {
"lang": "rust",
"repo": "vovacodes/try-axum",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vovacodes/try-axum path: /src/main.rs
//! Run with
//! ```not_rust
//! RUST_LOG=info cargo run
//! ```
use axum::prelude::*;
use serde::Serialize;
use std::time::Duration;
use tower::ServiceBuilder;
use tower_http::compression::CompressionLayer;
use tower_http::trace::TraceLayer;
#[tokio::main]... | code_fim | hard | {
"lang": "rust",
"repo": "vovacodes/try-axum",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
security_id: &security_id_lib::SecurityId,
date: chrono::NaiveDate,
) -> HistoricalPrice;
}<|fim_prefix|>// repo: dayfine/xlab path: /xlab/data/market_data/src/price_provider.rs
pub struct HistoricalPrice {
open: f64,
close: f64,
high: f64,
low: f64,
}
... | code_fim | easy | {
"lang": "rust",
"repo": "dayfine/xlab",
"path": "/xlab/data/market_data/src/price_provider.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dayfine/xlab path: /xlab/data/market_data/src/price_provider.rs
pub struct HistoricalPrice {
open: f64,
close: f64,
high: f64,
low: f64,
}
<|fim_suffix|> &self,
security_id: &security_id_lib::SecurityId,
date: chrono::NaiveDate,
) -> HistoricalPrice;
}... | code_fim | easy | {
"lang": "rust",
"repo": "dayfine/xlab",
"path": "/xlab/data/market_data/src/price_provider.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // safe approach for the same thing:
// use scoping for closure to release the borrow
{
let mut m_inc = || m += 1;
m_inc();
}
assert_eq!(m, 2);
{
let mut m_inc = || m += 1;
m_inc();
}
asser... | code_fim | hard | {
"lang": "rust",
"repo": "geomatsi/rust-tests",
"path": "/scratch-board/src/bin/test-closures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn move_add(a: i32) -> impl Fn(i32) -> i32 {
move |x| a + x
}
#[test]
fn f_test_closure_t6() {
let v = 2;
let f = move_add(v);
assert_eq!(f(1), 3);
}
#[test]
fn f_test_closure_t7() {
let mut v = vec![1; 4];
assert_eq!(v.iter().... | code_fim | hard | {
"lang": "rust",
"repo": "geomatsi/rust-tests",
"path": "/scratch-board/src/bin/test-closures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geomatsi/rust-tests path: /scratch-board/src/bin/test-closures.rs
extern crate rand;
use rand::Rng;
use std::io;
use std::thread;
use std::time::Duration;
struct Cacher<T>
where
T: Fn(u32) -> u32,
{
calculation: T,
value: Option<u32>,
}
impl<T> Cacher<T>
where
T: Fn(u32) -> u3... | code_fim | hard | {
"lang": "rust",
"repo": "geomatsi/rust-tests",
"path": "/scratch-board/src/bin/test-closures.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rheydskey/neoirc path: /src/main.rs
mod server;
use crate::func::user::user::{list_user, login_user, logout_user};
use crate::server::db::create::create_database;
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use func::user::user::{create_user, delete_user};
<|fim_suffix|>#[ac... | code_fim | hard | {
"lang": "rust",
"repo": "Rheydskey/neoirc",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_web::main]
async fn main() -> std::io::Result<()> {
create_database().await;
println!("Running......");
HttpServer::new(|| {
App::new()
.service(
web::scope("/user")
.route("/create", web::post().to(create_user))
... | code_fim | hard | {
"lang": "rust",
"repo": "Rheydskey/neoirc",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willmcpherson2/notcord path: /src/test.rs
t_hash01\"
}",
)
.dispatch();
client
.post("/login")
.header(ContentType::JSON)
.body(
"{
\"username\":\"test_user01\",
\"password\":\"test_hash01\"
}"... | code_fim | hard | {
"lang": "rust",
"repo": "willmcpherson2/notcord",
"path": "/src/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut response = message.dispatch();
assert_eq!(
response.body_string(),
Some(serde_json::to_string(&Err::UserNotInGroup).unwrap())
);
}
#[test]
fn get_groups_for_user_success() {
let (client, _) = setup!();
client
.post("/signup")
.header(ContentTy... | code_fim | hard | {
"lang": "rust",
"repo": "willmcpherson2/notcord",
"path": "/src/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn is_group_admin_user_doesnt_exist() {
let (client, _) = setup!();
client
.post("/signup")
.header(ContentType::JSON)
.body(
"{
\"username\":\"test_user01\",
\"password\":\"test_hash01\"
}",
)
.dis... | code_fim | hard | {
"lang": "rust",
"repo": "willmcpherson2/notcord",
"path": "/src/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cole-h/passrs path: /src/subcmds/init.rs
use std::fs;
use std::io::{self, Write};
use std::os::unix::fs::OpenOptionsExt;
use std::path::{Path, PathBuf};
use std::str;
use git2::{Commit, Oid, Repository, Signature};
use gpgme::{Context, Protocol};
use crate::consts::{
PASSWORD_STORE_DIR, PA... | code_fim | hard | {
"lang": "rust",
"repo": "cole-h/passrs",
"path": "/src/subcmds/init.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if fs::metadata(&path).is_err() {
fs::create_dir_all(&path)?;
util::set_permissions_recursive(&path)?;
}
if let Ok(repo) = Repository::open(&store) {
let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let gpg_id_path = path.join(".gpg-id");
let ... | code_fim | hard | {
"lang": "rust",
"repo": "cole-h/passrs",
"path": "/src/subcmds/init.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group.bench_function("vec-1-byte", |b| {
b.iter(|| {
let _v = black_box(Vec::<u8>::with_capacity(black_box(1)));
// NB: Vec is deallocated here
})
});
group.bench_function("vec-1000-byte", |b| {
b.iter(|| {
let _v = black_box(Vec::<... | code_fim | medium | {
"lang": "rust",
"repo": "mgeier/rust-realtime-nursery",
"path": "/benches/std_allocation.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgeier/rust-realtime-nursery path: /benches/std_allocation.rs
use criterion::{black_box, criterion_group, criterion_main};
pub fn criterion_benchmark(criterion: &mut criterion::Criterion) {
let mut group = criterion.benchmark_group("std-allocation");
//group.sampling_mode(criterion::Sa... | code_fim | hard | {
"lang": "rust",
"repo": "mgeier/rust-realtime-nursery",
"path": "/benches/std_allocation.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> auto data = trans_lval(bcx, lhs);
assert (data.is_mem);
bcx = data.res.bcx;
auto unit_ty = node_ann_type(bcx.fcx.lcx.ccx, ann);
// FIXME: calculate copy init-ness in typestate.
ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING);
}
fn recv_val(&@block_ctxt cx, ValueRef ... | code_fim | hard | {
"lang": "rust",
"repo": "bendotc/rust",
"path": "/src/comp/middle/trans.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bendotc/rust path: /src/comp/middle/trans.rs
ValueRef llop) -> result {
// We can't use call_tydesc_glue_full() and friends here because compare
// glue has a special signature.
auto lllhs = spill_if_immediate(cx, lhs, t);
auto llrhs = spill_if_immediate(cx, rhs, t... | code_fim | hard | {
"lang": "rust",
"repo": "bendotc/rust",
"path": "/src/comp/middle/trans.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bendotc/rust path: /src/comp/middle/trans.rs
.Trunc(ix.val, T_int());
} else {
ix_val = ix.val;
}
auto unit_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_sz = size_of(bcx, unit_ty);
bcx = unit_sz.bcx;
maybe_name_value(cx.fcx.lcx.ccx, unit_sz.val, "unit_sz");... | code_fim | hard | {
"lang": "rust",
"repo": "bendotc/rust",
"path": "/src/comp/middle/trans.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/flowbetween path: /render/src/metal_renderer/mod.rs
mod metal_renderer;
mod bindings;
mod convert;
<|fim_suffix|>;
mod pipeline_configuration;
pub use self::metal_renderer::*;
pub use self::render_target::*;<|fim_middle|>mod buffer;
mod matrix_buffer;
mod render_target | code_fim | easy | {
"lang": "rust",
"repo": "isgasho/flowbetween",
"path": "/render/src/metal_renderer/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tal_renderer::*;
pub use self::render_target::*;<|fim_prefix|>// repo: isgasho/flowbetween path: /render/src/metal_renderer/mod.rs
mod metal_renderer;
mod bindings;
mod convert;
<|fim_middle|>mod buffer;
mod matrix_buffer;
mod render_target;
mod pipeline_configuration;
pub use self::me | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/flowbetween",
"path": "/render/src/metal_renderer/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ction configuration register 0"]
pub struct FUNCTION_REG_0 {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Function configuration register 0"]
pub mod function_reg_0;
#[doc = "Function configuration register 1"]
pub struct FUNCTION_REG_1 {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Functi... | code_fim | hard | {
"lang": "rust",
"repo": "laanwj/k210-pac",
"path": "/src/sha256.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laanwj/k210-pac path: /src/sha256.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Calculated SHA256 return value"]
pub result: [RESULT; 8],
#[doc = "0x20 - SHA256 input data is written to this register"]
pub data_in: DATA_IN,
_reserved0: [... | code_fim | hard | {
"lang": "rust",
"repo": "laanwj/k210-pac",
"path": "/src/sha256.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zubchick/rust-base64 path: /src/lib.rs
mod encode;
mod decode;
pub use decode::Result;
const ALPHABET: &'static [u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\
0123456789\
... | code_fim | hard | {
"lang": "rust",
"repo": "zubchick/rust-base64",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn encode(data: &[u8], out: &mut [u8]) -> usize {
encode::encode(ALPHABET, data, out)
}
pub fn decode(data: &[u8], out: &mut [u8]) -> Result<usize> {
let table: [u8; 256] = make_decode_table(ALPHABET);
decode::decode(&table, data, out)
}<|fim_prefix|>// repo: zubchick/rust-base64 path: /... | code_fim | medium | {
"lang": "rust",
"repo": "zubchick/rust-base64",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BalanceResponse {
pub balance: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StateResponse {
pub region: String,
pub ecostate: i64,
pub total_tokens: i64,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "levackt/ecopay",
"path": "/src/msg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StateResponse {
pub region: String,
pub ecostate: i64,
pub total_tokens: i64,
pub released_tokens: i64,
pub payout_start_height: Option<i64>,
pub payout_end_height: Option<i64>,
pub is_locked: Opt... | code_fim | hard | {
"lang": "rust",
"repo": "levackt/ecopay",
"path": "/src/msg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: levackt/ecopay path: /src/msg.rs
use cosmwasm::types::{Coin, CanonicalAddr, HumanAddr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
pub region: String,
pub beneficiary: HumanAd... | code_fim | hard | {
"lang": "rust",
"repo": "levackt/ecopay",
"path": "/src/msg.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ways)]
#[must_use]
pub fn b525(&mut self) -> B525_W<MPCBB1_VCTR16_SPEC, 13> {
B525_W::new(self)
}
#[doc = "Bit 14 - B526"]
#[inline(always)]
#[must_use]
pub fn b526(&mut self) -> B526_W<MPCBB1_VCTR16_SPEC, 14> {
B526_W::new(self)
}
#[doc = "Bit 15 - B527... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb1/mpcbb1_vctr16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[must_use]
pub fn b524(&mut self) -> B524_W<MPCBB1_VCTR16_SPEC, 12> {
B524_W::new(self)
}
#[doc = "Bit 13 - B525"]
#[inline(always)]
#[must_use]
pub fn b525(&mut self) -> B525_W<MPCBB1_VCTR16_SPEC, 13> {
B525_W::new(self)
}
#[doc = "Bit 14 - B526"]
#[inl... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb1/mpcbb1_vctr16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/sec_gtzc_mpcbb1/mpcbb1_vctr16.rs
;
#[doc = "Field `B515` writer - B515"]
pub type B515_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `B516` reader - B516"]
pub type B516_R = crate::BitReader;
#[doc = "Field `B516` ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb1/mpcbb1_vctr16.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if success {
for i in 0..g1.len() {
g2[i] = solver.g2[solver.xy[i] as usize].clone();
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use models::point::Point;
#[test]
fn test_hungarian() {
let mut v1 = vec![
Point{x: 1., y: 2.},
Point{x: 1.5, y: 3.5},
Point{x: 10., y: -2.}
];
l... | code_fim | hard | {
"lang": "rust",
"repo": "lanPN85/area-cov",
"path": "/src/ga/hungarian.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_to_tree(&mut self, x: i32, prevx: i32, weight_fn: &Fn(&T, &T)->f32) {
let _x = x as usize;
self.s[_x] = true;
self.prev[_x] = prevx;
for y in 0..self.n {
let _y = y as usize;
let cost = weight_fn(&self.g1[_x], &self.g2[_y]);
if self.lx[_x] + self.ly[_y] - cost < self.slack[_y] {
... | code_fim | hard | {
"lang": "rust",
"repo": "lanPN85/area-cov",
"path": "/src/ga/hungarian.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lanPN85/area-cov path: /src/ga/hungarian.rs
use std::fmt::Debug;
use std::collections::VecDeque;
use std::{f32, i32};
struct HugarianSolver<T: Clone+Debug> {
pub g1: Vec<T>, pub g2: Vec<T>,
matches: i32, n: i32,
lx: Vec<f32>, ly: Vec<f32>,
pub xy: Vec<i32>, pub yx: Vec<i32>,
q: VecDeque<i3... | code_fim | hard | {
"lang": "rust",
"repo": "lanPN85/area-cov",
"path": "/src/ga/hungarian.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return a * NUM_BITS;
}
}
impl SearchCache2 for BitCache {
#[inline]
fn unmark(&mut self, index: usize) {
let a = index / NUM_BITS;
let b = index % NUM_BITS;
self.0[a] &= !(1 << b);
}
}<|fim_prefix|>// repo: dotanavi/dotamoji path: /src/search_cache/bit_cac... | code_fim | hard | {
"lang": "rust",
"repo": "dotanavi/dotamoji",
"path": "/src/search_cache/bit_cache1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = index / NUM_BITS;
let b = index % NUM_BITS;
self.0[a] |= 1 << b;
}
#[inline]
fn is_filled(&self, index: usize, _check: &[u32]) -> bool {
let data = &self.0;
let a = index / NUM_BITS;
let b = index % NUM_BITS;
a < data.len() && (d... | code_fim | hard | {
"lang": "rust",
"repo": "dotanavi/dotamoji",
"path": "/src/search_cache/bit_cache1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dotanavi/dotamoji path: /src/search_cache/bit_cache1.rs
use std::mem::size_of;
use super::{SearchCache, SearchCache2};
type Bits = usize;
const NUM_BITS: usize = 8 * size_of::<Bits>();
#[inline]
fn round_up(value: usize) -> usize {
(value + NUM_BITS) / NUM_BITS
}
pub struct BitCache(Vec... | code_fim | hard | {
"lang": "rust",
"repo": "dotanavi/dotamoji",
"path": "/src/search_cache/bit_cache1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bxt/adventofcode path: /2022/visualisation_utils/canvas.rs
use std::marker::PhantomData;
pub trait Canvas {
type Position;
fn set(&mut self, position: Self::Position, value: u8);
}
#[derive(Debug)]
pub struct PixelMap {
width: usize,
pixels: Vec<u8>,
}
impl PixelMap {
pub... | code_fim | hard | {
"lang": "rust",
"repo": "bxt/adventofcode",
"path": "/2022/visualisation_utils/canvas.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T, C> MappedCanvas<'a, T, C> {
pub fn new(canvas: &'a mut C) -> MappedCanvas<'a, T, C> {
MappedCanvas {
canvas,
phantom: PhantomData,
}
}
}
impl<'a, T, C, F> Canvas for MappedCanvas<'a, T, C>
where
C: Canvas<Position = (F, F)>,
F: TryFrom<T... | code_fim | hard | {
"lang": "rust",
"repo": "bxt/adventofcode",
"path": "/2022/visualisation_utils/canvas.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stearnsc/rust-stripe-client path: /src/model/owner.rs
use super::address::Address;
use super::date_of_birth::DateOfBirth;
use super::verification::Verification;
use url_encodable::UrlEncodable;
#[derive(Clone, Debug, Deserialize)]
pub struct Owner {
address: Option<Address>,
dob: Option... | code_fim | hard | {
"lang": "rust",
"repo": "stearnsc/rust-stripe-client",
"path": "/src/model/owner.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn verification(mut self, verification_file_token: String) -> Self {
self.0.push(("verification".to_string(), verification_file_token));
self
}
}
impl UrlEncodable for NewOwner {
fn key_value_pairs(&self) -> Vec<(String, String)> {
self.0.key_value_pairs()
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "stearnsc/rust-stripe-client",
"path": "/src/model/owner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_grouped_windows_using_cache(
em: &EntityManager,
db_url: &str,
) -> Result<Vec<GroupedWindow>, IntelError> {
let mut cache_pool = cache::CACHE_POOL.lock().unwrap();
let tables = cache_pool.get_cached_tables(em, db_url)?;
let grouped_window = get_grouped_windows(em, &tables)?... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/diwata",
"path": "/intel/src/window.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut matched = 0;
for ind in indirect.iter() {
if ind.indirect_table.name == *table_name {
matched += 1;
}
}
if matched > 1 {
true
} else {
false
}
}
#[derive(Debug, Serialize)]
pub struct WindowName {
pub name: String,
pub ta... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/diwata",
"path": "/intel/src/window.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzeroo/diwata path: /intel/src/window.rs
use cache;
use error::IntelError;
use rustorm::table::SchemaContent;
use rustorm::ColumnName;
use rustorm::DbError;
use rustorm::EntityManager;
use rustorm::Table;
use rustorm::TableName;
use tab::Tab;
use table_intel;
use table_intel::IndirectTable;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "zzeroo/diwata",
"path": "/intel/src/window.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /vendor/webpki/tests/dns_name_tests.rs
// Copyright 2014-2017 Brian Smith.
// (name, is_valid)
static DNS_NAME_VALIDITY: &[(&[u8], bool)] = &[
(b"a", true),
(b"a.b", true),
(b"a.b.c", true),
(b"a.b.c.d", true),
// Hyphens, one component.... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/webpki/tests/dns_name_tests.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> // multiple consecutive hyphens allowed
(b"a--1", true),
(b"1---a", true),
(b"a-----------------b", true),
// Wildcard specifications are not valid reference names.
(b"*.a", false),
(b"a*", false),
(b"a*.", false),
(b"a*.a", false),
(b"a*.a.", false),
(b"*.a.b"... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/webpki/tests/dns_name_tests.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frankegoesdown/LeetCode-in-Go path: /Algorithms/0023.merge-k-sorted-lists/merge-k-sorted-lists.go
package problem0023
// ListNode 是链接节点
type ListNode struct {
Val int
Next *ListNode
}
func merge(lists []*ListNode) *ListNode {
length := len(lists)
half := length / 2
if length == 1 {
re... | code_fim | medium | {
"lang": "rust",
"repo": "frankegoesdown/LeetCode-in-Go",
"path": "/Algorithms/0023.merge-k-sorted-lists/merge-k-sorted-lists.go",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for l0 != nil && l1 != nil {
if l0.Val < l1.Val {
cur.Next, l0 = l0, l0.Next
} else {
cur.Next, l1 = l1, l1.Next
}
cur = cur.Next
}
if l0 != nil {
cur.Next = l0
}
if l1 != nil {
cur.Next = l1
}
return res
}
return mergeKLists([]*ListNode{mergeKLists(lists[half:... | code_fim | medium | {
"lang": "rust",
"repo": "frankegoesdown/LeetCode-in-Go",
"path": "/Algorithms/0023.merge-k-sorted-lists/merge-k-sorted-lists.go",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return res
}
return mergeKLists([]*ListNode{mergeKLists(lists[half:]), mergeKLists(lists[:half])})
}
func mergeKLists(lists []*ListNode) *ListNode {
if len(lists) == 0 {
return nil
}
return merge(lists)
}<|fim_prefix|>// repo: frankegoesdown/LeetCode-in-Go path: /Algorithms/0023.merge-k-sorte... | code_fim | hard | {
"lang": "rust",
"repo": "frankegoesdown/LeetCode-in-Go",
"path": "/Algorithms/0023.merge-k-sorted-lists/merge-k-sorted-lists.go",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Request parameters for `commands::attest_asymmetric`
#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct AttestAsymmetricCommand {
/// Key that attestation certificate will be generated for
pub key_id: ObjectId,
/// Key to use to sign attestation certificate
pub attestation_key... | code_fim | hard | {
"lang": "rust",
"repo": "harrier-lcc/yubihsm-rs",
"path": "/src/commands/attest_asymmetric.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harrier-lcc/yubihsm-rs path: /src/commands/attest_asymmetric.rs
//! Obtain an X.509 attestation certificate for a key within the `YubiHSM2`
//!
//! <https://developers.yubico.com/YubiHSM2/Commands/Get_Object_Info.html>
//!
use super::{Command, Response};
use {CommandType, Connector, ObjectId, Se... | code_fim | hard | {
"lang": "rust",
"repo": "harrier-lcc/yubihsm-rs",
"path": "/src/commands/attest_asymmetric.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Response for AttestationCertificate {
const COMMAND_TYPE: CommandType = CommandType::AttestAsymmetric;
}
#[allow(unknown_lints, len_without_is_empty)]
impl AttestationCertificate {
/// Unwrap inner byte vector
pub fn into_vec(self) -> Vec<u8> {
self.into()
}
/// Get leng... | code_fim | hard | {
"lang": "rust",
"repo": "harrier-lcc/yubihsm-rs",
"path": "/src/commands/attest_asymmetric.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: germangb/imgui-ext path: /src/progress.rs
//!
//! Works on `f32` and `Option<f32>`.
//!
//! # Optional params
//!
//! * `overlay` override default overlay text.
//! * `size` path to a function that returns the size.
//! * `map` Applies a mapping function to `&mut Self`.
//!
//! ## Example
//!
//... | code_fim | medium | {
"lang": "rust",
"repo": "germangb/imgui-ext",
"path": "/src/progress.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Progress> Progress for Option<T> {
#[inline]
fn build(ui: &Ui, elem: &Self, params: ProgressParams) {
if let Some(elem) = elem {
T::build(ui, elem, params)
}
}
}<|fim_prefix|>// repo: germangb/imgui-ext path: /src/progress.rs
//!
//! Works on `f32` and `Opt... | code_fim | hard | {
"lang": "rust",
"repo": "germangb/imgui-ext",
"path": "/src/progress.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if this container implements an interface
pub fn does_implement(&self, intf_canon_name: &String) -> bool {
self.interfaces.contains(intf_canon_name)
}
/// Adds a member variable
pub fn add_member_variable(&mut self, var: (String, Type)) -> CompilerResult<()> {... | code_fim | hard | {
"lang": "rust",
"repo": "delbato/oxy-script",
"path": "/oxs/oxs/src/codegen/def.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: delbato/oxy-script path: /oxs/oxs/src/codegen/def.rs
use crate::{
parser::{
ast::{
Type,
FunctionDeclArgs,
ContainerDeclArgs
}
},
codegen::{
compiler::{
CompilerResult,
CompilerError,
Comp... | code_fim | hard | {
"lang": "rust",
"repo": "delbato/oxy-script",
"path": "/oxs/oxs/src/codegen/def.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Gets the byte offset of a member
pub fn get_member_offset(&self, compiler: &Compiler, var_name: &String) -> CompilerResult<usize> {
let target_index = self.get_member_index(var_name)?;
let mut offset = 0;
for (member_name, member_index) in self.member_indices.iter() {
... | code_fim | hard | {
"lang": "rust",
"repo": "delbato/oxy-script",
"path": "/oxs/oxs/src/codegen/def.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(output.status.success());
}
// The actual work here is completely driven by the futures. We
// only execute one future per reactor loop.
async fn start() {
bdev_create(BDEVNAME).await.expect("failed to create bdev");
bdev_io::write_some(BDEVNAME, 0, 0xff).await.unwrap();
bdev_io::... | code_fim | hard | {
"lang": "rust",
"repo": "wade-wu/mayastor",
"path": "/mayastor/tests/io.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wade-wu/mayastor path: /mayastor/tests/io.rs
use std::process::Command;
use common::bdev_io;
use mayastor::{core::MayastorCliArgs, nexus_uri::bdev_create};
static DISKNAME: &str = "/tmp/disk.img";
static BDEVNAME: &str = "aio:///tmp/disk.img?blk_size=512";
pub mod common;
#[tokio::test]
async... | code_fim | medium | {
"lang": "rust",
"repo": "wade-wu/mayastor",
"path": "/mayastor/tests/io.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An `Injector`: a container for components.
#[derive(Debug, Clone)]
pub struct Injector<Components> {
components: Components,
}
#[cfg(test)]
mod injector_tests;<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/injector/mod.rs
//!
mod impl_construct;
mod impl_empty;
mod impl_trait_provide;
mod... | code_fim | easy | {
"lang": "rust",
"repo": "RGafiyatullin/tfsi",
"path": "/src/injector/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RGafiyatullin/tfsi path: /src/injector/mod.rs
//!
mod impl_construct;
mod impl_empty;
mod impl_trait_provide;
mod impl_with_arc;
mod impl_with_component;
mod impl_with_provider;
mod impl_with_value;
<|fim_suffix|>/// An `Injector`: a container for components.
#[derive(Debug, Clone)]
pub struct... | code_fim | easy | {
"lang": "rust",
"repo": "RGafiyatullin/tfsi",
"path": "/src/injector/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RDambrosio016/starlight path: /crates/wtf-rs/src/cryptographically_random_number.rs
use core::{cell::UnsafeCell, mem::MaybeUninit};
use once_cell::sync::Lazy;
use parking_lot::{lock_api::RawMutex, RawMutex as Lock};
use crate::random_device::cryptographically_random_number_from_os;
#[derive(Cl... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/wtf-rs/src/cryptographically_random_number.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn random_number(&mut self) -> u32 {
self.mutex.lock();
self.count -= 4;
self.stir_if_needed();
let word = self.get_word();
unsafe { self.mutex.unlock() };
word
}
pub fn stir_if_needed(&mut self) {
if self.count <= 0 {
se... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/wtf-rs/src/cryptographically_random_number.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_random_data(&mut self, data: &[u8]) {
self.stream.i = self.stream.i.wrapping_sub(1);
for n in 0..256 {
self.stream.i = self.stream.i.wrapping_add(1);
let si = self.stream.s[self.stream.i as usize];
self.stream.j = self
.stream
... | code_fim | hard | {
"lang": "rust",
"repo": "RDambrosio016/starlight",
"path": "/crates/wtf-rs/src/cryptographically_random_number.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut num = num;
while num > 0. {
if binary.len() >= 32 {
return Ok("ERROR".to_string());
}
let r = num * 2.;
if r >= 1. {
write!(&mut binary, "{}", 1)?;
num = r - 1.;
} else {
write!(&mut binary, "{}", 0)?;... | code_fim | medium | {
"lang": "rust",
"repo": "DarinM223/ctci-rs",
"path": "/src/chapter5/binary_to_string.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DarinM223/ctci-rs path: /src/chapter5/binary_to_string.rs
use std::fmt::{Error, Write};
pub fn print_binary(num: f64) -> Result<String, Error> {
if num >= 1. || num <= 0. {
return Ok("ERROR".to_string());
}
<|fim_suffix|> let mut num = num;
while num > 0. {
if bi... | code_fim | medium | {
"lang": "rust",
"repo": "DarinM223/ctci-rs",
"path": "/src/chapter5/binary_to_string.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilipDaniels/dnscan path: /dnscan/src/main.rs
mod csv_output;
mod errors;
mod options;
use chrono::{DateTime, Utc};
use dnlib::prelude::*;
use logging_timer::{finish, timer, stimer, executing};
use env_logger::Builder;
use errors::AnalysisResult;
use log::{warn, Level};
use options::Options;
u... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/dnscan",
"path": "/dnscan/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn merge_configuration_and_options(mut config: Configuration, options: Options) -> Configuration {
if let Some(dir) = options.output_directory {
config.output_directory = dir;
}
if let Some(dir) = options.input_directory {
config.input_directory = dir;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipDaniels/dnscan",
"path": "/dnscan/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hanasuke/rustbook path: /04/ex04/examples/4-2-8.rs
fn double(n: i32) -> i32 {
<|fim_suffix|> if n >= 0 { n } else { -n }
}
fn main() {
let mut f: fn(i32) -> i32 = double;
assert_eq!(f(-42), -84);
f = abs;
assert_eq!(f(-42), 42);
}<|fim_middle|> n + n
}
fn abs(n: i32) -> i32 {
| code_fim | easy | {
"lang": "rust",
"repo": "hanasuke/rustbook",
"path": "/04/ex04/examples/4-2-8.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut f: fn(i32) -> i32 = double;
assert_eq!(f(-42), -84);
f = abs;
assert_eq!(f(-42), 42);
}<|fim_prefix|>// repo: hanasuke/rustbook path: /04/ex04/examples/4-2-8.rs
fn double(n: i32) -> i32 {
<|fim_middle|> n + n
}
fn abs(n: i32) -> i32 {
if n >= 0 { n } else { -n }
}
| code_fim | medium | {
"lang": "rust",
"repo": "hanasuke/rustbook",
"path": "/04/ex04/examples/4-2-8.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hanasuke/rustbook path: /04/ex04/examples/4-2-8.rs
fn double(n: i32) -> i32 {
<|fim_suffix|> let mut f: fn(i32) -> i32 = double;
assert_eq!(f(-42), -84);
f = abs;
assert_eq!(f(-42), 42);
}<|fim_middle|> n + n
}
fn abs(n: i32) -> i32 {
if n >= 0 { n } else { -n }
}
fn main() {
| code_fim | medium | {
"lang": "rust",
"repo": "hanasuke/rustbook",
"path": "/04/ex04/examples/4-2-8.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/wasmer path: /src/spectests/tee_local.rs
tee_local 0)
(func (;2;) (type 2) (result f32)
(local f32)
f32.const 0x0p+0 (;=0;)
tee_local 0)
(func (;3;) (type 3) (result f64)
(local f64)
f64.const 0x0p+0 (;=0;)
tee_local 0)
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wasmer",
"path": "/src/spectests/tee_local.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Line 115
fn c10_l115_action_invoke(result_object: &ResultObject) {
println!("Executing function {}", "c10_l115_action_invoke");
let func_index = match result_object.module.info.exports.get("write") {
Some(&Export::Function(index)) => index,
_ => panic!("Function not found"),
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wasmer",
"path": "/src/spectests/tee_local.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/wasmer path: /src/spectests/tee_local.rs
(func (;8;) (type 8) (param i64 f32 f64 i32 i32)
(local f32 i64 i64 f64)
i64.const 0
tee_local 0
i64.eqz
drop
f32.const 0x0p+0 (;=0;)
tee_local 1
f32.neg
drop
f64.co... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/wasmer",
"path": "/src/spectests/tee_local.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.