text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: infinyon/flv-kf-protocol path: /kf-protocol-api/src/record.rs
use std::fmt;
use std::fmt::Debug;
use std::fmt::Display;
use std::io::Error;
use std::io::ErrorKind;
use content_inspector::{inspect, ContentType};
use log::trace;
use log::warn;
use kf_protocol::bytes::Buf;
use kf_protocol::bytes:... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-api/src/record.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loxp/kvs path: /project-2/src/error.rs
use failure::Fail;
use std::io;
/// Error type for kvs
#[derive(Fail, Debug)]
pub enum KvsError {
/// key not found error
#[fail(display = "Key not found")]
KeyNotFound,
/// IO error
#[fail(display = "{}", _0)]
Io(#[cause] io::Error... | code_fim | medium | {
"lang": "rust",
"repo": "loxp/kvs",
"path": "/project-2/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<serde_json::error::Error> for KvsError {
fn from(err: serde_json::error::Error) -> KvsError {
KvsError::SerdeJson(err)
}
}<|fim_prefix|>// repo: loxp/kvs path: /project-2/src/error.rs
use failure::Fail;
use std::io;
/// Error type for kvs
#[derive(Fail, Debug)]
pub enum KvsErro... | code_fim | medium | {
"lang": "rust",
"repo": "loxp/kvs",
"path": "/project-2/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> KvsError::Io(err)
}
}
impl From<serde_json::error::Error> for KvsError {
fn from(err: serde_json::error::Error) -> KvsError {
KvsError::SerdeJson(err)
}
}<|fim_prefix|>// repo: loxp/kvs path: /project-2/src/error.rs
use failure::Fail;
use std::io;
/// Error type for kvs
#[de... | code_fim | medium | {
"lang": "rust",
"repo": "loxp/kvs",
"path": "/project-2/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_date(&self, date: &Date){
write_protection(&self.rtc, false);
{
init_mode(&self.rtc, true);
{
let (dt, du) = byte_to_bcd2(date.date as u8);
let (mt, mu) = byte_to_bcd2(date.month as u8);
let yr = date.ye... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/zissou",
"path": "/stm32l4xx-hal/src/rtc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/zissou path: /stm32l4xx-hal/src/rtc.rs
//! RTC peripheral abstraction
use crate::datetime::*;
use crate::rcc::{BDCR, APB1R1, Clocks};
use crate::pwr;
use crate::stm32::{RTC};
/// RTC Abstraction
pub struct Rtc {
rtc: RTC
}
impl Rtc {
pub fn rtc(rtc: RTC, apb1r1: &mut APB1R1, b... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/zissou",
"path": "/stm32l4xx-hal/src/rtc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rtc.wpr.write(|w| unsafe {
w.bits(0x53)
});
}
}
fn init_mode(rtc: &RTC, enabled: bool) {
if enabled {
let isr = rtc.isr.read();
if isr.initf().bit_is_clear() { // are we already in init mode?
rtc.isr.write(|w| { w.init().set_bit() });
... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/zissou",
"path": "/stm32l4xx-hal/src/rtc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osynge/parse_debconf_template path: /src/templates.rs
#[cfg(test)]
use std::borrow::Cow;
#[cfg(test)]
pub fn adduser<'a>() -> Cow<'a, str> {
return Cow::Owned(String::from(include_str!("templates/adduser.templates")));
}
#[cfg(test)]
pub fn apparmor<'a>() -> Cow<'a, str> {
return Cow::... | code_fim | hard | {
"lang": "rust",
"repo": "osynge/parse_debconf_template",
"path": "/src/templates.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_console_setup_all() {
let line = String::from(getlines(&console_setup(), 1, 9999));
match template_parser::<VerboseError<&str>>(&line) {
Ok((i, _value)) => {
//println!("value {:?}", value);
println!("i {:?}", i);
... | code_fim | hard | {
"lang": "rust",
"repo": "osynge/parse_debconf_template",
"path": "/src/templates.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huangliang367/linux path: /rust/func/src/main.rs
#![allow(unused)]
enum Message {
Quit,
Move {x: i32, y: i32},
Write(String),
ChangeColor(i32, i32, i32),
}
impl Message {
fn call(&self) {
}
}
#[derive(Debug)]
pub struct Rectangle {
width: u32,
height: u... | code_fim | medium | {
"lang": "rust",
"repo": "huangliang367/linux",
"path": "/rust/func/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.width * self.height
}
fn can_hold(&self, other: &Rectangle) -> bool {
self.width > other.width && self.height > other.height
}
pub fn new(width: u32, height: u32) -> Self {
Rectangle { width, height }
}
pub fn width(&self) -> u32 {
return sel... | code_fim | medium | {
"lang": "rust",
"repo": "huangliang367/linux",
"path": "/rust/func/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rect1 = Rectangle {width: 30, height: 50};
let rect2: Rectangle = Rectangle {width: 10, height: 40};
let rect3 = Rectangle::new(35, 55);
println!("The area of the rectangle is {} square pixels.",
rect1.area());
println!("Can rect1 hold rect2 ? {}", rect1.can_hold(&rect2));... | code_fim | hard | {
"lang": "rust",
"repo": "huangliang367/linux",
"path": "/rust/func/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> CatFileResponse(match self.repos.get(&req.repo_key) {
Some(repo) => self
.ops
.cat_file(repo, &req.reference, &req.path)
.map_err(|x| x.to_string()),
None => Err(format!("No repo found with name '{}'", &req.repo_key)),
... | code_fim | hard | {
"lang": "rust",
"repo": "intenthq/gitkv",
"path": "/handlers/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intenthq/gitkv path: /handlers/src/lib.rs
use actix::dev::MessageResponse;
use actix::{Actor, Context, Handler, Message};
use git::{git2::Repository, GitOps, LibGitOps};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Message)]
#[rtype(result = "CatFileResponse")]
pub struct Cat... | code_fim | hard | {
"lang": "rust",
"repo": "intenthq/gitkv",
"path": "/handlers/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<CatFile> for GitRepos {
type Result = CatFileResponse;
fn handle(&mut self, req: CatFile, _: &mut Self::Context) -> Self::Result {
CatFileResponse(match self.repos.get(&req.repo_key) {
Some(repo) => self
.ops
.cat_file(repo, &req.re... | code_fim | hard | {
"lang": "rust",
"repo": "intenthq/gitkv",
"path": "/handlers/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicksanders/rust-django-signing path: /src/baseconv.rs
pub const BASE10_CHARS: &'static str = "0123456789";
pub enum Base {
Base2,
Base10,
Base16,
Base36,
Base56,
Base62,
Base64
}
pub struct BaseConv {
chars: &'static str,
sign: &'static str
}
impl BaseCon... | code_fim | hard | {
"lang": "rust",
"repo": "nicksanders/rust-django-signing",
"path": "/src/baseconv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(BaseConv::new(Base::Base62).decode("1Z1WLZ"), 1433667265);
assert_eq!(BaseConv::new(Base::Base62).encode("1433667265"), "1Z1WLZ");
}
#[test]
fn test_base64() {
assert_eq!(BaseConv::new(Base::Base64).decode("$1Z1WLZ"), -1661338979);
assert_eq!(BaseConv::new(Base::Base64).encode(... | code_fim | hard | {
"lang": "rust",
"repo": "nicksanders/rust-django-signing",
"path": "/src/baseconv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (
vehicle in default_vehicle_type_prototype(),
breaks in get_breaks()
) -> VehicleType {
assert_eq!(vehicle.shifts.len(), 1);
let mut vehicle = vehicle;
vehicle.shifts.first_mut().unwrap().breaks = breaks;
vehicle
}
}
prop_compose! {
fn get_prob... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/tests/discovery/property/generated_with_breaks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tertsdiepraam/vrp path: /vrp-pragmatic/tests/discovery/property/generated_with_breaks.rs
use crate::format::problem::*;
use crate::format::Location;
use crate::generator::*;
use crate::helpers::solve_with_metaheuristic_and_iterations;
use proptest::prelude::*;
fn get_breaks() -> impl Strategy<V... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/tests/discovery/property/generated_with_breaks.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_break_time_windows() -> impl Strategy<Value = VehicleBreakTime> {
generate_multiple_time_windows_fixed(
START_DAY,
vec![from_hours(11), from_hours(13)],
vec![from_hours(2), from_hours(4)],
1..2,
)
.prop_map(|tws| VehicleBreakTime::TimeWindow(tws.first... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/tests/discovery/property/generated_with_breaks.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn render(&mut self, window: &Window) -> Result<()> {
let device = self.device.device_as_ref();
let (image_index, is_suboptimal) = self
.swapchain
.acquire_next_image(self.image_available_semaphore.semaphore())?;
if is_suboptimal {
let Phy... | code_fim | hard | {
"lang": "rust",
"repo": "MatchaChoco010/vulkan-ash-tutorial-rust-memo",
"path": "/techlabxe_vulkan_book_3/src/cs_post_effect/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatchaChoco010/vulkan-ash-tutorial-rust-memo path: /techlabxe_vulkan_book_3/src/cs_post_effect/app.rs
use anyhow::Result;
use ash::{version::DeviceV1_0, vk};
use winit::{dpi::PhysicalSize, event::Event, window::Window};
use crate::{
app_base::{VulkanAppBase, VulkanAppBaseBuilder},
cs_po... | code_fim | hard | {
"lang": "rust",
"repo": "MatchaChoco010/vulkan-ash-tutorial-rust-memo",
"path": "/techlabxe_vulkan_book_3/src/cs_post_effect/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vlad9486/gusni path: /src/core/ray.rs
use super::algebra::V3;
use super::scene::{Scene, Event, Material};
use super::wave::WaveLength;
use serde::{Serialize, Deserialize};
use num::Float;
use rand::Rng;
#[derive(Clone, Serialize, Deserialize)]
pub struct Ray<C>
where
C: Float,
{
positi... | code_fim | hard | {
"lang": "rust",
"repo": "vlad9486/gusni",
"path": "/src/core/ray.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ray {
position: position + &(&direction * C::epsilon()),
direction: direction,
wave_length: self.wave_length.clone(),
}
}
fn refract(&self, position: &V3<C>, normal: &V3<C>, factor: C) -> Self {
let incident = &self.direction;
le... | code_fim | hard | {
"lang": "rust",
"repo": "vlad9486/gusni",
"path": "/src/core/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn infix_to_rpn(tokens: Vec<Token>) -> Vec<Token> {
let mut output: Vec<Token> = Vec::new();
let mut oper_stack: Vec<Op> = Vec::new();
let tokens_iter = tokens.iter();
for token in tokens_iter {
match token {
Token::Char(_) => output.push(*token),
Toke... | code_fim | hard | {
"lang": "rust",
"repo": "gbordyugov/shuntyard",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> output.push(raw_tokens[0]);
for i in 0..raw_tokens.len() - 1 {
let this = raw_tokens[i];
let next = raw_tokens[i + 1];
if let (Token::Char(_), Token::Char(_)) = (this, next) {
output.push(Token::Op(Op::Dot));
}
output.push(next);
}
out... | code_fim | hard | {
"lang": "rust",
"repo": "gbordyugov/shuntyard",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gbordyugov/shuntyard path: /src/tokenizer.rs
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Op {
Alter,
Dot,
LeftParen,
RightParen,
}
impl Op {
fn prec(&self) -> i8 {
match self {
Op::Alter => 0,
Op::Dot => 1,
_ => unimplemented... | code_fim | hard | {
"lang": "rust",
"repo": "gbordyugov/shuntyard",
"path": "/src/tokenizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>:game::Game::new();
let pgn_filepath = "pgn_files/PGN6.txt";
chess::pgn::read_pgn(pgn_filepath);
//game.main();
}<|fim_prefix|>// repo: INDAPlus20/ahanifi-chess path: /chess/src/main.rs
#[warn(dead_code)]
fn main() {
let blockstate =
"XX XX XX XX XX XX XX XX
PB XX XX XX XX KB B... | code_fim | medium | {
"lang": "rust",
"repo": "INDAPlus20/ahanifi-chess",
"path": "/chess/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> XX XX KW XX XX PW XX XX";
let mut game = chess::game::Game::game_from_blockstate(blockstate);
//let mut game = chess::game::Game::new();
let pgn_filepath = "pgn_files/PGN6.txt";
chess::pgn::read_pgn(pgn_filepath);
//game.main();
}<|fim_prefix|>// repo: INDAPlus20/ahanifi-chess path... | code_fim | medium | {
"lang": "rust",
"repo": "INDAPlus20/ahanifi-chess",
"path": "/chess/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: INDAPlus20/ahanifi-chess path: /chess/src/main.rs
#[warn(dead_code)]
fn main() {
let blockstate =
"XX XX XX XX XX XX XX XX
PB XX XX XX XX KB BB XX
XX PB XX PB <|fim_suffix|> XX XX KW XX XX PW XX XX";
let mut game = chess::game::Game::game_from_blockstate(blockstate);
//l... | code_fim | medium | {
"lang": "rust",
"repo": "INDAPlus20/ahanifi-chess",
"path": "/chess/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silkworm-rs/silkworm path: /silkworm_syn/src/lex.rs
`.
Command,
/// Right after `[[`., before `|`.
OptionTextOrTarget,
/// Between `[[` and `]]`, after `|`.
OptionTarget,
/// Between `[` and `]`.
FormatFunction,
/// After an opening `"` and before a closing one.
... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/lex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inline_stack
.try_push(mode)
.map_err(|_| ErrorKind::StackTooDeep)
}
fn delay_token(&mut self, token: Token) -> Result<(), Error> {
self.delayed.push_back(token).map_err(|_| Error {
kind: ErrorKind::DelayQueueTooLong,
token,
... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/lex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //# disable_feature(foo, bar, baz)
<<if it_parses_strings("Foo\nBar\x3A baz\"\\\u{1234}") is true>>
Yay {$yay}! #yay!
<<else>>
Oops {$oops}! //Oops!
<<endif>>
//# private
<<if what_about_interpolation(... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_syn/src/lex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn view(&self) -> Html {
html! {
<section class="section">
<div class="container">
<Router<AppRoute, ()>
render = Router::render(|switch: AppRoute| {
match switch {
... | code_fim | medium | {
"lang": "rust",
"repo": "shaunbennett/dotdotyew",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaunbennett/dotdotyew path: /src/lib.rs
#![recursion_limit = "1024"]
use wasm_bindgen::prelude::*;
use yew::prelude::*;
use yew_router::prelude::*;
pub mod api;
pub mod component;
pub mod poll;
use poll::{CreatePoll, PollResults, ShowPoll};
<|fim_suffix|> Self { _link: link }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "shaunbennett/dotdotyew",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
ctx: transaction::Context<'_>,
batch: &TxnBatch,
) -> Result<Vec<CheckTxResult>, RuntimeError> {
// TODO: Get rid of StorageContext (pass mkvs in ctx).
StorageContext::with_current(|mkvs, _| {
// Prepare dispatch context.
let mut c... | code_fim | hard | {
"lang": "rust",
"repo": "lvshaoping007/oasis-sdk",
"path": "/runtime-sdk/src/dispatcher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(result)
}
fn check_tx(&self, ctx: &mut DispatchContext<'_>, tx: &[u8]) -> Result<CheckTxResult, Error> {
let tx = match self.decode_tx(ctx, &tx) {
Ok(tx) => tx,
Err(err) => {
return Ok(CheckTxResult {
error: RuntimeErr... | code_fim | hard | {
"lang": "rust",
"repo": "lvshaoping007/oasis-sdk",
"path": "/runtime-sdk/src/dispatcher.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvshaoping007/oasis-sdk path: /runtime-sdk/src/dispatcher.rs
//! Transaction dispatcher.
use std::{
collections::BTreeMap,
marker::PhantomData,
sync::{atomic::AtomicBool, Arc},
};
use slog::error;
use thiserror::Error;
use oasis_core_runtime::{
self,
common::cbor,
conse... | code_fim | hard | {
"lang": "rust",
"repo": "lvshaoping007/oasis-sdk",
"path": "/runtime-sdk/src/dispatcher.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where S: Serializer
{
struct Data<'a, V: 'a>(&'a V) where V: Sealed;
impl<'a, V: Sealed + 'a> Serialize for Data<'a, V> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
self.0.encod... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/serde-millis",
"path": "/src/impls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tailhook/serde-millis path: /src/impls.rs
#[cfg(feature = "chrono")] mod chrono;
#[cfg(feature = "time")] mod time;
use std::fmt;
use std::time::{Duration, SystemTime, Instant, UNIX_EPOCH};
use std::marker::PhantomData;
use serde::ser::{Serialize, Serializer, Error as SerError};
use serde::de:... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/serde-millis",
"path": "/src/impls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_instant_past() {
let early = Instant::now();
let converted = decode::<Instant>(
&encode(Instant::now() - Duration::from_millis(2000)));
let late = Instant::now();
assert!(converted >= early - Duration::from_millis(2002));
assert!(... | code_fim | hard | {
"lang": "rust",
"repo": "tailhook/serde-millis",
"path": "/src/impls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new<T: CloneDefault>(value: T) -> Element<T> {
Element::new(value)
}<|fim_prefix|>// repo: AlecGoncharow/bridges-rust path: /src/element.rs
use super::CloneDefault;
#[derive(Serialize, Deserialize, Clone)]
pub struct Element<T: CloneDefault> {
pub value: T,
pub name: String,
pub c... | code_fim | hard | {
"lang": "rust",
"repo": "AlecGoncharow/bridges-rust",
"path": "/src/element.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlecGoncharow/bridges-rust path: /src/element.rs
use super::CloneDefault;
#[derive(Serialize, Deserialize, Clone)]
pub struct Element<T: CloneDefault> {
pub value: T,
pub name: String,
pub color: Vec<f32>,
pub size: f32,
pub location: Vec<f32>,
pub shape: String,
}
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "AlecGoncharow/bridges-rust",
"path": "/src/element.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgreid/playground path: /program_config_derive/src/lib.rs
#![recursion_limit = "256"]
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::{self, Span};
use quote::quote;
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Expr, Field, Ident, Lit, Meta, Type};
// Ret... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/playground",
"path": "/program_config_derive/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn flag_long_options(data: &DataStruct) -> impl Iterator<Item = String> + '_ {
flags(data).filter_map(|f| f.ident.as_ref().map(|ident| ident.to_string()))
}
// Used to generate the `quote!`ed `HasArg` option to be used with getopts for each of the struct's
// fields.
fn has_args(data: &DataStruct) ->... | code_fim | hard | {
"lang": "rust",
"repo": "dgreid/playground",
"path": "/program_config_derive/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> BOTH ENDS
if n % 15 == 0 {
println!("fizzbuzz");
} else if n % 3 == 0 {
println!("fizz");
} else if n % 5 == 0 {
println!("buzz");
} else {
println!("{}", n);
}
}
}<|fim_prefix|>// repo: pprobst/rust-stuff path: ... | code_fim | medium | {
"lang": "rust",
"repo": "pprobst/rust-stuff",
"path": "/ch8_flow_control/for_and_range.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>);
} else if n % 5 == 0 {
println!("buzz");
} else {
println!("{}", n);
}
}
}<|fim_prefix|>// repo: pprobst/rust-stuff path: /ch8_flow_control/for_and_range.rs
fn main() {
// The 'for in' construct can be used to iterate through an Iterator.
// ... | code_fim | medium | {
"lang": "rust",
"repo": "pprobst/rust-stuff",
"path": "/ch8_flow_control/for_and_range.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pprobst/rust-stuff path: /ch8_flow_control/for_and_range.rs
fn main() {
// The 'for in' construct can be used to iterate through an Iterator.
// 'n' will take the values: 1, 2, ..., 100 in each iteration.
for n in 1..101 { // EXCLUSIVE RANGE (DEFAULT)
// for n in 1..=100 { ... | code_fim | medium | {
"lang": "rust",
"repo": "pprobst/rust-stuff",
"path": "/ch8_flow_control/for_and_range.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sandialabs/Polymers path: /src/physics/py.rs
use pyo3::prelude::*;
pub fn register_module(py: Python<'_>, paren<|fim_suffix|> physics)?;
parent_module.add_submodule(physics)?;
Ok(())
}<|fim_middle|>t_module: &PyModule) -> PyResult<()>
{
let physics = PyModule::new(py, "physic... | code_fim | medium | {
"lang": "rust",
"repo": "sandialabs/Polymers",
"path": "/src/physics/py.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>ew(py, "physics")?;
super::single_chain::py::register_module(py, physics)?;
parent_module.add_submodule(physics)?;
Ok(())
}<|fim_prefix|>// repo: sandialabs/Polymers path: /src/physics/py.rs
use pyo3::prelude::*;
pub fn register_module(py: Python<'_>, paren<|fim_middle|>t_module: &PyMo... | code_fim | medium | {
"lang": "rust",
"repo": "sandialabs/Polymers",
"path": "/src/physics/py.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> physics)?;
parent_module.add_submodule(physics)?;
Ok(())
}<|fim_prefix|>// repo: sandialabs/Polymers path: /src/physics/py.rs
use pyo3::prelude::*;
pub fn register_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()>
{
let physics = PyModule::n<|fim_middle|>ew(py, "physic... | code_fim | medium | {
"lang": "rust",
"repo": "sandialabs/Polymers",
"path": "/src/physics/py.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result2 = pre_process(
vec![
String::from("D = A + C "),
String::from(" D = A + C "),
String::from(" D = A + C"),
String::from(" "),
String::from("// "),
String::from(" D = A + C // "),
... | code_fim | hard | {
"lang": "rust",
"repo": "zhengrenzhe/nand2tetris",
"path": "/compiler/utils/tests/pre_process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhengrenzhe/nand2tetris path: /compiler/utils/tests/pre_process.rs
extern crate utils;
use utils::pre_process::pre_process;
#[test]
fn test_pre_process() {
let result = pre_process(
vec![
String::from("D = A + C "),
String::from(" D = A + C "),
... | code_fim | hard | {
"lang": "rust",
"repo": "zhengrenzhe/nand2tetris",
"path": "/compiler/utils/tests/pre_process.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_ptr(bt: BaseType) -> Type {
Type {
base_type: bt,
array_size: None,
is_ptr: true,
}
}
pub fn into_arr(self, array_size: u32) -> Type {
assert_eq!(self.array_size, None);
Type {
base_type: self.base_type... | code_fim | hard | {
"lang": "rust",
"repo": "micahswitzer/rucmic",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub enum Stmt_ {
// var decl statement (not sure if this is the right
// way of implementing this...)
Decl(Box<Decl>),
// compound statement
Comp(Vec<Stmt>),
// expression statement
Expr(Box<Expr>),
// if-else statement
Cond(Box<Expr>, Box<Stmt>, Option... | code_fim | hard | {
"lang": "rust",
"repo": "micahswitzer/rucmic",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: micahswitzer/rucmic path: /src/ast.rs
use crate::lexer::Span;
#[derive(Debug)]
pub struct Program {
pub decls: Vec<Decl>,
}
#[derive(Debug)]
pub struct Expr {
pub span: Span,
pub node: Expr_,
}
#[derive(Debug)]
pub enum BinOp {
Add,
Sub,
Mul,
Div,
CmpLT,
Cm... | code_fim | hard | {
"lang": "rust",
"repo": "micahswitzer/rucmic",
"path": "/src/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bastienbot/csml-engine path: /csml_manager/src/db_interactions.rs
use crate::Client;
mod db;
#[cfg(feature = "http")]
mod db_interactions_http_db;
#[cfg(feature = "mongo")]
mod db_interactions_mongo;
pub use db::*;
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct Conversation... | code_fim | hard | {
"lang": "rust",
"repo": "bastienbot/csml-engine",
"path": "/csml_manager/src/db_interactions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct State {
#[serde(rename = "_id")] // Use MongoDB's special primary key field name when serializing
pub id: String,
pub client: Client,
#[serde(rename = "type")]
pub _type: String,
pub value: String, // encrypted
p... | code_fim | hard | {
"lang": "rust",
"repo": "bastienbot/csml-engine",
"path": "/csml_manager/src/db_interactions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct Node {
#[serde(rename = "_id")] // Use MongoDB's special primary key field name when serializing
pub id: String,
pub client: Client,
pub interaction_id: String,
pub conversation_id: String,
pub flow_id: String,
p... | code_fim | hard | {
"lang": "rust",
"repo": "bastienbot/csml-engine",
"path": "/csml_manager/src/db_interactions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(dom_tree.dominates(blocks[1], blocks[1]));
assert!(dom_tree.dominates(blocks[1], blocks[2]));
assert!(dom_tree.dominates(blocks[1], blocks[3]));
assert!(dom_tree.dominates(blocks[1], blocks[4]));
assert!(dom_tree.dominates(blocks[1], blocks[5]));
ass... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/vicis",
"path": "/tests/dom_tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "#;
let module = module::parse_assembly(src).unwrap();
for (_, func) in module.functions() {
let blocks: Vec<BasicBlockId> = func.data.basic_blocks.iter().map(|(id, _)| id).collect();
let dom_tree = DominatorTree::new(func);
assert!(dom_tree.dominates(blocks[1], ... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/vicis",
"path": "/tests/dom_tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaplaceKorea/vicis path: /tests/dom_tree.rs
use rustc_hash::FxHashSet;
use vicis::{
// codegen::{isa::x86_64::X86_64, lower::compile_module},
// exec::{generic_value::GenericValue, interpreter::Interpreter},
ir::{function::basic_block::BasicBlockId, module},
pass::analysis::dom_t... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/vicis",
"path": "/tests/dom_tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn merge_two_lists(
l1: Option<Box<ListNode>>,
l2: Option<Box<ListNode>>,
) -> Option<Box<ListNode>> {
let mut res_head = Box::new(ListNode::new(-101));
let mut res = &mut res_head;
let mut l1_mut = &l1;
let mut l2_mut = &l2;
let mut min_val: i32;
if... | code_fim | medium | {
"lang": "rust",
"repo": "abadrinath15/rust-leetcode",
"path": "/easy_problems/src/solution_files/problem_21.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abadrinath15/rust-leetcode path: /easy_problems/src/solution_files/problem_21.rs
use crate::solution_files::Solution;
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
<|fim_suffix|>impl Solut... | code_fim | medium | {
"lang": "rust",
"repo": "abadrinath15/rust-leetcode",
"path": "/easy_problems/src/solution_files/problem_21.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: R1tschY/rustjvm path: /components/opcode/src/disasm.rs
use crate::{ArrayType, Opcode};
#[derive(Debug, Clone)]
pub enum DisasmError {
UnknownOpcode(u8),
MissingArgument,
InvalidArgument,
InvalidArrayType,
}
struct Disasm<'a> {
bytes: &'a [u8],
index: usize,
opcodes:... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/rustjvm",
"path": "/components/opcode/src/disasm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn argument_u32(&mut self) -> Result<u32, DisasmError> {
self.index += 4;
if self.index < self.bytes.len() {
Ok(compose_u32(
self.bytes[self.index - 3],
self.bytes[self.index - 2],
self.bytes[self.index - 1],
s... | code_fim | hard | {
"lang": "rust",
"repo": "R1tschY/rustjvm",
"path": "/components/opcode/src/disasm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
:
Ioctl
=
0x20005407
;
pub
const
TIOCEXCL
:
:
:
Ioctl
=
0x2000740d
;
pub
const
TIOCNXCL
:
:
:
Ioctl
=
0x2000740e
;
pub
const
TIOCSCTTY
:
:
:
Ioctl
=
0x20007484
;
pub
const
TIOCGPGRP
:
:
:
Ioctl
=
0x40047483
;
pub
const
TIOCSPGRP
:
:
:
Ioctl
=
0x80047482
;
pub
const
TIOCOUTQ
:
:
:
Ioctl
=
0x40047473
;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>CSERSETMULTI
:
:
:
Ioctl
=
0x545B
;
pub
const
TIOCMIWAIT
:
:
:
Ioctl
=
0x545C
;
pub
const
TIOCGICOUNT
:
:
:
Ioctl
=
0x545D
;
pub
const
TIOCSTART
:
:
:
Ioctl
=
0x2000746e
;
pub
const
TIOCSTOP
:
:
:
Ioctl
=
0x2000746f
;
pub
const
BLKIOMIN
:
:
:
Ioctl
=
0x20001278
;
pub
const
BLKIOOPT
:
:
:
Ioctl
=
0x2000127... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs
s
!
{
pub
struct
termios2
{
pub
c_iflag
:
:
:
tcflag_t
pub
c_oflag
:
:
:
tcflag_t
pub
c_cflag
:
:
:
tcflag_t
pub
c_lflag
:
:
:
tcflag_t
pub
c_line
:
:
:
cc_t
pub
c_cc
:
[
:
:
cc_t
;
19
]
pub
c_is... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/libc/src/unix/linux_like/linux/arch/sparc/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gaybro8777/nannou-sketches path: /src/bin/bloob.rs
use getopts::Options;
use nannou::app::LoopMode;
use nannou::prelude::*;
use std::env;
use sketches::img_path;
const WIDTH: u32 = 900;
const HEIGHT: u32 = 900;
<|fim_suffix|> nannou::sketch(view).size(WIDTH, HEIGHT).run()
}
fn view(app: &... | code_fim | medium | {
"lang": "rust",
"repo": "gaybro8777/nannou-sketches",
"path": "/src/bin/bloob.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn view(app: &App, frame: Frame) {
let args: Vec<String> = env::args().collect();
let mut opts = Options::new();
opts.optflag("p", "png", "save frames to file as png.");
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => panic!("{}", f),
};
let png =... | code_fim | medium | {
"lang": "rust",
"repo": "gaybro8777/nannou-sketches",
"path": "/src/bin/bloob.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..65 {
let theta = i as f32 / 64.0 * TAU;
let draw = draw.rotate(theta);
let r = 10.0 * (75.0 - i as f32) * theta.sin();
let mut color = srgba(1.0, 1.0, 1.0, i as f32 / 100.0);
if i == 10 {
color = srgba(1.0, 0.0, 0.0, 1.0);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gaybro8777/nannou-sketches",
"path": "/src/bin/bloob.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Book {
author: author,
isbn: isbn,
price: price,
title: title
}
}<|fim_prefix|>// repo: book-resources/rustlernen path: /10-Benutzerdefinierte Typen/programmtext-116.rs
struct Book {
author: String,
isbn: String,
price: f32,
title: String
}
fn main() {
let buch1 = create_boo... | code_fim | medium | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/10-Benutzerdefinierte Typen/programmtext-116.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: book-resources/rustlernen path: /10-Benutzerdefinierte Typen/programmtext-116.rs
struct Book {
author: String,
isbn: String,
price: f32,
title: String
}
fn main() {
<|fim_suffix|> Book {
author: author,
isbn: isbn,
price: price,
title: title
}
}<|fim_middle|> let buch... | code_fim | hard | {
"lang": "rust",
"repo": "book-resources/rustlernen",
"path": "/10-Benutzerdefinierte Typen/programmtext-116.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JAD3N/mc-server path: /server/src/util/mod.rs
mod properties;
mod time;
mod json_value;
<|fim_suffix|>pub use properties::*;
pub use time::*;
pub use traitable::*;
pub use json_value::*;<|fim_middle|>#[macro_use]
pub mod traitable;
| code_fim | easy | {
"lang": "rust",
"repo": "JAD3N/mc-server",
"path": "/server/src/util/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use properties::*;
pub use time::*;
pub use traitable::*;
pub use json_value::*;<|fim_prefix|>// repo: JAD3N/mc-server path: /server/src/util/mod.rs
mod properties;
mod time;
mod json_value;
<|fim_middle|>#[macro_use]
pub mod traitable;
| code_fim | easy | {
"lang": "rust",
"repo": "JAD3N/mc-server",
"path": "/server/src/util/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_participant = NewParticipant {
name: name,
car_name: car_name,
car_weight: car_weight,
};
diesel::insert_into(participants::table)
.values(&new_participant)
.get_result(conn)
.expect("Error saving new participant")
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "sputnick1124/pinewood-diesel.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sputnick1124/pinewood-diesel.rs path: /src/lib.rs
#[macro_use]
extern crate diesel;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use dotenv::dotenv;
use std::env;
pub mod models;
pub mod schema;
<|fim_suffix|> diesel::insert_into(participants::table)
.values(&new_participa... | code_fim | hard | {
"lang": "rust",
"repo": "sputnick1124/pinewood-diesel.rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if delta > 0.0 {
Some(r.at((-dl - delta.sqrt()) / d2))
} else {
None
}
}
fn normal(&self, p: &Point3) -> Vec3 {
(p - &self.center).unit()
}
}<|fim_prefix|>// repo: lyyyuna/ray-tracing-in-one-week path: /src/geometry/sphere.rs
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "lyyyuna/ray-tracing-in-one-week",
"path": "/src/geometry/sphere.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyyyuna/ray-tracing-in-one-week path: /src/geometry/sphere.rs
use crate::types::Point3;
use crate::types::Vec3;
use crate::types::Ray;
use super::Geometry;
pub struct Sphere {
center: Point3,
radius: f64,
radius_squared: f64,
}
<|fim_suffix|>impl Geometry for Sphere {
// Ray(t... | code_fim | medium | {
"lang": "rust",
"repo": "lyyyuna/ray-tracing-in-one-week",
"path": "/src/geometry/sphere.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let l = &r.origin - &self.center;
let dl = r.direction.dot(&l);
let dl2 = dl.powi(2);
let d2 = r.direction.length_squared();
let l2 = l.length_squared();
let delta = dl2 - d2 * (l2 - self.radius_squared);
if delta > 0.0 {
Some(r.... | code_fim | hard | {
"lang": "rust",
"repo": "lyyyuna/ray-tracing-in-one-week",
"path": "/src/geometry/sphere.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slog-rs/stdlog path: /tests/slog2log.rs
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use fragile::Fragile;
use log::RecordBuilder;
use slog::Drain;
struct StdLogAssertExpected<'a> {
expected: Mutex<Vec<Fragile<log::Record<'a>>>>,
current_index: AtomicUsize,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "slog-rs/stdlog",
"path": "/tests/slog2log.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl StdLogAssertExpected<'_> {
fn assert_finished(&self) {
let expected = self.expected.lock().unwrap();
// load fence implied (I think)
let remaining = expected.len() - self.current_index.load(Ordering::Relaxed);
assert!(
remaining == 0,
"Exp... | code_fim | hard | {
"lang": "rust",
"repo": "slog-rs/stdlog",
"path": "/tests/slog2log.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ludwigpacifici/adventofcode2017 path: /src/bin/day6.rs
extern crate failure;
use failure::Error;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::string::String;
fn main() {
if let Err(ref err) = run() {
eprintln!("error: {:?}", err);
eprintln!(... | code_fim | hard | {
"lang": "rust",
"repo": "ludwigpacifici/adventofcode2017",
"path": "/src/bin/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_b(input: &str) -> usize {
let logic = |previous_count, count| count - previous_count;
looper(input, logic)
}
fn looper(input: &str, logic: fn(usize, usize) -> usize) -> usize {
let mut input = into_vec(input);
let mut checksums = HashMap::new();
let mut count = 0;
while !c... | code_fim | hard | {
"lang": "rust",
"repo": "ludwigpacifici/adventofcode2017",
"path": "/src/bin/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn init_logger(config: &AppConfig) {
let log_level = if cfg!(test) {
Level::Warn.to_string()
} else {
config.log_level.to_string()
};
Logger::with_env_or_str(&log_level)
.format(custom_format)
.start()
.ok();
info!("Initialized logger with l... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/src/server/logger.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: floric/secret-clan path: /backend/src/server/logger.rs
use crate::config::AppConfig;
use flexi_logger::{style, DeferredNow, Level, Logger, Record};
use log::info;
use std::thread;
<|fim_suffix|>pub fn init_logger(config: &AppConfig) {
let log_level = if cfg!(test) {
Level::Warn.to_s... | code_fim | hard | {
"lang": "rust",
"repo": "floric/secret-clan",
"path": "/backend/src/server/logger.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // user poll
let poll = UserPoll::new(1,false);
// mesg -> talk1 -> talk2 -> assert in loop
let mut spawner = RestartOrError;
let (inp_s, inp_r) = LocalRcChannel.new().unwrap();
let (sr,reg1) = poll_reg();
let mut inp_s = MioSend {
mpsc : inp_s,
set_ready : sr,
};
let tok1 = 1;... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-userpoll/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sr,reg1) = poll_reg();
let mut inp_s = MioSend {
mpsc : inp_s,
set_ready : sr,
};
let tok1 = 1;
// TODO transform miochannel to do this code (create a trait behind poll_reg for it : trait would
// replace poll_reg fn in mydhtcnof)
let inp_r = MioRecv {
mpsc : inp_r,
reg ... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-userpoll/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cheme/mydht path: /mydht-userpoll/src/test.rs
use service_pre::{
Spawner,
SpawnerYield,
spawn::restart::RestartOrError,
Service,
ServiceRestartable,
SpawnChannel,
SpawnSend,
SpawnRecv,
SpawnUnyield,
channels::{
rc::LocalRcChannel,
MioSend,
MioRecv,
},
error::... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-userpoll/src/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: the-electric-computer-company/ele path: /src/testing.rs
use common::*;
use env_logger;
<|fim_suffix|>static FLAG: Once = ONCE_INIT;
pub fn test_init() {
FLAG.call_once(|| env_logger::init());
}<|fim_middle|>/// `true` if running on Appveyor CI
pub fn running_on_appveyor() -> bool {
env::v... | code_fim | medium | {
"lang": "rust",
"repo": "the-electric-computer-company/ele",
"path": "/src/testing.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn test_init() {
FLAG.call_once(|| env_logger::init());
}<|fim_prefix|>// repo: the-electric-computer-company/ele path: /src/testing.rs
use common::*;
use env_logger;
<|fim_middle|>/// `true` if running on Appveyor CI
pub fn running_on_appveyor() -> bool {
env::var_os("APPVEYOR").is_some()
}
s... | code_fim | medium | {
"lang": "rust",
"repo": "the-electric-computer-company/ele",
"path": "/src/testing.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_answer: NewAnswer = NewAnswer::attach_user_id(new_answer, user_uuid);
let author_uuid = UserUuid(new_answer.author_uuid);
let answer_user: User = User::get_user(author_uuid, &conn)
.map_err(Error::simple_reject)?;
Question::put_ques... | code_fim | hard | {
"lang": "rust",
"repo": "zoosky/WeekendAtJoes4",
"path": "/backend/warp_server/src/routes/answer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zoosky/WeekendAtJoes4 path: /backend/warp_server/src/routes/answer.rs
use warp::Filter;
use warp::filters::BoxedFilter;
use warp::reply::Reply;
use warp;
use crate::util::json_body_filter;
use crate::state::jwt::normal_user_filter;
//use crate::db_integration::s.db.clone();
use wire::answer::New... | code_fim | hard | {
"lang": "rust",
"repo": "zoosky/WeekendAtJoes4",
"path": "/backend/warp_server/src/routes/answer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Question::put_question_on_floor(question_uuid, &conn)
.map_err(Error::simple_reject)?;
Answer::create_answer(new_answer, &conn)
.map(|answer| {
AnswerData {
answer,
user: answer_us... | code_fim | hard | {
"lang": "rust",
"repo": "zoosky/WeekendAtJoes4",
"path": "/backend/warp_server/src/routes/answer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn has_function(&self, func: Function<'ctx>) -> bool;
}
impl<'ctx> StackTrait<'ctx> for Stack<'ctx> {
fn top(&self) -> &StackFrame<'ctx> {
&self[self.len() - 1]
}
fn top_mut(&mut self) -> &mut StackFrame<'ctx> {
let id = self.len() - 1;
&mut self[id]
}
fn... | code_fim | medium | {
"lang": "rust",
"repo": "apicad1/artifact",
"path": "/src/src/analyzer/src/symbolic_execution/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apicad1/artifact path: /src/src/analyzer/src/symbolic_execution/memory.rs
use llir::values::*;
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use crate::semantics::rced::*;
pub type Memory = HashMap<Rc<Value>, Rc<Value>>;
pub type LocalMemory<'ctx> = HashMap<Instruction<'ctx>, Rc<V... | code_fim | hard | {
"lang": "rust",
"repo": "apicad1/artifact",
"path": "/src/src/analyzer/src/symbolic_execution/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aethertap/audio path: /audio-device/src/alsa/channel_area.rs
// component is work in progress
#![allow(unused)]
<|fim_suffix|>/// A memory-mapped channel area.
pub struct ChannelArea<'a> {
pub(super) pcm: &'a mut ptr::NonNull<alsa::snd_pcm_t>,
pub(super) area: *const alsa::snd_pcm_chann... | code_fim | easy | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/audio-device/src/alsa/channel_area.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A memory-mapped channel area.
pub struct ChannelArea<'a> {
pub(super) pcm: &'a mut ptr::NonNull<alsa::snd_pcm_t>,
pub(super) area: *const alsa::snd_pcm_channel_area_t,
pub(super) offset: c::c_ulong,
pub(super) frames: c::c_ulong,
}<|fim_prefix|>// repo: aethertap/audio path: /audio-de... | code_fim | easy | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/audio-device/src/alsa/channel_area.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: greendwin/rust_tutorials path: /calc/src/compiler/parser/block.rs
use std::rc::Rc;
use compiler::*;
use super::expr::parse_expr;
use self::AST::*;
pub fn parse_block(ctx: &mut ParseContext) -> ParseResult {
let loc = ctx.loc().clone(); // store block beginning
let mut body: Vec<AST>... | code_fim | hard | {
"lang": "rust",
"repo": "greendwin/rust_tutorials",
"path": "/calc/src/compiler/parser/block.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.