text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub fn run() -> Result<(), Box<dyn Error>> {
let nums = parser::parse(&fs::read_to_string("in.txt")?)?;
println!("Part 1: {}", to_snafu(nums.iter().sum::<isize>()));
Ok(())
}<|fim_prefix|>// repo: Noble-Mushtak/Advent-of-Code path: /2022/day25/src/lib.rs
use std::collections::VecDeq... | code_fim | hard | {
"lang": "rust",
"repo": "Noble-Mushtak/Advent-of-Code",
"path": "/2022/day25/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Matrix is a NxN matrix
#[derive(Debug)]
pub struct Matrix {
pub stride: usize,
pub data: Vec<f64>,
}
impl Matrix {
pub fn mul(&self, m: Matrix) -> Result<Matrix, MatrixError> {
if m.stride * self.stride != m.data.len() {
return Err(MatrixError::new("Matrices are of inc... | code_fim | hard | {
"lang": "rust",
"repo": "Chakravarthy1997/civil",
"path": "/src/calc/linalg.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Chakravarthy1997/civil path: /src/calc/linalg.rs
//! WIP
//! Solvers for systems of equations.
//!
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct MatrixError {
details: String
}
impl MatrixError {
fn new(msg: &str) -> MatrixError {
<|fim_suffix|>
impl Matrix {
p... | code_fim | hard | {
"lang": "rust",
"repo": "Chakravarthy1997/civil",
"path": "/src/calc/linalg.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredfortier/bitmex-rs path: /src/model/leaderboard.rs
use serde_derive::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize)]
pub enum RankingType {
#[serde(rename = "notional")]
Notional,
#[serde(rename = "ROE")]
ROE,
}
impl Default for RankingType {
fn default() ->... | code_fim | medium | {
"lang": "rust",
"repo": "fredfortier/bitmex-rs",
"path": "/src/model/leaderboard.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Deserialize)]
pub struct GetLeaderboardNameResponse {
pub name: String,
}<|fim_prefix|>// repo: fredfortier/bitmex-rs path: /src/model/leaderboard.rs
use serde_derive::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize)]
pub enum RankingType {
#[serde(rename = "not... | code_fim | hard | {
"lang": "rust",
"repo": "fredfortier/bitmex-rs",
"path": "/src/model/leaderboard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadO... | code_fim | hard | {
"lang": "rust",
"repo": "glcraft/drift-rs",
"path": "/src/MainGame.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glcraft/drift-rs path: /src/MainGame.rs
use winit::{window::Window, event_loop::{EventLoop}};
pub struct WGPUData {
device: wgpu::Device,
queue: wgpu::Queue,
adapter: wgpu::Adapter,
surface: wgpu::Surface,
render_pipeline: wgpu::RenderPipeline,
pipeline_layout: wgpu::Pipe... | code_fim | hard | {
"lang": "rust",
"repo": "glcraft/drift-rs",
"path": "/src/MainGame.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frenicth/tock path: /capsules/src/spi.rs
//! The SPI capsule provides userspace applications with the ability
//! to communicate over the SPI bus.
use core::cell::Cell;
use core::cmp;
use kernel::{AppId, AppSlice, Callback, Driver, ReturnCode, Shared};
use kernel::common::take_cell::{MapCell, T... | code_fim | hard | {
"lang": "rust",
"repo": "frenicth/tock",
"path": "/capsules/src/spi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn command(&self, cmd_num: usize, arg1: usize, _: AppId) -> ReturnCode {
match cmd_num {
0 /* check if present */ => ReturnCode::SUCCESS,
// No longer supported, wrap inside a read_write_bytes
1 /* read_write_byte */ => ReturnCode::ENOSUPPORT,
2 ... | code_fim | hard | {
"lang": "rust",
"repo": "frenicth/tock",
"path": "/capsules/src/spi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>03::*;
#[cfg(feature = "package-2019-11")]
pub mod package_2019_11;
#[cfg(all(feature = "package-2019-11", not(feature = "no-default-tag")))]
pub use package_2019_11::*;<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/monitor/src/lib.rs
#![allow(clippy::module_inception)]
#![allow(cli... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/services/mgmt/monitor/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/monitor/src/lib.rs
#![allow(clippy::module_inception)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::ptr_arg)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::derive_parti<|fim_suffix|>03::*;
#[cfg(feature = "package-2019-11")]
pub mo... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/services/mgmt/monitor/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arogyad/Candle path: /nn/tests/linear_test.rs
#![allow(unused)]
use arrayfire::{constant, dim4, print, randn, Array};
use nn::linear::Linear;
use nn::model::Model;
use nn::tensor::Tensor;
<|fim_suffix|> let a = Tensor::new(constant(2., dim4!(200, 200, 1, 1)), None);
let b = Tensor::new(c... | code_fim | medium | {
"lang": "rust",
"repo": "arogyad/Candle",
"path": "/nn/tests/linear_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn linear_class() {
let data = Tensor::new(randn(dim4!(256, 256, 1, 1)), None);
let mut l = Linear::new(256, 128, false);
l.forward(&data);
l.backward();
}<|fim_prefix|>// repo: arogyad/Candle path: /nn/tests/linear_test.rs
#![allow(unused)]
use arrayfire::{constant, dim4, print, ... | code_fim | hard | {
"lang": "rust",
"repo": "arogyad/Candle",
"path": "/nn/tests/linear_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = Tensor::new(randn(dim4!(256, 256, 1, 1)), None);
let mut l = Linear::new(256, 128, false);
l.forward(&data);
l.backward();
}<|fim_prefix|>// repo: arogyad/Candle path: /nn/tests/linear_test.rs
#![allow(unused)]
use arrayfire::{constant, dim4, print, randn, Array};
use nn::linea... | code_fim | hard | {
"lang": "rust",
"repo": "arogyad/Candle",
"path": "/nn/tests/linear_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stuartlynn/geozero path: /geozero/src/svg/mod.rs
//! SVG conversions.
mod svg;
pub use svg::*;
pub(crate) mod conversion {
use super::svg::*;
use crate::error::Result;
use crate::FeatureProcessor;
use crate::{GeozeroDatasource, GeozeroGeometry};
/// Convert to SVG.
///... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/svg/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut svg_data: Vec<u8> = Vec::new();
let mut svg = SvgWriter::new(&mut svg_data, false);
// svg.set_dimensions(bbox.get(0), bbox.get(1), bbox.get(2), bbox.get(3), 800, 400);
svg.dataset_begin(None)?;
svg.feature_begin(0)?;
self.pro... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/svg/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl FromWkb for SvgString {
fn from_wkb<R: Read>(rdr: &mut R, dialect: WkbDialect) -> Result<Self> {
let mut svg_data: Vec<u8> = Vec::new();
let mut writer = SvgWriter::new(&mut svg_data, false);
crate::wkb::process_wkb_type_geom(rdr, &mut writer, dialect)?... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/svg/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: toolness/direct2d-rs path: /src/device/mod.rs
use crate::error::D2DResult;
use crate::factory::Factory1;
use std::ptr;
use com_wrapper::ComWrapper;
use dxgi::device::Device as DxgiDevice;
use winapi::shared::winerror::SUCCEEDED;
use winapi::um::d2d1_1::ID2D1Device;
use wio::com::ComPtr;
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "toolness/direct2d-rs",
"path": "/src/device/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub unsafe fn get_raw(&self) -> *mut ID2D1Device {
self.ptr.as_raw()
}
}
unsafe impl Send for Device {}
unsafe impl Sync for Device {}<|fim_prefix|>// repo: toolness/direct2d-rs path: /src/device/mod.rs
use crate::error::D2DResult;
use crate::factory::Factory1;
use std::pt... | code_fim | hard | {
"lang": "rust",
"repo": "toolness/direct2d-rs",
"path": "/src/device/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nyoho/RustDeAtCoder path: /ABC127_D/src/main.rs
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unknown_lints)]
#![allow(unused_variables)]
#![allow(unused_must_use)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_assignments)]
use std::cmp;
use std::collections::{HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "Nyoho/RustDeAtCoder",
"path": "/ABC127_D/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut a = a;
let mut max = 0;
for j in 0..m {
a.sort();
debug!(a);
let mut index: usize = 0;
let b = bc[j][0];
let c = bc[j][1];
for i in 0..b {
if c > a[i as usize] {
a[i as usize] = c;
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "Nyoho/RustDeAtCoder",
"path": "/ABC127_D/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Compile a Scheme program into a list of SVM cells (a control stack)
///
/// # Arguments
///
/// + `program` - a string containing a Scheme program or line
///
/// # Return Value
///
/// + A `Result` containing either a `List` of `SVMCells` if the program
/// was compiled successfully, or a `Strin... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/seax_scheme",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use seax::List;
use seax::cell::SVMCell;
use seax::compiler_tools::ForkTable;
use seax::compiler_tools::ast::ASTNode;
use std::iter::FromIterator;
/// Contains the Scheme abstract syntax tree (AST).
///
/// The AST stores the semantic structure of a parsed Scheme
/// program, and is responsible for com... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/seax_scheme",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawkw/seax_scheme path: /src/lib.rs
#![crate_name = "seax_scheme"]
#![unstable(feature="scheme")]
#![crate_type = "lib"]
#![feature(box_syntax,box_patterns)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(scheme, parser)]
#![staged_api]
//! Library for compiling Scheme programs ... | code_fim | hard | {
"lang": "rust",
"repo": "hawkw/seax_scheme",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0 as *mut wl_proxy;
id =
wl_proxy_marshal_constructor_versioned(wl_registry as *mut wl_proxy,
0i32 as uint32_t, interface,
version, name,
(*interface).n... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/examples/input_inhibitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoastVeg/wlrusts path: /src/examples/input_inhibitor.rs
ting an xdg_surface does not set the role for a wl_surface. In order
* to map an xdg_surface, the client must create a role-specific object
* using, e.g., get_toplevel, get_popup. The wl_surface for any given
* xdg_surface can have at mo... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/examples/input_inhibitor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoastVeg/wlrusts path: /src/examples/input_inhibitor.rs
: *mut wl_display) -> libc::c_int;
#[no_mangle]
fn wl_display_roundtrip(display: *mut wl_display) -> libc::c_int;
#[no_mangle]
static wl_registry_interface: wl_interface;
#[no_mangle]
static wl_compositor_interface: ... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/examples/input_inhibitor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mxjessie/exercism path: /rust/raindrops/src/lib.rs
pub fn raindrops(y: i32) -> String {
let mut answer = String::new();<|fim_suffix|>
if answer.is_empty() { answer = y.to_string(); }
return answer
}<|fim_middle|>
if y % 3 == 0 { answer.push_str("Pling"); }
if y % 5 == 0 { ans... | code_fim | medium | {
"lang": "rust",
"repo": "mxjessie/exercism",
"path": "/rust/raindrops/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>wer.push_str("Plang"); }
if y % 7 == 0 { answer.push_str("Plong"); }
if answer.is_empty() { answer = y.to_string(); }
return answer
}<|fim_prefix|>// repo: mxjessie/exercism path: /rust/raindrops/src/lib.rs
pub fn raindrops(y: i32) -> String {
let mut answer = String::new();<|fim_middle|>... | code_fim | medium | {
"lang": "rust",
"repo": "mxjessie/exercism",
"path": "/rust/raindrops/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
#[cfg(feature = "ext-a")]
pub fn atomic_sc(_p: &core::sync::atomic::AtomicU32, _val: u32) -> bool {
unreachable!()
}<|fim_prefix|>// repo: terminar/FlatRv path: /src/exec_generic.rs
#[inline(always)]
#[cfg(feature = "ext-a")]
pub fn atomic_is_supported() -> bool {
false
}
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "terminar/FlatRv",
"path": "/src/exec_generic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: terminar/FlatRv path: /src/exec_generic.rs
#[inline(always)]
#[cfg(feature = "ext-a")]
pub fn atomic_is_supported() -> bool {
false
}
<|fim_suffix|>#[inline(always)]
#[cfg(feature = "ext-a")]
pub fn atomic_sc(_p: &core::sync::atomic::AtomicU32, _val: u32) -> bool {
unreachable!()
}<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "terminar/FlatRv",
"path": "/src/exec_generic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> SubCommand::with_name("output")
.about("Displays the Terraform outputs for the target cluster")
.arg(
Arg::with_name("cluster")
.index(1)
.required(true)
.help("The cluster whose plan should be displayed")
)
.a... | code_fim | hard | {
"lang": "rust",
"repo": "smaftoul/kaws",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match cidr.subset_cmp(&vpc_cidr) {
Some(Ordering::Less) => {}
_ => return Err("Provided CIDR must be a subset of 10.0.0.0/16.".to_string()),
}
match cidr.subset_cmp(&elb_cidr) {
... | code_fim | hard | {
"lang": "rust",
"repo": "smaftoul/kaws",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smaftoul/kaws path: /src/cli.rs
.arg(
Arg::with_name("terraform-args")
.index(2)
.multiple(true)
.hidden(true)
.help("Additional arguments to be passed on to `terraform apply`")
)
.after_help("\nAny arg... | code_fim | hard | {
"lang": "rust",
"repo": "smaftoul/kaws",
"path": "/src/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let scattered = Ray::new(rec.p(), Vec3::new_random_in_unit_sphere(), r_in.time());
let attenuation = self.albedo.value(rec.u(), rec.v(), rec.p());
Some((attenuation, scattered))
}
}<|fim_prefix|>// repo: garethkcjones/rays path: /src/material/isotropic.rs
use super::Material;
... | code_fim | medium | {
"lang": "rust",
"repo": "garethkcjones/rays",
"path": "/src/material/isotropic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: garethkcjones/rays path: /src/material/isotropic.rs
use super::Material;
use crate::{Colour, HitRecord, Ray, Texture, Vec3};
use std::sync::Arc;
/**
* Type for materials that scatter randomly.
*/
#[derive(Debug)]
pub struct Isotropic {
albedo: Arc<dyn Texture>,
}
<|fim_suffix|> #[must... | code_fim | medium | {
"lang": "rust",
"repo": "garethkcjones/rays",
"path": "/src/material/isotropic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1aim/state_machine_future path: /src/transition.rs
/// Auxiliary macro for `poll_state_xy` functions to transition into a new state.
#[macro_export]
macro_<|fim_suffix|>rn Ok(::futures::Async::Ready($new_state.into())));
}<|fim_middle|>rules! transition {
( $new_state:expr ) => (retu | code_fim | easy | {
"lang": "rust",
"repo": "1aim/state_machine_future",
"path": "/src/transition.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rules! transition {
( $new_state:expr ) => (return Ok(::futures::Async::Ready($new_state.into())));
}<|fim_prefix|>// repo: 1aim/state_machine_future path: /src/transition.rs
/// Auxiliary macro for `poll_state_xy` functions to<|fim_middle|> transition into a new state.
#[macro_export]
macro_ | code_fim | easy | {
"lang": "rust",
"repo": "1aim/state_machine_future",
"path": "/src/transition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Twinklebear/ispc-rs path: /compile/src/opt.rs
//! This module has various option flags and configs we can pass to ISPC,
//! located here for convience and clutter reduction.
/// Different math libraries that ISPC can use for computations.
pub enum MathLib {
/// Use ispc's built-in math func... | code_fim | hard | {
"lang": "rust",
"repo": "Twinklebear/ispc-rs",
"path": "/compile/src/opt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
CPU::Generic => String::from("--cpu=generic"),
CPU::Bonnell => String::from("--cpu=bonnell"),
CPU::Core2 => String::from("--cpu=core2"),
CPU::Penryn => String::from("--cpu=penryn"),
CPU::Nehalem => String::from("--cpu=nehale... | code_fim | hard | {
"lang": "rust",
"repo": "Twinklebear/ispc-rs",
"path": "/compile/src/opt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Send + Sized> TypedMmap<T> {
/// Returns the length of the memory map
pub fn len(&self) -> usize {
self.mmap.len()
}
/// Checks if the memory map is empty
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
impl<T: Send + Sized> AsRef<T> for TypedMmap<T> ... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs-linux",
"path": "/core/src/shmem.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DLR-FT/a653rs-linux path: /core/src/shmem.rs
//! Implementation for shared memory
use std::marker::PhantomData;
use std::mem::size_of;
use anyhow::anyhow;
use memmap2::{Mmap, MmapMut};
use crate::error::{ResultExt, SystemError, TypedError, TypedResult};
#[derive(Debug)]
/// Internal data type... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs-linux",
"path": "/core/src/shmem.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
/// Internal data type for a mutable typed memory map
pub struct TypedMmap<T: Send + Sized> {
mmap: Mmap,
_p: PhantomData<T>,
}
impl<T: Send + Sized> TypedMmap<T> {
/// Returns the length of the memory map
pub fn len(&self) -> usize {
self.mmap.len()
}
//... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs-linux",
"path": "/core/src/shmem.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> quote!(
#types
type AllModules = ( #all_modules );
)
}
fn decl_pallet_runtime_setup(
module_declarations: &[Module],
scrate: &TokenStream2,
) -> TokenStream2 {
let names = module_declarations.iter().map(|d| &d.name);
let names2 = module_declarations.iter().map(|d| &d.name);
let name_strings = ... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-core",
"path": "/frame/support/procedural/src/construct_runtime/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IPSE-TEAM/ipse-core path: /frame/support/procedural/src/construct_runtime/mod.rs
// This file is part of Substrate.
// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not ... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-core",
"path": "/frame/support/procedural/src/construct_runtime/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn decl_all_modules<'a>(
runtime: &'a Ident,
module_declarations: impl Iterator<Item = &'a Module>,
) -> TokenStream2 {
let mut types = TokenStream2::new();
let mut names = Vec::new();
for module_declaration in module_declarations {
let type_name = &module_declaration.name;
let module = &module_d... | code_fim | hard | {
"lang": "rust",
"repo": "IPSE-TEAM/ipse-core",
"path": "/frame/support/procedural/src/construct_runtime/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let elapsed = time.elapsed();
64.0 / (elapsed.as_secs() as f64 + elapsed.subsec_nanos() as f64 / 1_000_000_000.0)
},
total_time: time.elapsed(),
points: 0, // TODO
}
}
}
#[derive(Clone)]
struct Rehasher<H: Clone> {
hashe... | code_fim | hard | {
"lang": "rust",
"repo": "ticki/trhasher",
"path": "/src/inspect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> a == b && b == c && c == d && d == e
},
gb_per_sec: {
let time = time::Instant::now();
let mut hasher = builder.build_hasher();
for i in 0..1000000000 / 8 {
hasher.write_u64(i);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ticki/trhasher",
"path": "/src/inspect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ticki/trhasher path: /src/inspect.rs
use std::hash::{Hasher, BuildHasher};
use std::{time, iter, fmt};
use {rng, data, test, stream, analysis};
pub struct Test {
dict: stream::Transforms,
rand: stream::Transforms,
ascii: stream::Transforms,
bad_rand: stream::Transforms,
num... | code_fim | hard | {
"lang": "rust",
"repo": "ticki/trhasher",
"path": "/src/inspect.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(vec![1, 3, 5, 7, 9], list_comprehension(1, 10, 2))
}
#[test]
fn test02() {
assert_eq!(vec![10, 8, 6, 4, 2, 0], list_comprehension(11, 0, 2))
}
}<|fim_prefix|>// repo: endygamedev/rust_algorithms path: /src/structures/list_comprehension.rs
/// Create a list of n... | code_fim | medium | {
"lang": "rust",
"repo": "endygamedev/rust_algorithms",
"path": "/src/structures/list_comprehension.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: endygamedev/rust_algorithms path: /src/structures/list_comprehension.rs
/// Create a list of numbers from _start_ to _stop_ with _step_
/// TODO: Edit case with reverse list
pub fn list_comprehension(start: isize, stop: isize, step: isize) -> Vec<isize> {
return if start < stop {
(st... | code_fim | medium | {
"lang": "rust",
"repo": "endygamedev/rust_algorithms",
"path": "/src/structures/list_comprehension.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test01() {
assert_eq!(vec![1, 3, 5, 7, 9], list_comprehension(1, 10, 2))
}
#[test]
fn test02() {
assert_eq!(vec![10, 8, 6, 4, 2, 0], list_comprehension(11, 0, 2))
}
}<|fim_prefix|>// repo: endygamedev/rust_algorithms path: /src/structures/list_comprehen... | code_fim | medium | {
"lang": "rust",
"repo": "endygamedev/rust_algorithms",
"path": "/src/structures/list_comprehension.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phubbard67/rustadio path: /src/mapgen/track.rs
use mp3_duration;
use std::path::{Path, PathBuf};
use std::time::Duration;
#[derive(Serialize, Deserialize, Clone)]
pub struct Track {
pub path: Option<PathBuf>,
pub title: String,
pub album: String,
pub artist: String,
pub genr... | code_fim | hard | {
"lang": "rust",
"repo": "phubbard67/rustadio",
"path": "/src/mapgen/track.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Track {
pub fn new<P: AsRef<Path>>(file_path: P) -> Track {
match id3::Tag::read_from_path(file_path.as_ref()) {
Ok(file) => Track {
path: Some(file_path.as_ref().to_owned()),
title: file.title().unwrap_or("Unkown").to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "phubbard67/rustadio",
"path": "/src/mapgen/track.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NajmusSaqib/rustgym path: /leetcode/src/d20/mod.rs
//
mod _2000_reverse_prefix_of_word;
//
mod _2006_count_number<|fim_suffix|>ay_into_2d_array;
//
mod _2027_minimum_moves_to_convert_string;<|fim_middle|>_of_pairs_with_absolute_difference_k;
//
mod _2016_maximum_difference_between_increasing_ele... | code_fim | medium | {
"lang": "rust",
"repo": "NajmusSaqib/rustgym",
"path": "/leetcode/src/d20/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ay_into_2d_array;
//
mod _2027_minimum_moves_to_convert_string;<|fim_prefix|>// repo: NajmusSaqib/rustgym path: /leetcode/src/d20/mod.rs
//
mod _2000_reverse_prefix_of_word;
//
mod _2006_count_number<|fim_middle|>_of_pairs_with_absolute_difference_k;
//
mod _2016_maximum_difference_between_increasing_ele... | code_fim | medium | {
"lang": "rust",
"repo": "NajmusSaqib/rustgym",
"path": "/leetcode/src/d20/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for c in 0..16 {
let mut known = Vec::new();
for _ in 0..(15 - c){
known.push(32); // Fill with spaces
}
let mut dict = Vec::new();
for asc in 0..255 {
let mut try_: Vec<u8> = Vec::new();
for k in &known {
tr... | code_fim | hard | {
"lang": "rust",
"repo": "c0ding/rysto",
"path": "/src/set2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c0ding/rysto path: /src/set2.rs
extern crate base64;
use ascii::AsciiStr;
use rand::prelude::*;
use super::util;
fn add_padding(content: String, block_len: usize) -> String {
let mut out = content.clone();
let rem = content.len() % block_len;
if rem != 0 {
let pad_size = ... | code_fim | hard | {
"lang": "rust",
"repo": "c0ding/rysto",
"path": "/src/set2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dict.push((asc, tmp_cyph[15]));
}
let mut joint: Vec<u8> = Vec::new();
for c in known {
joint.push(c);
}
for c in &cypher {
joint.push(*c);
}
let test_enc = util::encrypt_ecb(joint, key.to_vec());
for (a... | code_fim | hard | {
"lang": "rust",
"repo": "c0ding/rysto",
"path": "/src/set2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !moving_beyond_first && !moving_beyond_last {
self.cursor_y = ((self.cursor_y as i64) + y) as usize;
}
let length_of_line =
UnicodeSegmentation::graphemes(self.lines[self.cursor_y].as_str(), true).count();
if length_of_line == 0 {
sel... | code_fim | hard | {
"lang": "rust",
"repo": "tato/untitled-unmastered",
"path": "/src/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tato/untitled-unmastered path: /src/buffer.rs
use crate::{min, UnicodeSegmentation, editor::Mode};
#[derive(Debug, Clone, Copy)]
pub enum LineSeparatorFormat {
UNIX,
DOS,
}
impl LineSeparatorFormat {
pub fn separator(&self) -> &'static str {
match self {
LineSepar... | code_fim | hard | {
"lang": "rust",
"repo": "tato/untitled-unmastered",
"path": "/src/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phala-Network/phala-blockchain path: /vendor/ring/src/ec/suite_b/curve.rs
// Copyright 2015-2017 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this perm... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/ring/src/ec/suite_b/curve.rs",
"mode": "psm",
"license": "OpenSSL",
"source": "the-stack-v2"
} |
<|fim_suffix|> rng: &dyn rand::SecureRandom,
out: &mut [u8],
) -> Result<(), error::Unspecified> {
ec::suite_b::private_key::generate_private_scalar_bytes($private_key_ops, rng, out)
}
fn $public_from_private(
public_out: &mut [u8],
pri... | code_fim | hard | {
"lang": "rust",
"repo": "Phala-Network/phala-blockchain",
"path": "/vendor/ring/src/ec/suite_b/curve.rs",
"mode": "spm",
"license": "OpenSSL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aalekhpatel07/ggpo-rs path: /ggpo/src/ggpo.rs
use crate::{
backends::p2p::Peer2PeerError,
game_input::{Frame, FrameNum, InputBuffer},
network::udp_proto::UdpProtoError,
player::{Player, PlayerHandle},
sync::SyncError,
};
use bytes::Bytes;
use std::time::Duration;
// use log::... | code_fim | hard | {
"lang": "rust",
"repo": "aalekhpatel07/ggpo-rs",
"path": "/ggpo/src/ggpo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/*
* free_buffer - Frees a game state allocated in save_game_state. You
* should deallocate the memory contained in the buffer.
*/
fn free_buffer(&mut self, buffer: &Bytes);
/*
* advance_frame - Called during a rollback. You should advance your game
* state by exac... | code_fim | hard | {
"lang": "rust",
"repo": "aalekhpatel07/ggpo-rs",
"path": "/ggpo/src/ggpo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: serbe/prui path: /src/handlers.rs
use actix_web::{web, Error, HttpResponse};
use futures::Future;
use r2d2::Pool;
use r2d2_postgres::PostgresConnectionManager;
use serde_json::json;
<|fim_suffix|>pub fn get_num(
// id: Identity,
db: web::Data<Pool<PostgresConnectionManager>>,
path: ... | code_fim | medium | {
"lang": "rust",
"repo": "serbe/prui",
"path": "/src/handlers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_num(
// id: Identity,
db: web::Data<Pool<PostgresConnectionManager>>,
path: web::Path<(String, i64)>,
) -> impl Future<Item = HttpResponse, Error = Error> {
// let a = check_auth(id);
web::block(move || {
// a?;
let conn = db.get().unwrap();
match pat... | code_fim | medium | {
"lang": "rust",
"repo": "serbe/prui",
"path": "/src/handlers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teuron/rust-graphic-lib path: /src/main.rs
extern crate graphic_library;
extern crate raster;
use raster::Color;
use std::cell::RefCell;
use std::rc::Rc;
use graphic_library::geometric::Point2D;
//use graphic_library::geometric::Triangle2D;
use graphic_library::geometric::Circle2D;
use graphic_... | code_fim | hard | {
"lang": "rust",
"repo": "teuron/rust-graphic-lib",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // triangle.rotate_from_point(1.0, ¢er);
// let mut r = Renderer::new(1000, 1000);
// r.add(&triangle);
r.draw();
c.borrow_mut().transform(100.0, 100.0);
r.draw();
r.save_as("nice_out2.png".to_owned());
// }
let elapsed = now.elapsed();
let sec ... | code_fim | hard | {
"lang": "rust",
"repo": "teuron/rust-graphic-lib",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: victor-zed/tink-rust path: /core/src/keyset/reader.rs
// Copyright 2020 The Tink-Rust Authors
//
// 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... | code_fim | hard | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/core/src/keyset/reader.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `Reader` knows how to read a [`Keyset`](tink_proto::Keyset) or an
/// [`EncryptedKeyset`](tink_proto::EncryptedKeyset) from some source. In order to turn a `Reader`
/// into a [`keyset::Handle`](crate::keyset::Handle) for use, callers must use
/// [`insecure::new_handle`](super::insecure::new_handle) ... | code_fim | medium | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/core/src/keyset/reader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arr: [u8; 4] = [0x11, 0x22, 0x33, 0x44];
assert_eq!(unsafe { transmute_u64s(arr) }, vec![0x44332211]);
let arr: [u8; 5] = [0x11, 0x22, 0x33, 0x44, 0x55];
assert_eq!(unsafe { transmute_u64s(arr) }, vec![0x5544332211]);
let arr: [u8; 6] = [0x11, 0x22, 0x33, 0x44... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie-ptrace/src/stack.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasonwhite/reverie path: /reverie-ptrace/src/stack.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::sync::atomic... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie-ptrace/src/stack.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arr: [u8; 1] = [0x11];
assert_eq!(unsafe { transmute_u64s(arr) }, vec![0x11]);
let arr: [u8; 2] = [0x11, 0x22];
assert_eq!(unsafe { transmute_u64s(arr) }, vec![0x2211]);
let arr: [u8; 3] = [0x11, 0x22, 0x33];
assert_eq!(unsafe { transmute_u64s(arr) }, ... | code_fim | hard | {
"lang": "rust",
"repo": "jasonwhite/reverie",
"path": "/reverie-ptrace/src/stack.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/google_interview_daily_problems/Day8_Student_Attendance_Record_I.rs
// https://leetcode.com/problems/student-attendance-record-i/
pub struct Solution;
impl Solution {
pub fn check_record(s: String) -> bool {
let... | code_fim | hard | {
"lang": "rust",
"repo": "y-usuzumi/survive-the-course",
"path": "/survive-the-course-rs/src/problems/google_interview_daily_problems/Day8_Student_Attendance_Record_I.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(Solution::check_record("PPALLP".into()));
}
#[test]
fn test_2() {
assert!(!Solution::check_record("PPALLL".into()));
}
}<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/google_interview_daily_problems/Day8_Student_Atten... | code_fim | hard | {
"lang": "rust",
"repo": "y-usuzumi/survive-the-course",
"path": "/survive-the-course-rs/src/problems/google_interview_daily_problems/Day8_Student_Attendance_Record_I.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Example 1
{
let b: i32 = 222;
let wrapper; // ---+ wrapper life start from here
let c: i32 = 333;
{
let a: i32 = 111; // -+ a goes into scope
wrapper = I32Wrapper { x: &b } // Borrow checker error will occur if a or c are used
} /... | code_fim | medium | {
"lang": "rust",
"repo": "ggoranov/rust_snippets",
"path": "/src/snippets/memory_safety/lifetime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ggoranov/rust_snippets path: /src/snippets/memory_safety/lifetime.rs
// This struct needs to keep an immuatable reference to i32 value
// During the lifetime of an instance of I32Wrapper we need to ensure that
// the reference it points at will also be 'alive' otherwise we can have
// a dangling... | code_fim | hard | {
"lang": "rust",
"repo": "ggoranov/rust_snippets",
"path": "/src/snippets/memory_safety/lifetime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// Example 1
{
let b: i32 = 222;
let wrapper; // ---+ wrapper life start from here
let c: i32 = 333;
{
let a: i32 = 111; // -+ a goes into scope
wrapper = I32Wrapper { x: &b } // Borrow checker error will occur if a or c are used... | code_fim | medium | {
"lang": "rust",
"repo": "ggoranov/rust_snippets",
"path": "/src/snippets/memory_safety/lifetime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a: A<T> = A { begin: 0, end: 3 };
let mut cycle: Cycle<A<T>> = a.cycle();
for _ in 0..10 {
for x in 0..3 {
let y: Option<T> = cycle.next();
match y {
Some(v) => { assert_eq!(v, x); }
None => { assert!(false); }
}
}
}
assert_eq!(cycle.next().is_none(), false);
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/iter/trait_Iterator/cycle.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick68/rust-trace path: /libcore/iter/trait_Iterator/cycle.rs
#![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Cycle;
use core::clone::Clone;
<|fim_suffix|> A {
begin: self.begin,
end: self.end
}
}
}
mac... | code_fim | medium | {
"lang": "rust",
"repo": "rick68/rust-trace",
"path": "/libcore/iter/trait_Iterator/cycle.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbradaric/advent-of-code-2019 path: /day_14/src/main.rs
use std::collections::HashMap;
#[derive(Debug)]
struct Ingredient<'a> {
pub name: &'a str,
pub quantity: usize,
}
impl<'a> Ingredient<'a> {
fn parse(spec: &'a str) -> Self {
let parts: Vec<_> = spec.split_ascii_whitesp... | code_fim | medium | {
"lang": "rust",
"repo": "jbradaric/advent-of-code-2019",
"path": "/day_14/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Reaction<'a> {
fn parse(line: &'a str) -> Self {
let parts: Vec<_> = line.split_terminator("=>").collect();
if parts.len() != 2 {
panic!("Unknown material: {}", line);
}
let input = parts[0].trim().split(',').map(Ingredient::parse).collect();
... | code_fim | medium | {
"lang": "rust",
"repo": "jbradaric/advent-of-code-2019",
"path": "/day_14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kristopherjohnson/tscp-rust path: /src/search.rs
// search.rs
// Tom Kerrigan's Simple Chess Program (TSCP)
//
// Copyright 1997 Tom Kerrigan
//
// Rust port by Kristopher Johnson
use super::board;
use super::book;
use super::data::Data;
use super::defs::{Int, Move, HIST_STACK, MAX_PLY};
use su... | code_fim | hard | {
"lang": "rust",
"repo": "kristopherjohnson/tscp-rust",
"path": "/src/search.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn sort_pv(d: &mut Data) {
d.follow_pv = false;
for i in d.first_move[d.ply]..d.first_move[d.ply + 1] {
if d.gen_dat[i].m.value() == d.pv[0][d.ply].value() {
d.follow_pv = true;
d.gen_dat[i].score += 10_000_000;
return;
}
}
}
/// sort() sear... | code_fim | hard | {
"lang": "rust",
"repo": "kristopherjohnson/tscp-rust",
"path": "/src/search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ur0/rust-asn1 path: /src/utils.rs
use std::{mem};
use num::{BigInt, One, Signed};
use num::bigint::{Sign};
use deserializer::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ObjectIdentifier {
pub parts: Vec<u32>
}
impl ObjectIdentifier {
... | code_fim | hard | {
"lang": "rust",
"repo": "ur0/rust-asn1",
"path": "/src/utils.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(ObjectIdentifier::new(vec![]).is_none());
assert!(ObjectIdentifier::new(vec![3, 10]).is_none());
assert!(ObjectIdentifier::new(vec![1, 50]).is_none());
}
#[test]
fn test_bit_string_new() {
assert!(BitString::new(b"".to_vec(), 1).is_none());
asse... | code_fim | hard | {
"lang": "rust",
"repo": "ur0/rust-asn1",
"path": "/src/utils.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if symcc_job_cnt > 0 {
// SYMCC expects working directories of AFL++ to exist, thus
// we give AFL++ some time to spin up.
let duration = Duration::from_secs(30);
log::info!(
"Waiting {:?} for AFL++ workers to spin up, thus SYMCC can ... | code_fim | hard | {
"lang": "rust",
"repo": "fuzztruction/fuzztruction",
"path": "/scheduler/src/aflpp/aflpp_core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fuzztruction/fuzztruction path: /scheduler/src/aflpp/aflpp_core.rs
let env = self.prepare_env();
cmd.envs(env);
cmd.args([
"-i",
seed_dir.to_str().unwrap(),
"-o",
workdir.to_str().unwrap(),
]);
let id = match work... | code_fim | hard | {
"lang": "rust",
"repo": "fuzztruction/fuzztruction",
"path": "/scheduler/src/aflpp/aflpp_core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..afl_workers {
let worker_id = match i {
0 => WorkerId::AflMaster,
n => WorkerId::AflSlave(n),
};
log::info!("Starting AFL worker {:?}", worker_id);
let worker = AflPlusPlusWorker::new(self.config.clone(), ... | code_fim | hard | {
"lang": "rust",
"repo": "fuzztruction/fuzztruction",
"path": "/scheduler/src/aflpp/aflpp_core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn entity_id(&self) -> usize;
fn as_any(&self) -> &Any;
fn as_any_mut(&mut self) -> &mut Any;
}<|fim_prefix|>// repo: zhaoterryy/estrelas path: /src/core/engine_types/game_framework/component.rs
use std::any::Any;
pub trait Component {
fn name(&self) -> &'static str;
fn guid(&self) -... | code_fim | easy | {
"lang": "rust",
"repo": "zhaoterryy/estrelas",
"path": "/src/core/engine_types/game_framework/component.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn as_any_mut(&mut self) -> &mut Any;
}<|fim_prefix|>// repo: zhaoterryy/estrelas path: /src/core/engine_types/game_framework/component.rs
use std::any::Any;
pub trait Component {
fn name(&self) -> &'static str;
fn guid(&self) -> usize;
fn component_id(&self) -> u64;
fn entity_id(&se... | code_fim | easy | {
"lang": "rust",
"repo": "zhaoterryy/estrelas",
"path": "/src/core/engine_types/game_framework/component.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhaoterryy/estrelas path: /src/core/engine_types/game_framework/component.rs
use std::any::Any;
pub trait Component {
fn name(&self) -> &'static str;
<|fim_suffix|> fn as_any(&self) -> &Any;
fn as_any_mut(&mut self) -> &mut Any;
}<|fim_middle|> fn guid(&self) -> usize;
fn comp... | code_fim | medium | {
"lang": "rust",
"repo": "zhaoterryy/estrelas",
"path": "/src/core/engine_types/game_framework/component.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecafkoob/ockam path: /implementations/rust/ockam/ockam_examples/WIP/IOT/ARM/nRF52840/src/main.rs
#![feature(default_alloc_error_handler)]
#![no_main]
#![no_std]
use log::LevelFilter;
mod rttlogger;
use alloc_cortex_m::CortexMHeap;
use rtt_target::rtt_init_print;
use panic_rtt_target as _;
//... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_examples/WIP/IOT/ARM/nRF52840/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Force a backtrace on exit
pub fn exit() -> ! {
log::info!(" ~ 👋 ~ ");
core::sync::atomic::compiler_fence(Ordering::SeqCst);
loop {
asm::bkpt()
}
}
static OVERFLOWS: AtomicU32 = AtomicU32::new(0);
static TICKS: AtomicU32 = AtomicU32::new(0);
#[interrupt]
fn RTC0() {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "ecafkoob/ockam",
"path": "/implementations/rust/ockam/ockam_examples/WIP/IOT/ARM/nRF52840/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobismijnnaam/advent-of-code path: /2019/day19/src/main.rs
mod util;
use util::intcode::*;
use itertools::Itertools;
use nalgebra::Vector2;
use std::convert::TryInto;
use std::collections::HashMap;
struct Drone {
cpu: IntcodeCPU,
width_cache: HashMap<i64, i64>,
height_cache: HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "bobismijnnaam/advent-of-code",
"path": "/2019/day19/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = None;
for y in 686.. {
let tractor_width = drone.tractor_width_c(y);
println!("y: {}, width: {}", y, tractor_width);
if tractor_width < santa_side {
continue;
}
let start_x = drone.tractor_start_x_c(y);
for x in start_... | code_fim | hard | {
"lang": "rust",
"repo": "bobismijnnaam/advent-of-code",
"path": "/2019/day19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("y: {}, width: {}", y, tractor_width);
if tractor_width < santa_side {
continue;
}
let start_x = drone.tractor_start_x_c(y);
for x in start_x..start_x + tractor_width {
let start_y = drone.tractor_start_y_c(x);
let tra... | code_fim | hard | {
"lang": "rust",
"repo": "bobismijnnaam/advent-of-code",
"path": "/2019/day19/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jawline/rust-neural-network path: /src/neuron.rs
use rand;
use rand::Rng;
use steps::StepFn;
#[derive(Clone, RustcDecodable, RustcEncodable)]
pub struct Neuron {
pub weights: Vec<f64>,
pub bias: f64,
pub output: f64,
pub inputs: Vec<f64>
}
impl Neuron {
pub fn new(weights: Vec<f64>, bias:... | code_fim | hard | {
"lang": "rust",
"repo": "jawline/rust-neural-network",
"path": "/src/neuron.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn random(num_inputs: usize) -> Neuron {
let mut rng = rand::thread_rng();
Neuron::new((0..num_inputs).map(|_| rng.gen::<f64>().abs()).collect(), rng.gen::<f64>())
}
}<|fim_prefix|>// repo: jawline/rust-neural-network path: /src/neuron.rs
use rand;
use rand::Rng;
use steps::StepFn;
#[derive(Cl... | code_fim | hard | {
"lang": "rust",
"repo": "jawline/rust-neural-network",
"path": "/src/neuron.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.