text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> assert_eq!(outputs.len(), 2);
assert_eq!(
outputs[0],
" Le rapide renard brun saute sur le chien paresseux"
);
assert_eq!(outputs[1], " Le chien ne s'est pas réveillé");
Ok(())
}
#[test]
// #[cfg_attr(not(feature = "all-tests"), ignore)]
fn test_translation_builder() ... | code_fim | hard | {
"lang": "rust",
"repo": "guillaume-be/rust-bert",
"path": "/tests/marian.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guillaume-be/rust-bert path: /tests/marian.rs
use rust_bert::marian::{
MarianConfigResources, MarianModelResources, MarianSourceLanguages, MarianSpmResources,
MarianTargetLanguages, MarianVocabResources,
};
use rust_bert::pipelines::common::{ModelResource, ModelType};
use rust_bert::pipe... | code_fim | hard | {
"lang": "rust",
"repo": "guillaume-be/rust-bert",
"path": "/tests/marian.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
impl ObjectBuilder{
pub fn new() -> ObjectBuilder{
let default_model = "./assets/models/cube.obj".to_string();
let default_texture = "./assets/textures/spaceship_cockpit.png".to_string();
ObjectBuilder{
model: default_model,
texture: ... | code_fim | hard | {
"lang": "rust",
"repo": "TheHellBox/Sorption-Space-Sim",
"path": "/src/render/object.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheHellBox/Sorption-Space-Sim path: /src/render/object.rs
use support;
use glium::texture::Texture2d;
use nalgebra::geometry::{Quaternion, Point3};
use nalgebra::core::{Vector3, Matrix4};
use glium::vertex::VertexBufferAny;
use support::math;
use render::Window;
// Object that can be rendered
p... | code_fim | hard | {
"lang": "rust",
"repo": "TheHellBox/Sorption-Space-Sim",
"path": "/src/render/object.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_shader(self, shader: String) -> Self{
ObjectBuilder{
shader,
..self
}
}
pub fn with_texture(self, texture: String) -> Self{
ObjectBuilder{
texture,
..self
}
}
pub fn with_model(self, model: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "TheHellBox/Sorption-Space-Sim",
"path": "/src/render/object.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cryptape/rust-numext path: /constructor/src/fixed_uint/core/builtin/mod.rs
// Copyright 2018-2019 Cryptape Technologies LLC.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensou... | code_fim | medium | {
"lang": "rust",
"repo": "cryptape/rust-numext",
"path": "/constructor/src/fixed_uint/core/builtin/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod as_primitive;
mod std_cmp;
mod std_convert;
mod std_default;
mod std_fmt;
mod std_hash;
mod std_iter;
mod std_ops;
mod std_str;<|fim_prefix|>// repo: cryptape/rust-numext path: /constructor/src/fixed_uint/core/builtin/mod.rs
// Copyright 2018-2019 Cryptape Technologies LLC.
//
// Licensed under the ... | code_fim | medium | {
"lang": "rust",
"repo": "cryptape/rust-numext",
"path": "/constructor/src/fixed_uint/core/builtin/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rcc = dp.RCC.constrain();
let mut flash = dp.FLASH.constrain();
let clocks = rcc.cfgr.sysclk(16.mhz()).freeze(&mut flash.acr);
let gpioe = dp.GPIOE.split(&mut rcc.ahb);
let mut leds = DiscoLeds::new(gpioe);
let mut delay = hal::delay::Delay::new(cp.SYST, clocks);
for ... | code_fim | medium | {
"lang": "rust",
"repo": "kesyog/dead-disco",
"path": "/examples/led_roulette.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kesyog/dead-disco path: /examples/led_roulette.rs
#![no_std]
#![no_main]
/// LED roulette example. Turns on the compass LED's in sequence with some overlap.
use core::iter::Iterator;
use cortex_m_rt::entry;
use dead_disco::leds::DiscoLeds;
use hal::{prelude::*, stm32 as pac};
use panic_halt as _... | code_fim | medium | {
"lang": "rust",
"repo": "kesyog/dead-disco",
"path": "/examples/led_roulette.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let gpioe = dp.GPIOE.split(&mut rcc.ahb);
let mut leds = DiscoLeds::new(gpioe);
let mut delay = hal::delay::Delay::new(cp.SYST, clocks);
for current_idx in (0..8).cycle() {
let prev_idx = if current_idx == 0 { 7 } else { current_idx - 1 };
leds[current_idx].set_high().ok()... | code_fim | hard | {
"lang": "rust",
"repo": "kesyog/dead-disco",
"path": "/examples/led_roulette.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/dma/dma_tcd_biter_elinkyes.rs
#[doc = "Register `TCD%s_BITER_ELINKYES` reader"]
pub struct R(crate::R<DMA_TCD_BITER_ELINKYES_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DMA_TCD_BITER_ELINKYES_SPEC>;
#[inline(always)]
fn deref(&self) -... | code_fim | hard | {
"lang": "rust",
"repo": "sindrehan/mkl82z7-pac",
"path": "/src/dma/dma_tcd_biter_elinkyes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Field `ELINK` reader - Enables channel-to-channel linking on minor loop complete"]
pub struct ELINK_R(crate::FieldReader<bool, ELINK_A>);
impl ELINK_R {
pub(crate) fn new(bits: bool) -> Self {
ELINK_R(crate::FieldReader::new(bits))
}
#[doc = ... | code_fim | hard | {
"lang": "rust",
"repo": "sindrehan/mkl82z7-pac",
"path": "/src/dma/dma_tcd_biter_elinkyes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hoppy0616/binarysearch path: /src/main.rs
use std::io;
use std::convert::TryInto;
fn main() {
let a = [5,8,12,15,17,23,38,41,62,91];
let mut number = String::new();
let (mut pos,mut left,mut right) = (-1isize,0isize,9i<|fim_suffix|>ight){
middle = (left + right) as usize / 2;... | code_fim | medium | {
"lang": "rust",
"repo": "Hoppy0616/binarysearch",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> right = (middle - 1 as usize).try_into().unwrap();
}
else {
left = (middle + 1 as usize).try_into().unwrap();
}
}
print!("pos = {}",pos);
}<|fim_prefix|>// repo: Hoppy0616/binarysearch path: /src/main.rs
use std::io;
use std::convert::TryInto;
fn main() {... | code_fim | medium | {
"lang": "rust",
"repo": "Hoppy0616/binarysearch",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//mod accounts;
mod generic;
mod accounts;
mod traits;
mod account_db;
pub use accounts::{FVMAccount, AVMAccount};<|fim_prefix|>// repo: aion-camus/aion_utils path: /accounts/src/lib.rs
extern crate acore_bytes as bytes;
/// this is a standalone account model for Aion Blockchain
///
extern crate aion_ty... | code_fim | medium | {
"lang": "rust",
"repo": "aion-camus/aion_utils",
"path": "/accounts/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aion-camus/aion_utils path: /accounts/src/lib.rs
extern crate acore_bytes as bytes;
/// this is a standalone account model for Aion Blockchain
///
extern crate aion_types;
extern crate lru_cache;
<|fim_suffix|>//mod accounts;
mod generic;
mod accounts;
mod traits;
mod account_db;
pub use accou... | code_fim | medium | {
"lang": "rust",
"repo": "aion-camus/aion_utils",
"path": "/accounts/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luser/dwarfinspect path: /src/lib.rs
= path.as_ref();
let f = File::open(path)?;
let buf = unsafe { memmap::Mmap::map(&f)? };
let obj = object::File::parse(&*buf)
.map_err(|e| format_err!("Failed to parse file {:?}: {}", path, e))?;
func(&obj)
}
use cursive_table_view::{... | code_fim | hard | {
"lang": "rust",
"repo": "luser/dwarfinspect",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> w: &mut W,
attr: &gimli::Attribute<R>,
unit: &Unit<R>,
debug_str: &gimli::DebugStr<R>,
//loclists: &gimli::LocationLists<R>,
//rnglists: &gimli::RangeLists<R>,
) -> Result<(), Error>
where R: Reader,
W: Write,
{
let value = attr.value();
match value {
... | code_fim | hard | {
"lang": "rust",
"repo": "luser/dwarfinspect",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luser/dwarfinspect path: /src/lib.rs
match column {
DieColumn::Offset => self.offset.cmp(&other.offset),
DieColumn::Tag => self.tag.0.cmp(&other.tag.0),
DieColumn::Name => self.name.cmp(&other.name),
}
}
}
struct Unit<R: Reader> {
end... | code_fim | hard | {
"lang": "rust",
"repo": "luser/dwarfinspect",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> auto val = 0u;
auto sz = size; // FIXME: trans::ml bug workaround
while (sz > 0u) {
sz -= 1u;
val += (rdr.read_byte() as uint) << sz * 8u;
}
ret val;
}
fn read_whole_stream() -> vec[u8] {
let vec[u8] buf = [];
while (... | code_fim | hard | {
"lang": "rust",
"repo": "sayrer/rust",
"path": "/src/lib/io.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sayrer/rust path: /src/lib/io.rs
import os::libc;
native "rust" mod rustrt {
fn rust_get_stdin() -> os::libc::FILE;
fn rust_get_stdout() -> os::libc::FILE;
}
// Reading
// FIXME This is all buffered. We might need an unbuffered variant as well
tag seek_style { seek_set; seek_end; se... | code_fim | hard | {
"lang": "rust",
"repo": "sayrer/rust",
"path": "/src/lib/io.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: defcon201/SafeTrace path: /enclave/safetrace/app/src/keys_u.rs
use crate::common_u::errors::EnclaveFailError;
use failure::Error;
use sgx_types::{sgx_enclave_id_t, sgx_status_t};
use enigma_types::{EnclaveReturn};
extern {
pub fn ecall_get_user_key(
eid: sgx_enclave_id_t,
r... | code_fim | hard | {
"lang": "rust",
"repo": "defcon201/SafeTrace",
"path": "/enclave/safetrace/app/src/keys_u.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = unsafe {
ecall_get_user_key(eid, &mut ret as *mut EnclaveReturn, &mut sig, user_pubkey.as_ptr() as _, &mut serialized_ptr as *mut u64)
};
if ret != EnclaveReturn::Success || status != sgx_status_t::SGX_SUCCESS {
return Err(EnclaveFailError { err: ret, status }.into... | code_fim | hard | {
"lang": "rust",
"repo": "defcon201/SafeTrace",
"path": "/enclave/safetrace/app/src/keys_u.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// # Safety
///
/// Requires that you ensure the reference does not become invalid.
/// The object has to outlive the reference.
#[inline(always)]
pub unsafe fn change_lifetime_mut<'a, 'b, T>(x: &'a mut T) -> &'b mut T {
&mut *(x as *mut T)
}
/// # Safety
///
/// Make a immutable ref mutable.
/// No... | code_fim | hard | {
"lang": "rust",
"repo": "Danappelxx/dashmap",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Danappelxx/dashmap path: /src/util.rs
//! This module is full of hackery and dark magic.
//! Either spend a day fixing it and quietly submit a PR or don't mention it to anybody.
use core::{mem, ptr};
#[inline(always)]
pub const fn ptr_size_bits() -> usize {
mem::size_of::<usize>() * 8
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "Danappelxx/dashmap",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k0pernicus/orbutils path: /src/terminal/main.rs
extern crate orbclient;
use orbclient::Color;
use std::env;
use std::io::{Read, Write};
use std::process::{Command, Stdio};
use std::sync::{Arc, Mutex};
use std::thread;
use window::{ConsoleEvent, ConsoleWindow};
mod window;
fn main() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "k0pernicus/orbutils",
"path": "/src/terminal/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for console_event in window.read() {
match console_event {
ConsoleEvent::Line(mut line) => {
line.push('\n');
match stdin.write(&line.as_bytes()) {
Ok(_) => (... | code_fim | hard | {
"lang": "rust",
"repo": "k0pernicus/orbutils",
"path": "/src/terminal/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GiregL/blastracer path: /src/objects/plane.rs
use crate::maths::vector3f::Vector3f;
use crate::objects::color4u8::Color4u8;
use crate::objects::intersectable::Intersectable;
use crate::objects::ray::Ray;
<|fim_suffix|>impl Intersectable for Plane {
fn intersect(&self, ray: &Ray) -> Option<f... | code_fim | medium | {
"lang": "rust",
"repo": "GiregL/blastracer",
"path": "/src/objects/plane.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_color(&self) -> &Color4u8 {
&self.color
}
fn surface_normal(&self, _hit_point: &Vector3f) -> Vector3f {
self.normal * (-1.0)
}
}<|fim_prefix|>// repo: GiregL/blastracer path: /src/objects/plane.rs
use crate::maths::vector3f::Vector3f;
use crate::objects::color4u8::... | code_fim | medium | {
"lang": "rust",
"repo": "GiregL/blastracer",
"path": "/src/objects/plane.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/blockchain7 path: /transaction/core/src/onetime_keys.rs
keys are `A = a*G` and `B = b*G`, where `G` is the Ristretto base point. The
//! keys `a`, `b`, `A`, and `B` "stay in the user's wallet": they are not shared
//! with other users and they do not appear in the ledger.
//!
//... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain7",
"path": "/transaction/core/src/onetime_keys.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // view_key_matches_output should return true.
let view_key = ViewKey::new(
account.view_private_key().clone(), //a
recipient.spend_public_key().clone(), // D_7
);
assert!(view_key_matches_output(
&view_key,
&tx_target_key,
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain7",
"path": "/transaction/core/src/onetime_keys.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
// Should not panic if the output contains the wrong tx_target_key.
fn test_recover_public_subaddress_spend_key_wrong_tx_target_key() {
let mut rng = McRng::default();
let account: AccountKey = AccountKey::random(&mut rng);
let (_c, _d, recipient) = get_subaddre... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/blockchain7",
"path": "/transaction/core/src/onetime_keys.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bl00mie/AoC path: /rust/src/lib.rs
use std::{
fmt::Debug,
fmt::Display,
marker::PhantomData,
str::FromStr,
time::{Duration, Instant},
};
#[macro_export]
macro_rules! poop {
($($arg:tt)*) => {
{
#[cfg(debug_assertions)]
{
pr... | code_fim | hard | {
"lang": "rust",
"repo": "bl00mie/AoC",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !suppress_output {
println!("Day {:02}", day);
println!(" - {}", $crate::ResultLine::note("Parsing", solution.parse_time));
println!(" - {}", $crate::ResultLine::solution(1, sol... | code_fim | hard | {
"lang": "rust",
"repo": "bl00mie/AoC",
"path": "/rust/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(Box::new(TouchHandlerEx))
}
fn keyboard_added(&mut self,
_: CompositorHandle,
_: KeyboardHandle)
-> Option<Box<KeyboardHandler>> {
Some(Box::new(ExKeyboardHandler))
}
}
fn main() {
init_logging(WLR_DEB... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-junior-dube/wlroots-rs",
"path": "/examples/touch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daniel-junior-dube/wlroots-rs path: /examples/touch.rs
#[macro_use]
extern crate wlroots;
extern crate libc;
use wlroots::{CompositorBuilder, CompositorHandle, InputManagerHandler, KeyboardHandle,
KeyboardHandler, OutputBuilder, OutputBuilderResult, OutputHandle, OutputHandler,
... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-junior-dube/wlroots-rs",
"path": "/examples/touch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shirataki2/competitive_submissions path: /ahc001/src/bin/a.rs
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use procon_lazy_segtree::{LazySegTree, MaxAdd};
const CANVAS_SIZE: usize = 10000;
f... | code_fim | hard | {
"lang": "rust",
"repo": "Shirataki2/competitive_submissions",
"path": "/ahc001/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ad = self.ads[i];
let (_xj, yj) = self.search(i);
// 左上
let xlu = self.left_margin.query((yj - ad.y) as usize..min(yj as usize, CANVAS_SIZE));
let h = yj - ad.y;
let mut f = 1.0;
let mut ylu;
let mut w ;
loop {
w = min... | code_fim | hard | {
"lang": "rust",
"repo": "Shirataki2/competitive_submissions",
"path": "/ahc001/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let left_margin = vec![0; CANVAS_SIZE].into();
let up_margin = vec![0; CANVAS_SIZE].into();
Solver {
ads,
left_margin,
up_margin,
}
}
fn put_all(&mut self) -> Vec<(i64, i64, i64, i64)> {
for i in 0..self.ads.len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Shirataki2/competitive_submissions",
"path": "/ahc001/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32f3/src/stm32f3x4/hrtim_master/mrep.rs
#[doc = "Reader of register MREP"]
pub type R = crate::R<u32, super::MREP>;
#[doc = "Writer for register MREP"]
pub type W = crate::W<u32, super::MREP>;
#[doc = "Register MREP `reset()`'s with value 0"]
impl crate... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32f3/src/stm32f3x4/hrtim_master/mrep.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ine(always)]
pub fn mrep(&self) -> MREP_R {
MREP_R::new((self.bits & 0xff) as u8)
}
}
impl W {
#[doc = "Bits 0:7 - Master Timer Repetition counter value"]
#[inline(always)]
pub fn mrep(&mut self) -> MREP_W {
MREP_W { w: self }
}
}<|fim_prefix|>// repo: oxidecomputer... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32f3/src/stm32f3x4/hrtim_master/mrep.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn constant(&mut self, value: &str, type_: &Type) {
if !self.silenced {
self.output.writenl(&format!(
"{}.const {}",
self.typename(type_), value
))
}
}
pub fn local_set(&mut self, name: &str) {
if !self.silenc... | code_fim | hard | {
"lang": "rust",
"repo": "flaamjab/rupc",
"path": "/src/translation/wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn eqz(&mut self, type_: &Type) {
self.output.writenl(&format!(
"{}.eqz", self.typename(type_)
));
}
pub fn call(&mut self, name: &str) {
if !self.silenced {
self.output.writenl(&format!("call ${}", name));
}
}
pub fn if_sta... | code_fim | hard | {
"lang": "rust",
"repo": "flaamjab/rupc",
"path": "/src/translation/wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flaamjab/rupc path: /src/translation/wasm.rs
use std::io::Write;
use crate::{semantics::{Type, Types}, tokenization::{Operator, Relation}, translation::output::{Output, TEMPLATE}};
pub struct Wasm {
output: Output,
silenced: bool,
}
impl Wasm {
pub fn new(writer: Box<dyn Write>) -... | code_fim | hard | {
"lang": "rust",
"repo": "flaamjab/rupc",
"path": "/src/translation/wasm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.particles.vx[particle] += force.0 * time_delta;
self.particles.vy[particle] += force.1 * time_delta;
}
fn calc_neighbours(&mut self, particle: usize) -> Vec<usize> {
let i = particle;
let mut neighbours: Vec<usize> = Vec::new();
for k in 0..self.partic... | code_fim | hard | {
"lang": "rust",
"repo": "pepijnd/js-game-engine",
"path": "/src/fluid/default.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pepijnd/js-game-engine path: /src/fluid/default.rs
#![allow(dead_code)]
struct Particles {
x: Vec<f32>,
y: Vec<f32>,
oldx: Vec<f32>,
oldy: Vec<f32>,
vx: Vec<f32>,
vy: Vec<f32>,
p: Vec<f32>,
pnear: Vec<f32>,
g: Vec<f32>,
}
impl Particles {
fn new(count: u... | code_fim | hard | {
"lang": "rust",
"repo": "pepijnd/js-game-engine",
"path": "/src/fluid/default.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn apply_global_forces(&mut self, particle: usize) {
let time_delta = self.simulation_settings.time_delta;
let force = self.simulation_settings.gravity;
self.particles.vx[particle] += force.0 * time_delta;
self.particles.vy[particle] += force.1 * time_delta;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pepijnd/js-game-engine",
"path": "/src/fluid/default.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: The127/oath2 path: /src/ds/packet_queue.rs
use super::super::err::*;
use super::ports::PortNumber;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use num_traits::{FromPrimitive, ToPrimitive};
use std::convert::{Into, TryFrom};
use std::io::{Cursor, Seek, SeekFrom};
use std::path;
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "The127/oath2",
"path": "/src/ds/packet_queue.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //put cursor to correct position
cursor
.seek(SeekFrom::Current(queue_prop_header.len as i64))
.unwrap();
//construct message
let property = QueuePropMessage {
header: queue_prop_header,
payloa... | code_fim | hard | {
"lang": "rust",
"repo": "The127/oath2",
"path": "/src/ds/packet_queue.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // consent_expired_timestamp represents the timestamp at which the latest valid
// STUN binding response expired.
pub consent_expired_timestamp: Instant,
}
// CandidateStats contains ICE candidate statistics related to the ICETransport objects.
#[derive(Debug, Clone)]
pub struct CandidateStat... | code_fim | hard | {
"lang": "rust",
"repo": "laizy/ice",
"path": "/src/stats/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laizy/ice path: /src/stats/mod.rs
use crate::candidate::*;
use crate::network_type::*;
use tokio::time::Instant;
// CandidatePairStats contains ICE candidate pair statistics
#[derive(Debug, Clone)]
pub struct CandidatePairStats {
// timestamp is the timestamp associated with this object.
... | code_fim | hard | {
"lang": "rust",
"repo": "laizy/ice",
"path": "/src/stats/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg.data = String::from("hello world unlatched");
// Log event
ros_info!("Publishing: {}", msg.data);
// Send string message to topic via publisher, without latching it
chatter_pub_unlatched.send(msg).unwrap();
rosrust::spin();
}<|fim_prefix|>// repo: ZhangHanDong/rosrust path:... | code_fim | medium | {
"lang": "rust",
"repo": "ZhangHanDong/rosrust",
"path": "/examples/examples/publisher_latch_demo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZhangHanDong/rosrust path: /examples/examples/publisher_latch_demo.rs
use env_logger;
use rosrust::{self, ros_info};
fn main() {
env_logger::init();
// Initialize node
rosrust::init("talker");
// Create publisher
let mut chatter_pub_latched = rosrust::publish("chatter", 2)... | code_fim | hard | {
"lang": "rust",
"repo": "ZhangHanDong/rosrust",
"path": "/examples/examples/publisher_latch_demo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futurepaul/druid path: /druid-shell/src/mac/win_main.rs
// Copyright 2019 The xi-editor 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://w... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/druid",
"path": "/druid-shell/src/mac/win_main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Request to quit the application, exiting the runloop.
pub fn request_quit() {
unsafe {
// Is this threadsafe, or should we schedule on main loop?
let () = msg_send![NSApp(), terminate: nil];
}
}<|fim_prefix|>// repo: futurepaul/druid path: /druid-shell/src/mac/win_main.rs
// C... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/druid",
"path": "/druid-shell/src/mac/win_main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::Secp(err)
}
}<|fim_prefix|>// repo: jjyr/hdwallet path: /hdwallet-bitcoin/src/error.rs
use hdwallet::secp256k1;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
MisChecksum,
UnknownVersion,
Secp(secp256k1::Error),
InvalidBase58,
}
<|fim_middle|>impl From<... | code_fim | medium | {
"lang": "rust",
"repo": "jjyr/hdwallet",
"path": "/hdwallet-bitcoin/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjyr/hdwallet path: /hdwallet-bitcoin/src/error.rs
use hdwallet::secp256k1;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
MisChecksum,
UnknownVersion,
Secp(secp256k1::Error),
InvalidBase58,
}
<|fim_suffix|> Error::Secp(err)
}
}<|fim_middle|>impl From<... | code_fim | medium | {
"lang": "rust",
"repo": "jjyr/hdwallet",
"path": "/hdwallet-bitcoin/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let filename = env::args().nth(1).unwrap_or("input.txt".to_string());
let input_data = Input::new(filename).load_data();
'answer_one: for a in input_data.iter().copied() {
for b in input_data.iter().copied() {
if (a + b) == 2020 {
println!("Answ... | code_fim | hard | {
"lang": "rust",
"repo": "robinvalk/advent-of-code-2020",
"path": "/day_one/report_repair/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robinvalk/advent-of-code-2020 path: /day_one/report_repair/src/main.rs
use std::env;
use std::fs;
struct Input {
filename: String,
}
impl Input {
fn new(filename: String) -> Input {
Input { filename }
}
<|fim_suffix|> 'answer_one: for a in input_data.iter().copied() {
... | code_fim | hard | {
"lang": "rust",
"repo": "robinvalk/advent-of-code-2020",
"path": "/day_one/report_repair/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const FOOMP: Foo = Foo {
bar: 0,
baa: [69; 1],
};
fn main() {
let _val = FOOMP;
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/consts/extra-const-ub/issue-101034.rs
// check-pass
// compile-flags: -Zextra-const-ub-checks
<|fim_middle|>#[repr(packed)]
pub struct Foo {
bar: u8,
... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/consts/extra-const-ub/issue-101034.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/consts/extra-const-ub/issue-101034.rs
// check-pass
// compile-flags: -Zextra-const-ub-checks
#[repr(packed)]
pub struct Foo {
bar: u8,
baa: [u32; 1],
}
<|fim_suffix|> let _val = FOOMP;
}<|fim_middle|>const FOOMP: Foo = Foo {
bar: 0,
baa: [69; ... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/consts/extra-const-ub/issue-101034.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = {
let mut pos = origin;
let mut dir = east;
for &(m, n) in &dirs {
match m {
b'F' => pos += dir * n,
b'N' => pos += north * n,
b'S' => pos += south * n,
b'E' => pos += east * n,
... | code_fim | hard | {
"lang": "rust",
"repo": "inrick/aoc2020",
"path": "/day12/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for &(m, n) in &dirs {
match m {
b'F' => pos += waypoint * n,
b'N' => waypoint += north * n,
b'S' => waypoint += south * n,
b'E' => waypoint += east * n,
b'W' => waypoint += west * n,
b'L' =... | code_fim | hard | {
"lang": "rust",
"repo": "inrick/aoc2020",
"path": "/day12/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inrick/aoc2020 path: /day12/main.rs
use std::io::BufRead;
use std::io::BufReader;
use std::ops::Mul;
use std::ops::AddAssign;
use std::ops::MulAssign;
#[derive(Clone, Copy)]
struct C(i64, i64);
impl AddAssign<C> for C {
fn add_assign(&mut self, other: Self) {
self.0 += other.0;
... | code_fim | hard | {
"lang": "rust",
"repo": "inrick/aoc2020",
"path": "/day12/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jean-Serge/rust-args-parser path: /src/option.rs
struct Option {
required: bool,
nb_params: u8,
names: Vec<String>,
description: String
}
<|fim_suffix|>fn main() {
let mut parser = Arguments::new();
let opt = Option{required: true,
nb_params: 2,
... | code_fim | hard | {
"lang": "rust",
"repo": "Jean-Serge/rust-args-parser",
"path": "/src/option.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut parser = Arguments::new();
let opt = Option{required: true,
nb_params: 2,
names: vec![String::from("--hello"), String::from("-h")],
description: String::from("Un argument pour dire bonjour")
};
parser.re... | code_fim | medium | {
"lang": "rust",
"repo": "Jean-Serge/rust-args-parser",
"path": "/src/option.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: holmgr/hansa path: /src/ship/shipyard.rs
use super::*;
use ggez::{
graphics::{draw, get_drawable_size, rectangle, set_color, DrawMode, Font, Text},
GameResult,
};
/// Holds all unplaced 'ships' and manages of drawing UI element for ship selection.
#[derive(Serialize, Deserialize, Debug... | code_fim | hard | {
"lang": "rust",
"repo": "holmgr/hansa",
"path": "/src/ship/shipyard.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a builder to the shipyard.
pub fn add_builder(&mut self, builder: ShipBuilder) {
self.ships += 1;
}
/// Returns a ship to the shipyard.
pub fn add_ship(&mut self, ship: Ship) {
self.ships += 1;
}
/// Draws the shipyard with ship count on screen.
... | code_fim | hard | {
"lang": "rust",
"repo": "holmgr/hansa",
"path": "/src/ship/shipyard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let text = Text::new(ctx, &format!("{:1?}: ", self.ships), &font)?;
let text_dims = text.get_dimensions();
let x_offset =
cell_size * (config.grid_width / 2) as f32 - (text_dims.right() + 2. * cell_size) / 2.;
let y_offset = cell_size * (config.grid_height as f... | code_fim | hard | {
"lang": "rust",
"repo": "holmgr/hansa",
"path": "/src/ship/shipyard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out.push(item);
TokenStream::from_iter(out.into_iter())
}<|fim_prefix|>// repo: lu-zero/simd_helpers path: /src/lib.rs
extern crate proc_macro;
use std::iter::FromIterator;
use proc_macro::TokenStream;
use quote::quote;
<|fim_middle|>#[proc_macro_attribute]
pub fn cold_for_target_arch(attr: T... | code_fim | hard | {
"lang": "rust",
"repo": "lu-zero/simd_helpers",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lu-zero/simd_helpers path: /src/lib.rs
extern crate proc_macro;
use std::iter::FromIterator;
use proc_macro::TokenStream;
use quote::quote;
<|fim_suffix|> out.push(item);
TokenStream::from_iter(out.into_iter())
}<|fim_middle|>#[proc_macro_attribute]
pub fn cold_for_target_arch(attr: T... | code_fim | hard | {
"lang": "rust",
"repo": "lu-zero/simd_helpers",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> SendMessage {
chat_id: "".to_string(),
text: "".to_string(),
parse_mode: "HTML".to_string(),
disable_web_page_preview: false,
}
}
}<|fim_prefix|>// repo: l4l/this_week_in_rust.rs path: /src/bot.rs
use hyper::header::{ContentLength, Conte... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/this_week_in_rust.rs",
"path": "/src/bot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize)]
struct SendMessage {
chat_id: String,
text: String,
parse_mode: String,
disable_web_page_preview: bool,
}
impl Default for SendMessage {
fn default() -> Self {
SendMessage {
chat_id: "".to_string(),
text: "".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/this_week_in_rust.rs",
"path": "/src/bot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: l4l/this_week_in_rust.rs path: /src/bot.rs
use hyper::header::{ContentLength, ContentType};
use reqwest;
use reqwest::Url;
use serde::Serialize;
use serde_json;
type ReqwestResult = reqwest::Result<reqwest::Response>;
const URL: &'static str = "https://api.telegram.org/bot";
#[derive(Debug)]
... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/this_week_in_rust.rs",
"path": "/src/bot.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(msg: &[String], port: i32) {
let res = query(msg, port).expect("Connection error.");
println!("{}", res);
}<|fim_prefix|>// repo: maur1th/simplest-database path: /src/client/mod.rs
use std::io::prelude::*;
use std::io;
use std::net::TcpStream;
<|fim_middle|>fn query(msg: &[String], po... | code_fim | hard | {
"lang": "rust",
"repo": "maur1th/simplest-database",
"path": "/src/client/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maur1th/simplest-database path: /src/client/mod.rs
use std::io::prelude::*;
use std::io;
use std::net::TcpStream;
fn query(msg: &[String], port: i32) -> io::Result<String> {
<|fim_suffix|>pub fn run(msg: &[String], port: i32) {
let res = query(msg, port).expect("Connection error.");
pri... | code_fim | hard | {
"lang": "rust",
"repo": "maur1th/simplest-database",
"path": "/src/client/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slowmistio/MaskWalletCore path: /crypto/src/scrypt_params.rs
use scrypt::{scrypt, Params};
use serde::{Deserialize, Serialize};
use super::kdf_params::KdfParamsType;
use super::number_util::random_iv;
use crate::Error;
const CREDENTIAL_LEN: usize = 64usize;
#[derive(Serialize, Deserialize, Cl... | code_fim | hard | {
"lang": "rust",
"repo": "slowmistio/MaskWalletCore",
"path": "/crypto/src/scrypt_params.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut output: [u8; CREDENTIAL_LEN] = [0; CREDENTIAL_LEN];
let salt_bytes = hex::decode(&self.salt).or(Err(Error::KdfParamsInvalid))?;
scrypt(password, &salt_bytes, ¶ms, &mut output).or(Err(Error::PasswordIncorrect))?;
Ok(output[0..self.dklen].to_vec())
}
}
#[cfg(... | code_fim | medium | {
"lang": "rust",
"repo": "slowmistio/MaskWalletCore",
"path": "/crypto/src/scrypt_params.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn save_config_holder_contract(storage: &mut dyn Storage, addr: &Addr) -> StdResult<()> {
KEY_CONFIG_HOLDER_CONTRACT.save(storage, addr)
}<|fim_prefix|>// repo: vicioux/basset-vault-contracts path: /contracts/nasset_token/src/state.rs
use cosmwasm_std::{Addr, StdResult, Storage};
use cw_storage_p... | code_fim | hard | {
"lang": "rust",
"repo": "vicioux/basset-vault-contracts",
"path": "/contracts/nasset_token/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vicioux/basset-vault-contracts path: /contracts/nasset_token/src/state.rs
use cosmwasm_std::{Addr, StdResult, Storage};
use cw_storage_plus::Item;
<|fim_suffix|>pub fn save_config_holder_contract(storage: &mut dyn Storage, addr: &Addr) -> StdResult<()> {
KEY_CONFIG_HOLDER_CONTRACT.save(stor... | code_fim | hard | {
"lang": "rust",
"repo": "vicioux/basset-vault-contracts",
"path": "/contracts/nasset_token/src/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>.rs"]
pub mod inner;
pub use inner::sdd::{ mob, dungeon, pickable, client, server, common };<|fim_prefix|>// repo: SalonDesDevs/SuperDungeonsDestroyers path: /super-dungeons-destroyers-server/src/binding.rs
#[allow(non_snake_case, unused_imports)]
#[pat<|fim_middle|>h = "../../target/flatbuffers/schema_... | code_fim | easy | {
"lang": "rust",
"repo": "SalonDesDevs/SuperDungeonsDestroyers",
"path": "/super-dungeons-destroyers-server/src/binding.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SalonDesDevs/SuperDungeonsDestroyers path: /super-dungeons-destroyers-server/src/binding.rs
#[allow(non_snake_case, unused_imports)]
#[path = "../../target/flatbuffers/schema_generated<|fim_suffix|>b, dungeon, pickable, client, server, common };<|fim_middle|>.rs"]
pub mod inner;
pub use inner::... | code_fim | easy | {
"lang": "rust",
"repo": "SalonDesDevs/SuperDungeonsDestroyers",
"path": "/super-dungeons-destroyers-server/src/binding.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b, dungeon, pickable, client, server, common };<|fim_prefix|>// repo: SalonDesDevs/SuperDungeonsDestroyers path: /super-dungeons-destroyers-server/src/binding.rs
#[allow(non_snake_case, unused_imports)]
#[pat<|fim_middle|>h = "../../target/flatbuffers/schema_generated.rs"]
pub mod inner;
pub use inner::... | code_fim | medium | {
"lang": "rust",
"repo": "SalonDesDevs/SuperDungeonsDestroyers",
"path": "/super-dungeons-destroyers-server/src/binding.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wojtczal/rustlings-course path: /Enums/Enums and Pattern Matching/Implement Match/tests/tests.rs
use implement_match::test_match_message_call;
<|fim_suffix|> let state = test_match_message_call();
assert_eq!(state.color, (255, 0, 255));
assert_eq!(state.position.x, 10);
assert_eq... | code_fim | easy | {
"lang": "rust",
"repo": "wojtczal/rustlings-course",
"path": "/Enums/Enums and Pattern Matching/Implement Match/tests/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let state = test_match_message_call();
assert_eq!(state.color, (255, 0, 255));
assert_eq!(state.position.x, 10);
assert_eq!(state.position.y, 15);
assert_eq!(state.quit, true);
}<|fim_prefix|>// repo: wojtczal/rustlings-course path: /Enums/Enums and Pattern Matching/Implement Match/te... | code_fim | easy | {
"lang": "rust",
"repo": "wojtczal/rustlings-course",
"path": "/Enums/Enums and Pattern Matching/Implement Match/tests/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OfekShochat/leelacoin path: /src/main.rs
extern crate ed25519_dalek;
extern crate miniz_oxide;
extern crate rand;
extern crate serde_json;
extern crate sha3;
extern crate simple_logger;
#[macro_use]
extern crate lazy_static;
pub mod block;
mod blockchain;
pub mod config;
pub mod p2p;
use ed255... | code_fim | easy | {
"lang": "rust",
"repo": "OfekShochat/leelacoin",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use ed25519_dalek::Keypair;
use rand::rngs::OsRng;
fn main() {
simple_logger::init().unwrap();
let mut csprng = OsRng {};
p2p::Client::new(
Keypair::generate(&mut csprng),
config::get_config().boot_node,
)
.main();
}<|fim_prefix|>// repo: OfekShochat/leelacoin path: /src/main.rs
extern... | code_fim | medium | {
"lang": "rust",
"repo": "OfekShochat/leelacoin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stadust/pointercrate path: /pointercrate-core-pages/src/footer.rs
use maud::{html, Markup, PreEscaped, Render};
pub struct Footer {
copyright_notice: Markup,
columns: Vec<FooterColumn>,
twitter_links: Vec<Link>,
}
impl Footer {
pub fn new(copyright_notice: Markup) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "stadust/pointercrate",
"path": "/pointercrate-core-pages/src/footer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Link {
href: String,
text: String,
}
impl Link {
pub fn new<S: Into<String>, T: Into<String>>(href: S, text: T) -> Self {
Link {
href: href.into(),
text: text.into(),
}
}
}
impl Render for &Link {
fn render(&self) -> Markup {
... | code_fim | hard | {
"lang": "rust",
"repo": "stadust/pointercrate",
"path": "/pointercrate-core-pages/src/footer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse_json(text: &String) -> Json {
match Json::from_str(text) {
Ok(json) => json,
Err(_) => bad_format_close_app(),
}
}<|fim_prefix|>// repo: webbrandon/mc path: /src/file/input/mod.rs
use std::fs::File;
use std::io::prelude::*;
use std::str::FromStr;
use serde_json::value... | code_fim | hard | {
"lang": "rust",
"repo": "webbrandon/mc",
"path": "/src/file/input/mod.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: webbrandon/mc path: /src/file/input/mod.rs
use std::fs::File;
use std::io::prelude::*;
use std::str::FromStr;
use serde_json::value::Value as Json;
use crate::file::bad_format_close_app;
use std::process;
<|fim_suffix|>pub fn parse_json(text: &String) -> Json {
match Json::from_str(text) {
... | code_fim | hard | {
"lang": "rust",
"repo": "webbrandon/mc",
"path": "/src/file/input/mod.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hongweixiao/for_offer path: /src/number_of1_013.rs
fn number_of1(mut n: i32) -> i32{
let mut count = 0;
while n!=0 {
count += 1;
n = n&(n-1); //清除最右边的1
}
count
}
<|fim_suffix|> assert_eq!(0, number_of1(0));
assert_eq!(1, number_of1(2));
assert_eq!(2, number_of1(3));
as... | code_fim | medium | {
"lang": "rust",
"repo": "hongweixiao/for_offer",
"path": "/src/number_of1_013.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(0, number_of1(0));
assert_eq!(1, number_of1(2));
assert_eq!(2, number_of1(3));
assert_eq!(1, number_of1(8));
assert_eq!(3, number_of1(7));
}
}<|fim_prefix|>// repo: hongweixiao/for_offer path: /src/number_of1_013.rs
fn number_of1(mut n: i32) -> i32{
let mut count = 0... | code_fim | medium | {
"lang": "rust",
"repo": "hongweixiao/for_offer",
"path": "/src/number_of1_013.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jason-Cooke/gluon path: /format/src/lib.rs
//! Code formatter.
#![doc(html_root_url = "https://docs.rs/gluon_formatter/0.11.2")] // # GLUON
extern crate codespan;
#[macro_use]
extern crate gluon_base as base;
extern crate itertools;
extern crate pretty;
use base::{ast::SpannedExpr, symbol::Sym... | code_fim | hard | {
"lang": "rust",
"repo": "Jason-Cooke/gluon",
"path": "/format/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let source = codespan::FileMap::new("test".into(), input.into());
let arena = pretty::Arena::<()>::new();
let printer = pretty_print::Printer::new(&arena, &source, self.clone());
printer.format(100, newline, &expr)
}
}<|fim_prefix|>// repo: Jason-Cooke/gluon path: /for... | code_fim | hard | {
"lang": "rust",
"repo": "Jason-Cooke/gluon",
"path": "/format/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucklove/gprs path: /src/lib.rs
#![feature(fnbox)]
/// slice permutation
pub mod permutation;
/// Heap operations
<|fim_suffix|>tate;
/// scope guard
pub mod scope_guard;<|fim_middle|>pub mod heap;
/// rotate slice
pub mod ro | code_fim | easy | {
"lang": "rust",
"repo": "lucklove/gprs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tate;
/// scope guard
pub mod scope_guard;<|fim_prefix|>// repo: lucklove/gprs path: /src/lib.rs
#![feature(fnbox)]
/// slice permutation<|fim_middle|>
pub mod permutation;
/// Heap operations
pub mod heap;
/// rotate slice
pub mod ro | code_fim | medium | {
"lang": "rust",
"repo": "lucklove/gprs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keyboard-mapping/uinput-tokio path: /examples/mouse.rs
extern crate uinput_tokio;
use std::thread;
use std::time::Duration;
use tokio;
use uinput_tokio::event::controller::Controller::Mouse;
use uinput_tokio::event::controller::Mouse::Left;
use uinput_tokio::event::relative::Position::{X, Y};
u... | code_fim | medium | {
"lang": "rust",
"repo": "keyboard-mapping/uinput-tokio",
"path": "/examples/mouse.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> device.send(X, 50).await.unwrap();
device.send(Y, 50).await.unwrap();
device.synchronize().await.unwrap();
}
}<|fim_prefix|>// repo: keyboard-mapping/uinput-tokio path: /examples/mouse.rs
extern crate uinput_tokio;
use std::thread;
use std::time::Duration;
use tokio;
use uinp... | code_fim | medium | {
"lang": "rust",
"repo": "keyboard-mapping/uinput-tokio",
"path": "/examples/mouse.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// Piayala_hotel.new("Husnain Mirza".to_String());
Piayala_hotel.new("Habib Ullah".to_string());
let Wadi_e_meharan = hotel {
rasturan_name:String::from("Wadi e Mehran"),
food_name:String::from("Dall Roti"),
quantity:5,
price:1200,
avaliblity:true,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "husnainsuleman/rust_code",
"path": "/method_syentex/src/main.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.