text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn m2(&self, x: &dyn T5<X>);
}
trait T6<X: T> {
fn dummy(&self) { }
fn m1(&self, x: &dyn T4<X>);
fn m2(&self, x: &dyn T5<X>);
}
trait T7<X: ?Sized+T> {
fn dummy(&self) { }
// not an error (for now)
fn m1(&self, x: &dyn T4<X>);
fn m2(&self, x: &dyn T5<X>);
}
// The last fi... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/unsized2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> box S
}
}
fn f7<X: ?Sized+T3>(x: &X) {
// This is valid, but the unsized bound on X is irrelevant because any type
// which implements T3 must have statically known size.
let _: Box<X> = T3::f();
}
trait T4<X> {
fn dummy(&self) { }
fn m1(&self, x: &dyn T4<X>, y: X);
fn... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/unsized2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thorhs/mk66f18 path: /src/spi2.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Module Configuration Register"]
pub mcr: MCR,
_reserved1: [u8; 4usize],
#[doc = "0x08 - Transfer Count Register"]
pub tcr: TCR,
_reserved_2_ctar: [u8; 8usize... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/spi2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ow(missing_docs)]
#[doc(hidden)]
pub struct _PUSHR;
#[doc = "`read()` method returns [pushr::R](pushr::R) reader structure"]
impl crate::Readable for PUSHR {}
#[doc = "`write(|w| ..)` method takes [pushr::W](pushr::W) writer structure"]
impl crate::Writable for PUSHR {}
#[doc = "PUSH TX FIFO Register In M... | code_fim | hard | {
"lang": "rust",
"repo": "thorhs/mk66f18",
"path": "/src/spi2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::Sponge(sponge)
},
RngRaw::Seed(seed) => Self::Seed(seed),
RngRaw::Sponge(sponge) => Self::Sponge(sponge),
RngRaw::State(state) => Self::State(state),
RngRaw::StateElseSponge(state) => {
match bincode::Options... | code_fim | hard | {
"lang": "rust",
"repo": "juntyr/necsim-rust",
"path": "/rustcoalescence/src/args/config/rng/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juntyr/necsim-rust path: /rustcoalescence/src/args/config/rng/mod.rs
use std::{fmt, marker::PhantomData};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_state::DeserializeState;
use necsim_core::cogs::{MathsCore, RngCore};
use necsim_partitioning_core::partition::Part... | code_fim | hard | {
"lang": "rust",
"repo": "juntyr/necsim-rust",
"path": "/rustcoalescence/src/args/config/rng/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustWorks/openshift-openapi-codegen path: /src/v4_4/api/quota/v1/cluster_resource_quota_status.rs
// Generated from definition com.github.openshift.api.quota.v1.ClusterResourceQuotaStatus
/// ClusterResourceQuotaStatus defines the actual enforced quota and its current usage
#[derive(Clone, Debu... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/openshift-openapi-codegen",
"path": "/src/v4_4/api/quota/v1/cluster_resource_quota_status.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.write_str("ClusterResourceQuotaStatus")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
let mut value_namespaces: Option<Vec<crate::api::quota::v1::ResourceQuotaStatusByNamespace>> = None;
... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/openshift-openapi-codegen",
"path": "/src/v4_4/api/quota/v1/cluster_resource_quota_status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mboecker/edcert-restrevoke path: /src/restrevoker.rs
// The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Softw... | code_fim | hard | {
"lang": "rust",
"repo": "mboecker/edcert-restrevoke",
"path": "/src/restrevoker.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create the request
let mut req = client.get(&format!("{}{}", self.revokeserver, &bytestr))
.send()
.expect("Failed to request");
// allocate a string for the response and read it
let mut response = String::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "mboecker/edcert-restrevoke",
"path": "/src/restrevoker.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
UN
]
:
U42
/
/
/
/
/
/
#
Example
/
/
/
/
/
/
rust
/
/
/
use
typenum
:
:
*
;
/
/
/
/
/
/
assert_type_eq
!
(
U
<
42
>
U42
)
;
/
/
/
/
/
/
/
/
/
This
can
even
be
used
in
a
generic
const
N
:
usize
context
provided
the
/
/
/
genericity
is
guarded
by
a
where
clause
:
/
/
/
/
/
/
rust
/
/
/
use
typenum
:
:
*
;
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/typenum/build/generic_const_mappings.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/typenum/build/generic_const_mappings.rs
use
super
:
:
*
;
pub
fn
emit_impls
(
)
-
>
:
:
std
:
:
io
:
:
Result
<
(
)
>
{
let
out_dir
=
:
:
std
:
:
env
:
:
var
(
"
OUT_DIR
"
)
.
unwrap
(
)
;
let
dest
=
:
:
std
:
:
path
:
:
Path
:
:
new
(
&
out_di... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/typenum/build/generic_const_mappings.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ruct
<
42
>
as
MyTrait
>
:
:
AssocType
U42
)
;
/
/
/
pub
type
U
<
const
N
:
usize
>
=
<
Const
<
N
>
as
ToUInt
>
:
:
Output
;
/
/
/
Used
to
allow
the
usage
of
[
U
]
in
a
generic
context
.
pub
struct
Const
<
const
N
:
usize
>
;
/
/
/
Used
to
allow
the
usage
of
[
U
]
in
a
generic
context
.
pub
trait
ToUInt
{... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/typenum/build/generic_const_mappings.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/network/netstack3/src/bindings/util.rs
(ctx, zone)
.map_err(SocketAddressError::Device)
})
.map(Into::into)?
}
None => specified.into(),
};
Ok((Som... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/src/bindings/util.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (net, prefix) = self.net_prefix();
Ok(fidl_net::Subnet { addr: net.into_fidl(), prefix_len: prefix })
}
}
impl TryFromFidl<fposix_socket::OptionalUint8> for Option<u8> {
type Error = Never;
fn try_from_fidl(fidl: fposix_socket::OptionalUint8) -> Result<Self, Self::Error> ... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/src/bindings/util.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A FIDL type which can be fallibly converted from the core type `C` given a
/// context that implements [`ConversionContext`].
///
/// `TryFromCoreWithContext<C>` is automatically implemented for all `F` where
/// [`C: TryIntoFidlWithContext<F>`].
///
/// [`C: TryIntoFidlWithContext<F>`]: crate::bindin... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/network/netstack3/src/bindings/util.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> x4 = _mm_add_epi32(x0, _mm_shuffle_epi32(x4, 0x4e));
x5 = _mm_add_epi32(x1, _mm_shuffle_epi32(x5, 0x4e));
x6 = _mm_add_epi32(x2, _mm_shuffle_epi32(x6, 0x4e));
x7 = _mm_add_epi32(x3, _mm_shuffle_epi32(x7, 0x4e));
y0 = x1;
... | code_fim | hard | {
"lang": "rust",
"repo": "mcrepeau/cubehash",
"path": "/src/cubehash.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcrepeau/cubehash path: /src/cubehash.rs
use std::io::Read;
use std::io::Stdin;
#[cfg(target_arch = "x86")]
use core::arch::x86::__m128i;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::__m128i;
#[cfg(target_arch = "x86")]
use core::arch::x86::_mm_set_epi32;
#[cfg(target_arch = "x86_64")]... | code_fim | hard | {
"lang": "rust",
"repo": "mcrepeau/cubehash",
"path": "/src/cubehash.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while pos < end {
x0 = _mm_xor_si128(x0, _mm_loadu_si128(pos));
pos = pos.add(1);
x1 = _mm_xor_si128(x1, _mm_loadu_si128(pos));
pos = pos.add(1);
for _i in 0..ROUNDS {
x4 = _mm_add_epi32(x0, _mm_shuffle_epi32... | code_fim | hard | {
"lang": "rust",
"repo": "mcrepeau/cubehash",
"path": "/src/cubehash.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e:f32 = 2.5; //double-precision, 8 bytes or 64 bits, f64
println!("e = {}, size of e = {} bytes", e, mem::size_of_val(&e));
// boolean
let g:bool = false;
println!("g = {}, size of g = {} bytes", g, mem::size_of_val(&g));
who_am_i();
}<|fim_prefix|>// repo: heathdrobertson/c... | code_fim | medium | {
"lang": "rust",
"repo": "heathdrobertson/code",
"path": "/rust/projects/rust_up/src/types_n_variables/core_data_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let d:char = 'x';
println!("d = {}, size of d = {} bytes", d, mem::size_of_val(&d));
let e:f32 = 2.5; //double-precision, 8 bytes or 64 bits, f64
println!("e = {}, size of e = {} bytes", e, mem::size_of_val(&e));
// boolean
let g:bool = false;
println!("g = {}, size of g = {... | code_fim | hard | {
"lang": "rust",
"repo": "heathdrobertson/code",
"path": "/rust/projects/rust_up/src/types_n_variables/core_data_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heathdrobertson/code path: /rust/projects/rust_up/src/types_n_variables/core_data_types.rs
fn who_am_i() {
println!("\nWho Am I >> {}", module_path!());
}
use std::mem;
pub fn main() {
// u = unsigned 0 or positive +
// i = signed neg or pos
let a:u8 = 123;
println!("a = {... | code_fim | hard | {
"lang": "rust",
"repo": "heathdrobertson/code",
"path": "/rust/projects/rust_up/src/types_n_variables/core_data_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let auth0_user = get_user(token.access_token());
// log::info!("Hello {} with {}", auth0_user.name, user_email);
let conn = pool.get().expect("couldn't get db connection from pool");
// use web::block to offload blocking Diesel code without blocking server thread
let user = web::blo... | code_fim | hard | {
"lang": "rust",
"repo": "smurfpandey/playday",
"path": "/playday_web/src/routes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// POST /library/{store_name}/sync
pub async fn sync_game_library(
id: Identity,
pool: web::Data<types::DBPool>,
store_name: web::Path<String>
) -> Result<HttpResponse, Error> {
let EpicGames = "epicgames".to_string();
match is_logged_in(id) {
None => return Ok(HttpResponse::... | code_fim | hard | {
"lang": "rust",
"repo": "smurfpandey/playday",
"path": "/playday_web/src/routes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smurfpandey/playday path: /playday_web/src/routes.rs
use actix_identity::Identity;
use actix_web::{web, Error, HttpRequest, HttpResponse, Responder};
use anyhow::bail;
use chrono::Utc;
use diesel::prelude::PgConnection;
use http::header::{HeaderValue, ACCEPT, AUTHORIZATION};
use http::method::Me... | code_fim | hard | {
"lang": "rust",
"repo": "smurfpandey/playday",
"path": "/playday_web/src/routes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let normalized = self.normalize();
match normalized {
Self::KiBs(s) | Self::MiBs(s) | Self::GiBs(s) =>
write!(f, "{:.2?} {}", s, normalized.unit()),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use sp_runtime::assert_eq_error_rate_float;
/// `SUBSTRATE_REFERENCE_HARDWARE` can be en- and... | code_fim | hard | {
"lang": "rust",
"repo": "ABMatrix/substrate",
"path": "/utils/frame/benchmarking-cli/src/machine/hardware.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ABMatrix/substrate path: /utils/frame/benchmarking-cli/src/machine/hardware.rs
// This file is part of Substrate.
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use thi... | code_fim | hard | {
"lang": "rust",
"repo": "ABMatrix/substrate",
"path": "/utils/frame/benchmarking-cli/src/machine/hardware.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>const KIBIBYTE: f64 = 1024.0;
impl Throughput {
/// The unit of the metric.
pub fn unit(&self) -> &'static str {
match self {
Self::KiBs(_) => "KiB/s",
Self::MiBs(_) => "MiB/s",
Self::GiBs(_) => "GiB/s",
}
}
/// [`Self`] as number of byte/s.
pub fn to_bs(&self) -> f64 {
self.to_kibs(... | code_fim | hard | {
"lang": "rust",
"repo": "ABMatrix/substrate",
"path": "/utils/frame/benchmarking-cli/src/machine/hardware.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Segment {
pub fn new(pos: GridPosition) -> Self {
Segment { pos }
}
}<|fim_prefix|>// repo: tytrdev/2dgame path: /src/components/segment.rs
use crate::components::GridPosition;
<|fim_middle|>#[derive(Clone, Copy, Debug)]
pub struct Segment {
pub pos: GridPosition,
}
| code_fim | medium | {
"lang": "rust",
"repo": "tytrdev/2dgame",
"path": "/src/components/segment.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tytrdev/2dgame path: /src/components/segment.rs
use crate::components::GridPosition;
<|fim_suffix|>impl Segment {
pub fn new(pos: GridPosition) -> Self {
Segment { pos }
}
}<|fim_middle|>#[derive(Clone, Copy, Debug)]
pub struct Segment {
pub pos: GridPosition,
}
| code_fim | medium | {
"lang": "rust",
"repo": "tytrdev/2dgame",
"path": "/src/components/segment.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> graphics::Image::new()
.rect([10.0 * 16.0, 10.0 * 16.0, 16.0, 16.0])
.draw(hero.tex(), &graphics::DrawState::default(), c.transform, g);
});
}
pub fn update<T: PartialEq>(&mut self, ctl: &controller::Controller<T>) {
self.hero.walk(ctl.dpad.flatten());
let world = &s... | code_fim | hard | {
"lang": "rust",
"repo": "BOTBrad/sunshine",
"path": "/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BOTBrad/sunshine path: /src/game.rs
use std::vec::Vec;
use graphics;
use opengl_graphics as gl_gfx;
use piston::input;
use crate::controller;
use crate::hero;
use crate::logic::physics;
use crate::world;
pub struct State {
hero: hero::Hero,
world: world::World,
gl: gl_gfx::GlGraphics,
}... | code_fim | hard | {
"lang": "rust",
"repo": "BOTBrad/sunshine",
"path": "/src/game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Colorable for ::cairo::Context {
fn set_color(&self, color: Color) {
self.set_source_rgba(
color.r, color.g, color.b, color.a
);
}
}<|fim_prefix|>// repo: strogo/frontend-3 path: /src/color.rs
pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
... | code_fim | hard | {
"lang": "rust",
"repo": "strogo/frontend-3",
"path": "/src/color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: strogo/frontend-3 path: /src/color.rs
pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
pub a: f64,
}
impl ::std::convert::Into<Color> for ::redpitaya_scpi::generator::Source {
fn into(self) -> Color {
match self {
::redpitaya_scpi::generator::Source... | code_fim | medium | {
"lang": "rust",
"repo": "strogo/frontend-3",
"path": "/src/color.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> since_the_epoch.as_millis()
}<|fim_prefix|>// repo: isgasho/nasu path: /src/lib/utils/timestamp.rs
use std::time::{SystemTime, UNIX_EPOCH};
<|fim_middle|>pub fn current_timestamp() -> u128 {
let start = SystemTime::now();
let since_the_epoch = start
.duration_since(UNIX_EPOCH)
... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/nasu",
"path": "/src/lib/utils/timestamp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/nasu path: /src/lib/utils/timestamp.rs
use std::time::{SystemTime, UNIX_EPOCH};
<|fim_suffix|> since_the_epoch.as_millis()
}<|fim_middle|>pub fn current_timestamp() -> u128 {
let start = SystemTime::now();
let since_the_epoch = start
.duration_since(UNIX_EPOCH)
... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/nasu",
"path": "/src/lib/utils/timestamp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UrkelLabs/extended-primitives path: /src/buffer.rs
use std::fmt;
use std::ops;
#[derive(thiserror::Error, Debug)]
pub enum BufferError {
#[error("Read Out of Bounds")]
OutOfBounds,
#[error(transparent)]
InvalidString(#[from] std::string::FromUtf8Error),
#[error("Non-Minimal ... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/extended-primitives",
"path": "/src/buffer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
E: ::serde::de::Error,
{
if let Ok(hex) = ::std::str::from_utf8(v) {
Buffer::from_hex(hex).map_err(E::custom)
} else {
return Err(E::invalid_value(serde::de::Un... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/extended-primitives",
"path": "/src/buffer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(u8)]
#[derive(StableAbi)]
#[sabi(kind(WithNonExhaustive(
size = {one()},
align = {one()},
)))]
#[sabi(with_constructor)]
pub enum UnalignedAndTooLarge<T = u64> {
Foo,
Bar,
Baz(T),
}
const _: () = { std::mem::forget(NEFor::new(<UnalignedAndTooLarge>::Foo)); };
const fn one() ->... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/ui_tests/nonexhaustive_ui_tests/size_align_const_err.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/tests/ui_tests/nonexhaustive_ui_tests/size_align_const_err.rs
use abi_stable::{
nonexhaustive_enum::NonExhaustiveFor as NEFor,
StableAbi,
};
#[repr(u8)]
#[derive(StableAbi)]
#[sabi(kind(WithNonExhaustive(
size = 1,
align = 1,
)))... | code_fim | medium | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/ui_tests/nonexhaustive_ui_tests/size_align_const_err.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const _: () = { std::mem::forget(NEFor::new(<UnalignedAndTooLarge>::Foo)); };
const fn one() -> usize {
1
}
fn main(){}<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/tests/ui_tests/nonexhaustive_ui_tests/size_align_const_err.rs
use abi_stable::{
nonexhaustive_enum::No... | code_fim | hard | {
"lang": "rust",
"repo": "rodrimati1992/abi_stable_crates",
"path": "/abi_stable/tests/ui_tests/nonexhaustive_ui_tests/size_align_const_err.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Apply scissor to draw params
let mut draw_params = glium::draw_parameters::DrawParameters::default();
draw_params.viewport = scissor_rect;
//draw_params.scissor = scissor_rect;
draw_params.blend = glium::draw_parameters::Blend::alpha_blending();
target.draw(&vbo,
... | code_fim | hard | {
"lang": "rust",
"repo": "tomc1998/rust-guitk",
"path": "/src/renderer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomc1998/rust-guitk path: /src/renderer/mod.rs
use glium;
use glium::Surface;
use glium::uniforms::{UniformsStorage, EmptyUniforms};
use view::Layer;
use LibState;
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 2],
color: [f32; 4],
}
implement_vertex!(Vertex, position, color);
pub... | code_fim | hard | {
"lang": "rust",
"repo": "tomc1998/rust-guitk",
"path": "/src/renderer/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Output FASTA data from the provided generator function.
fn make_fasta<F>(n: usize, mut f: F) -> io::Result<()>
where F: FnMut(&mut [u8])
{
let mut block = vec![0; BLOCK_SIZE];
// Write whole blocks.
let num_blocks = n / BLOCK_SIZE;
for _ in 0..num_blocks {
f(&mut block);
/... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/rust-sgx-benchmark",
"path": "/mesalock-sgx-bench/fasta/enclave/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/rust-sgx-benchmark path: /mesalock-sgx-bench/fasta/enclave/src/lib.rs
// Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are m... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/rust-sgx-benchmark",
"path": "/mesalock-sgx-bench/fasta/enclave/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Generate DNA sequences by weighted random selection from two alphabets.
let p0 = cumulative_probabilities(
&[('a', 0.27), ('c', 0.12), ('g', 0.12), ('t', 0.27), ('B', 0.02),
('D', 0.02), ('H', 0.02), ('K', 0.02), ('M', 0.02), ('N', 0.02),
('R', 0.02), ('S', 0.02), (... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/rust-sgx-benchmark",
"path": "/mesalock-sgx-bench/fasta/enclave/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfelsche/tremor-runtime path: /src/dflt.rs
// Copyright 2018-2020, Wayfair GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/lic... | code_fim | medium | {
"lang": "rust",
"repo": "mfelsche/tremor-runtime",
"path": "/src/dflt.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// just a default
#[cfg_attr(tarpaulin, skip)]
pub fn d_ttl() -> u32 {
64
}
// just a default
#[cfg_attr(tarpaulin, skip)]
pub fn d<T>() -> T
where
T: Default,
{
T::default()
}
// just a default
#[cfg_attr(tarpaulin, skip)]
pub fn dflt<T: Default>() -> T {
T::default()
}<|fim_prefix|>// ... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/tremor-runtime",
"path": "/src/dflt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/mod.rs
= r" that may race with any existing instances, for example by only"]
#[doc = r" accessing read-only or write-only registers, or by consuming the"]
#[doc = r" original peripheral and using critical sections to coordinate"]
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/mod.rs
t SPI3 {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for SPI3 {}
impl SPI3 {
#[doc = r"Pointer to the register block"]
pub const PTR: *const spi1::RegisterBlock = 0x4000_3c00 as *const _;
#[doc = r"Return the... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.debug_struct("SEC_ICACHE").finish()
}
}
#[doc = "ICache"]
pub use self::icache as sec_icache;
#[doc = "Independent watchdog"]
pub struct IWDG {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for IWDG {}
impl IWDG {
#[doc = r"Pointer to the register block"]
pub const PTR: *co... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elonmuskceo/tokenizers path: /tokenizers/src/tokenizer/mod.rs
deInput {
Single(String),
Dual(String, String),
}
#[derive(Debug, Clone)]
pub struct AddedToken {
/// The content of the added token
pub content: String,
/// Whether this token must be a single word or can break w... | code_fim | hard | {
"lang": "rust",
"repo": "elonmuskceo/tokenizers",
"path": "/tokenizers/src/tokenizer/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elonmuskceo/tokenizers path: /tokenizers/src/tokenizer/mod.rs
false,
}
}
}
// We only want to hash on the content. AddedToken cannot be added multiple times with different
// options
impl std::hash::Hash for AddedToken {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
... | code_fim | hard | {
"lang": "rust",
"repo": "elonmuskceo/tokenizers",
"path": "/tokenizers/src/tokenizer/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Encode all the sentences in parallel, using multiple threads
pub fn encode_batch(&self, inputs: Vec<EncodeInput>) -> Result<Vec<Encoding>> {
let encodings = inputs
.into_par_iter()
.map(|input| self.encode(input))
.collect::<Result<Vec<Encoding>>>()?... | code_fim | hard | {
"lang": "rust",
"repo": "elonmuskceo/tokenizers",
"path": "/tokenizers/src/tokenizer/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmwill/tonic path: /tonic-web/src/call.rs
use std::error::Error;
use std::pin::Pin;
use std::task::{Context, Poll};
use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures_core::{ready, Stream};
use http::{header, HeaderMap, HeaderValue};
use http_body::{Body, SizeHint};
use pin_project::pin_pro... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic-web/src/call.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut this = self.as_mut().project();
match ready!(this.inner.as_mut().poll_data(cx)) {
Some(Ok(data)) => this.buf.put(data),
Some(Err(e)) => return Poll::Ready(Some(Err(internal_error(e)))),
None => {
... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic-web/src/call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll_trailers(
self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Result<Option<HeaderMap<HeaderValue>>, Self::Error>> {
Poll::Ready(Ok(None))
}
fn is_end_stream(&self) -> bool {
self.inner.is_end_stream()
}
fn size_hint(&self) -> SizeHint {
... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic-web/src/call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Andrew-College/GolfMania-Rust path: /src/main.rs
#![feature(start)]
extern crate GolfManiaLib as glib;
mod view;
mod login_logic;
use glib::model::{score_card};
use glib::model::map::*;
use view::console;
#[start]
fn main( argc : isize, argv: *const *const u8 ) -> isize {
<|fim_suffix|> fo... | code_fim | medium | {
"lang": "rust",
"repo": "Andrew-College/GolfMania-Rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test : Map = MapBuilder::from_named(None).unwrap();
for thing in test.into_iter() {
//println!("{:?}", thing);
}
1337
}<|fim_prefix|>// repo: Andrew-College/GolfMania-Rust path: /src/main.rs
#![feature(start)]
extern crate GolfManiaLib as glib;
<|fim_middle|>mod view;
mod l... | code_fim | medium | {
"lang": "rust",
"repo": "Andrew-College/GolfMania-Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut random_bytes = [0u8; RANDOM_BYTES_LENGTH];
reader.read_exact(&mut random_bytes)?;
Ok(HandshakeRandom {
gmt_unix_time,
random_bytes,
})
}
// populate fills the HandshakeRandom with random values
// may be called multiple times
... | code_fim | hard | {
"lang": "rust",
"repo": "peter-signal/dtls",
"path": "/src/handshake/handshake_random.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peter-signal/dtls path: /src/handshake/handshake_random.rs
use rand::Rng;
use std::io::{Read, Write};
use std::time::{Duration, SystemTime};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use util::Error;
pub const RANDOM_BYTES_LENGTH: usize = 28;
pub const HANDSHAKE_RANDOM_LENGTH:... | code_fim | medium | {
"lang": "rust",
"repo": "peter-signal/dtls",
"path": "/src/handshake/handshake_random.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // populate fills the HandshakeRandom with random values
// may be called multiple times
pub fn populate(&mut self) {
self.gmt_unix_time = SystemTime::now();
rand::thread_rng().fill(&mut self.random_bytes);
}
}<|fim_prefix|>// repo: peter-signal/dtls path: /src/handshake/h... | code_fim | hard | {
"lang": "rust",
"repo": "peter-signal/dtls",
"path": "/src/handshake/handshake_random.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match lua_value {
LuaNil => Ok(LMetronomeSettings(MetronomeSettings::default())),
LuaValue::Table(table) => {
let mut settings = MetronomeSettings::default();
if table.contains_key("tempo")? {
settings.tempo = table.get::<_, LTempo>("tempo")?.0;
}
if table.contains_key("interv... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/kira",
"path": "/kira-lua/src/metronome.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/kira path: /kira-lua/src/metronome.rs
use kira::MetronomeSettings;
use mlua::prelude::*;
use crate::{error::KiraLuaError, tempo::LTempo};
<|fim_suffix|>impl<'lua> FromLua<'lua> for LMetronomeSettings {
fn from_lua(lua_value: LuaValue<'lua>, _: &'lua Lua) -> LuaResult<Self> {
match l... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/kira",
"path": "/kira-lua/src/metronome.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'lua> FromLua<'lua> for LMetronomeSettings {
fn from_lua(lua_value: LuaValue<'lua>, _: &'lua Lua) -> LuaResult<Self> {
match lua_value {
LuaNil => Ok(LMetronomeSettings(MetronomeSettings::default())),
LuaValue::Table(table) => {
let mut settings = MetronomeSettings::default();
if tab... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/kira",
"path": "/kira-lua/src/metronome.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Diesel(#[from] diesel::result::Error),
#[error(transparent)]
Other(#[from] anyhow::Error),
}<|fim_prefix|>// repo: risoflora/fiscalidade_server path: /src/db/mod.rs
use diesel::PgConnection;
use rocket_contrib::database;
use t... | code_fim | medium | {
"lang": "rust",
"repo": "risoflora/fiscalidade_server",
"path": "/src/db/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[database("postgres_pool")]
pub struct Conn(PgConnection);
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Diesel(#[from] diesel::result::Error),
#[error(transparent)]
Other(#[from] anyhow::Error),
}<|fim_prefix|>// repo: risoflora/fiscalidade_server path: /src/db/mod.rs
... | code_fim | medium | {
"lang": "rust",
"repo": "risoflora/fiscalidade_server",
"path": "/src/db/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risoflora/fiscalidade_server path: /src/db/mod.rs
use diesel::PgConnection;
use rocket_contrib::database;
use thiserror::Error;
<|fim_suffix|>#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Diesel(#[from] diesel::result::Error),
#[error(transparent)]
Other(#[from]... | code_fim | medium | {
"lang": "rust",
"repo": "risoflora/fiscalidade_server",
"path": "/src/db/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NivenT/REnforce path: /src/stat/mod.rs
//! Statistics Module
use rand::{Rng, thread_rng};
use num::Float;
use num::cast::NumCast;
/// Calculates the mean and variance of a set of numbers
pub fn mean_var<T: Float>(nums: &[T]) -> (T, T) {
let (mut sum, mut sq_sum) = (T::zero(), T::zero());
fo... | code_fim | hard | {
"lang": "rust",
"repo": "NivenT/REnforce",
"path": "/src/stat/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut nums: Vec<_> = (0..100).map(|n| n as f64).collect();
normalize(&mut nums);
let (mean, var) = mean_var(&nums);
assert!(mean.abs() < EPSILON && (var - 1.0).abs() < EPSILON);
}
#[test]
fn shuffle_simple() {
let mut nums: Vec<_> = (0..10).collect();
shuffle(&mut nums);
assert!(nums.... | code_fim | hard | {
"lang": "rust",
"repo": "NivenT/REnforce",
"path": "/src/stat/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_1() {
assert_eq!(
to_list(vec![1, 2, 3, 4]),
Solution::insertion_sort_list(to_list(vec![4, 2, 1, 3]))
);
}
#[test]
fn example_2() {
assert_eq!(
to_list(vec![-1, 0, 3, 4, 5]),
Solution::insertion... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/november-leetcoding-challenge/week-1/3517/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/leetcode path: /others/november-leetcoding-challenge/week-1/3517/lib.rs
use utils::ListNode;
pub struct Solution {}
impl Solution {
pub fn insertion_sort_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
let mut head = head;
let mut dummy = ListNode::new(0... | code_fim | medium | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/november-leetcoding-challenge/week-1/3517/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snow2flying/drogue-tls path: /drogue-tls/src/ssl/context.rs
use drogue_tls_sys::{
ssl_context, ssl_init, ssl_set_hostname, ssl_setup, ERR_SSL_ALLOC_FAILED, ERR_SSL_BAD_INPUT_DATA,
};
use crate::ffi::CStr;
use crate::platform::strlen;
use core::ptr::slice_from_raw_parts;
use core::str::from... | code_fim | hard | {
"lang": "rust",
"repo": "snow2flying/drogue-tls",
"path": "/drogue-tls/src/ssl/context.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result != 0 {
Err(())
} else {
Ok(())
}
}
pub fn set_hostname(&mut self, hostname: &str) -> Result<(), HostnameError> {
let hostname_cstr: CStr<U255> = CStr::new(hostname);
match unsafe { ssl_set_hostname(self.inner_mut(), hostnam... | code_fim | hard | {
"lang": "rust",
"repo": "snow2flying/drogue-tls",
"path": "/drogue-tls/src/ssl/context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub key: AuditLogChangeKey,
#[cfg(feature = "serde-support")]
pub new_value: Option<serde_value::Value>,
#[cfg(feature = "serde-support")]
pub old_value: Option<serde_value::Value>,
}<|fim_prefix|>// repo: haze/dawn path: /model/src/guild/audit_log/change.rs
use crate::guild::audit_log::... | code_fim | medium | {
"lang": "rust",
"repo": "haze/dawn",
"path": "/model/src/guild/audit_log/change.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haze/dawn path: /model/src/guild/audit_log/change.rs
use crate::guild::audit_log::AuditLogChangeKey;
#[cfg_attr(
feature = "serde-support",
derive(serde::Deserialize, serde::Serialize)
)]
#[derive(Clone, Debug)]
pub struct AuditLogChange {
<|fim_suffix|>alue::Value>,
#[cfg(featur... | code_fim | medium | {
"lang": "rust",
"repo": "haze/dawn",
"path": "/model/src/guild/audit_log/change.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>alue::Value>,
#[cfg(feature = "serde-support")]
pub old_value: Option<serde_value::Value>,
}<|fim_prefix|>// repo: haze/dawn path: /model/src/guild/audit_log/change.rs
use crate::guild::audit_log::AuditLogChangeKey;
#[cfg_attr(
feature = "serde-support",
der<|fim_middle|>ive(serde::Deser... | code_fim | medium | {
"lang": "rust",
"repo": "haze/dawn",
"path": "/model/src/guild/audit_log/change.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
D: serde::Deserializer<'de>,
{
Ok(u64::deserialize(deserializer)?.into())
}
}
impl serde::Serialize for ControlRoll {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
u64::from(self).serialize(seria... | code_fim | hard | {
"lang": "rust",
"repo": "fishface60/gmtools",
"path": "/gcs/src/control_roll.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fishface60/gmtools path: /gcs/src/control_roll.rs
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq)]
pub enum ControlRoll {
NotApplicable,
Rarely,
FairlyOften,
QuiteOften,
AlmostAlways,
NoneRequired,
}
impl From<&ControlRoll> for u64 {
fn from(va... | code_fim | medium | {
"lang": "rust",
"repo": "fishface60/gmtools",
"path": "/gcs/src/control_roll.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/sample_mask_override_coverage_nv.rs
//! VK_NV_sample_mask_override_coverage extensions
pub con<|fim_suffix|>_NAME: &'static str = "VK_NV_sample_mask_override_coverage";<|fim_middle|>st VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION: usize = 1;
pub static V... | code_fim | medium | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/sample_mask_override_coverage_nv.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>_NAME: &'static str = "VK_NV_sample_mask_override_coverage";<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/sample_mask_override_coverage_nv.rs
//! VK_NV_sample_mask_override_coverage extensions
pub const VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION: usize =<|fim_middle|> 1;
pub static V... | code_fim | medium | {
"lang": "rust",
"repo": "Pctg-x8/interlude",
"path": "/vk/defs/src/sample_mask_override_coverage_nv.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rillrate-fossil/rillrate path: /pkg-core/rill-config/src/env.rs
use crate::ReadableConfig;
use anyhow::Error;
use std::env::{var, VarError};
use std::str::FromStr;
pub fn typed_var<T>(name: &'static str) -> Result<Option<T>, Error>
where
T: FromStr,
Error: From<T::Err>,
{
match var(... | code_fim | medium | {
"lang": "rust",
"repo": "rillrate-fossil/rillrate",
"path": "/pkg-core/rill-config/src/env.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> envy::prefixed(Self::prefix())
.from_env()
.map_err(Error::from)
}
}<|fim_prefix|>// repo: rillrate-fossil/rillrate path: /pkg-core/rill-config/src/env.rs
use crate::ReadableConfig;
use anyhow::Error;
use std::env::{var, VarError};
use std::str::FromStr;
pub fn typed_... | code_fim | medium | {
"lang": "rust",
"repo": "rillrate-fossil/rillrate",
"path": "/pkg-core/rill-config/src/env.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ScottyThePilot/a3f_sentinel path: /src/data/config.rs
use std::collections::{HashSet, BTreeMap};
use std::sync::Arc;
use singlefile::serde_multi::formats::json::Json;
use singlefile::BackendReadonly;
use serenity::{
prelude::{TypeMapKey, RwLock},
model::{
channel::{Reaction, ReactionTyp... | code_fim | hard | {
"lang": "rust",
"repo": "ScottyThePilot/a3f_sentinel",
"path": "/src/data/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_higher_rank(&self, rank_name: &str) -> Option<&Rank> {
let index = self.ranks.iter()
.position(|rank| rank.name == rank_name)?;
self.ranks.get(index + 1)
}
pub fn get_lower_rank(&self, rank_name: &str) -> Option<&Rank> {
let index = self.ranks.iter()
.position(|ra... | code_fim | hard | {
"lang": "rust",
"repo": "ScottyThePilot/a3f_sentinel",
"path": "/src/data/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peter-fomin/rust-playground path: /spiral-matrix/src/lib.rs
enum Direction {
Right,
Down,
Left,
Up,
}
use Direction::*;
pub fn spiral_matrix(size: usize) -> Vec<Vec<u32>> {
let (mut row, mut col) = (0, 0);
let mut matrix = vec!(vec!(0_u32; size); size);
let mut dire... | code_fim | hard | {
"lang": "rust",
"repo": "peter-fomin/rust-playground",
"path": "/spiral-matrix/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>wn => if row < size - 1 && matrix[row + 1][col] == 0{
row +=1;
} else {
direction = Left;
col -=1;
},
Left => if col > 0 && matrix[row][col - 1] == 0{
col -=1;
} else {
direction... | code_fim | hard | {
"lang": "rust",
"repo": "peter-fomin/rust-playground",
"path": "/spiral-matrix/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self
}
}
pub type CoreInputViewOcclusionsChangedEventArgs = *mut ::core::ffi::c_void;
pub type CoreInputViewShowingEventArgs = *mut ::core::ffi::c_void;
pub type CoreInputViewTransferringXYFocusEventArgs = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct CoreInputViewXYFocusTransferD... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/UI/ViewManagement/Core/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/UI/ViewManagement/Core/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type CoreFrameworkInputView = *mut ::co... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/UI/ViewManagement/Core/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[contract]
pub struct WriteBytesContract;
#[contractimpl]
impl WriteBytesContract {
pub fn write(env: Env, xdr_bytes: Bytes) -> BytesN<32> {
let hash = env.crypto().sha256(&xdr_bytes);
env.storage().persistent().set(&hash, &xdr_bytes);
env.storage().persistent().bump(&hash, B... | code_fim | medium | {
"lang": "rust",
"repo": "stellar/stellar-core",
"path": "/scripts/soroban-settings/write_upgrade_bytes/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stellar/stellar-core path: /scripts/soroban-settings/write_upgrade_bytes/src/lib.rs
#![no_std]
use soroban_sdk::{contract, contractimpl, Env, Bytes, BytesN};
<|fim_suffix|> env.storage().instance().bump(BUMP_AMOUNT);
hash
}
}
mod test;<|fim_middle|>pub(crate) const BUMP_AMO... | code_fim | hard | {
"lang": "rust",
"repo": "stellar/stellar-core",
"path": "/scripts/soroban-settings/write_upgrade_bytes/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #2630
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
// #2956
fn bar(beans: Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf, spam: bool, eggs: bool) -> bool{
unimplemented!();
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustfmt",
"path": "/tests/source/fn-simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustfmt path: /tests/source/fn-simple.rs
// rustfmt-normalize_comments: true
fn simple(/*pre-comment on a function!?*/ i: i32/*yes, it's possible! */
,response: NoWay /* hose */) {
fn op(x: Typ, key : &[u8], upd : Box<Fn(Option<&memcache::It... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustfmt",
"path": "/tests/source/fn-simple.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn http_fetch_async(listener:Box< AsyncCORSResponseListener+Send >, script_chan: Box<ScriptChan+Send>) {
}
fn some_func<T:Box<Trait+Bound>>(val:T){}
fn zzzzzzzzzzzzzzzzzzzz<Type, NodeType>
(selff: Type, mut handle: node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>)
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustfmt",
"path": "/tests/source/fn-simple.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ED-NEWP/galos path: /galos_db/examples/systems.rs
use galos_db::{Error, Database};
use galos_db::systems::System;
#[async_std::main]
async fn main() -> Result<(), Error> {
let db =<|fim_suffix|> "Sol").await?;
println!("SELECT: {:#?}", system);
Ok(())
}<|fim_middle|> Database::new(... | code_fim | medium | {
"lang": "rust",
"repo": "ED-NEWP/galos",
"path": "/galos_db/examples/systems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Database::new().await?;
let system = System::fetch_by_name(&db, "Sol").await?;
println!("SELECT: {:#?}", system);
Ok(())
}<|fim_prefix|>// repo: ED-NEWP/galos path: /galos_db/examples/systems.rs
use galos_db::{Error, Database};
use galos_db::systems::System;
#[<|fim_middle|>async_std::main... | code_fim | medium | {
"lang": "rust",
"repo": "ED-NEWP/galos",
"path": "/galos_db/examples/systems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while task_done_len < task_total_len {
let task_left_len = task_total_len - task_done_len;
let this_done_len = {
if task_left_len >= real_capacity_len {
real_capacity_len as usize
} else {
task_left_len as usize
}
... | code_fim | hard | {
"lang": "rust",
"repo": "wangmarkqi/udp_hole_punching",
"path": "/src/client/packet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut queue = vec![];
let mut task_done_len = 0;
let mut order = 0;
while task_done_len < task_total_len {
let task_left_len = task_total_len - task_done_len;
let this_done_len = {
if task_left_len >= real_capacity_len {
real_capacity_len as u... | code_fim | hard | {
"lang": "rust",
"repo": "wangmarkqi/udp_hole_punching",
"path": "/src/client/packet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wangmarkqi/udp_hole_punching path: /src/client/packet.rs
use crate::server::swap_cmd::SwapCmd;
use std::mem::size_of;
use super::conf::Conf;
use rand::Rng;
#[derive(PartialEq, Debug, Clone)]
pub struct Packet {
pub cmd: u8,
pub sess: u32,
pub max: u32,
pub order: u32,
pub bo... | code_fim | hard | {
"lang": "rust",
"repo": "wangmarkqi/udp_hole_punching",
"path": "/src/client/packet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: llogiq/koto path: /src/parser/src/parser.rs
tIndex>, ParserError> {
use Token::*;
let last_lhs = match lhs {
[last] => *last,
[.., last] => *last,
_ => return internal_error!(MissingContinuedExpressionLhs, self),
};
if let Som... | code_fim | hard | {
"lang": "rust",
"repo": "llogiq/koto",
"path": "/src/parser/src/parser.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.