text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let _client = connect("127.0.0.1:9092".parse().unwrap()).await.unwrap();
println!("Stopping.");
}<|fim_prefix|>// repo: tychedelia/franz path: /src/bin/test.rs
use franz::client::connect;
<|fim_middle|>#[tokio::main]
async fn main() {
env_logger::init();
| code_fim | easy | {
"lang": "rust",
"repo": "tychedelia/franz",
"path": "/src/bin/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Group::default()
.direction(Direction::Vertical)
.margin(2)
.sizes(&[Size::Fixed(3), Size::Min(1)])
.render(t, &app.size, |t, chunks| {
Paragraph::default()
.style(Style::default().fg(Color::Yellow))
.block(Block::default().bo... | code_fim | hard | {
"lang": "rust",
"repo": "bestouff/tui-rs",
"path": "/examples/user_input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>enum Event {
Input(event::Key),
}
fn main() {
// Terminal initialization
let backend = MouseBackend::new().unwrap();
let mut terminal = Terminal::new(backend).unwrap();
// Channels
let (tx, rx) = mpsc::channel();
let input_tx = tx.clone();
// Input
thread::spawn(move... | code_fim | hard | {
"lang": "rust",
"repo": "bestouff/tui-rs",
"path": "/examples/user_input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bestouff/tui-rs path: /examples/user_input.rs
/// A simple example demonstrating how to handle user input. This is
/// a bit out of the scope of the library as it does not provide any
/// input handling out of the box. However, it may helps some to get
/// started.
///
/// This is a very simple ... | code_fim | hard | {
"lang": "rust",
"repo": "bestouff/tui-rs",
"path": "/examples/user_input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dinfuehr/dora path: /dora-frontend/src/typeck/constck.rs
use crate::error::msg::ErrorMessage;
use crate::sema::{ConstDefinition, ConstValue, Sema};
use crate::ty::SourceType;
use crate::typeck::body::{check_lit_char, check_lit_float, check_lit_int};
use dora_parser::ast::*;
pub struct ConstChe... | code_fim | hard | {
"lang": "rust",
"repo": "dinfuehr/dora",
"path": "/dora-frontend/src/typeck/constck.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ => {
let msg = ErrorMessage::ConstValueExpected;
self.sa.report(self.const_.file_id, expr.span(), msg);
return (SourceType::Error, ConstValue::None);
}
};
if !self.const_.ty().allows(self.sa, ty.clone()) {
... | code_fim | hard | {
"lang": "rust",
"repo": "dinfuehr/dora",
"path": "/dora-frontend/src/typeck/constck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> int mark[4];
float average;
count = 4;
sum = 0;
for (i=0; i < count; i++) {
mark[i] = i * 30;
sum = sum + mark[i];
average = avg(i + 1, mark);
if (average > 40) {
printf("%f\n", average);
}
}
}
"#;
let ast = semic::parse... | code_fim | hard | {
"lang": "rust",
"repo": "astralhpi/semi-c",
"path": "/parser/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astralhpi/semi-c path: /parser/src/lib.rs
pub mod semic;
pub mod ast;
pub mod ast_utils;
use ast::*;
use ast_utils::*;
#[test]
fn lit() {
assert_eq!(
semic::parse_Lit("\'a\'").unwrap().node,
LitKind::Char('a'));
assert_eq!(
semic::parse_Lit("\'Z\'").unwrap().nod... | code_fim | hard | {
"lang": "rust",
"repo": "astralhpi/semi-c",
"path": "/parser/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> float average;
count = 4;
sum = 0;
for (i=0; i < count; i++) {
mark[i] = i * 30;
sum = sum + mark[i];
average = avg(i + 1, mark);
if (average > 40) {
printf("%f\n", average);
}
}
}
"#;
let ast = semic::parse_Prog(code);
... | code_fim | hard | {
"lang": "rust",
"repo": "astralhpi/semi-c",
"path": "/parser/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Rust-Cookbook path: /Chapter01/tuples.rs
// Task : To explain tuples in rust
// Author : Vigneshwer
// Version : 1.0
// Date : 3 Dec 2016
use std::{i8};
fn main() {
<|fim_suffix|> // tuple operations
println!(" Name : {}", rand_tuple2.0);
println!(" Lucky no : {}", rand_tup... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Cookbook",
"path": "/Chapter01/tuples.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // tuple operations
println!(" Name : {}", rand_tuple2.0);
println!(" Lucky no : {}", rand_tuple2.1);
}<|fim_prefix|>// repo: PacktPublishing/Rust-Cookbook path: /Chapter01/tuples.rs
// Task : To explain tuples in rust
// Author : Vigneshwer
// Version : 1.0
// Date : 3 Dec 2016
use std::{i8};
fn m... | code_fim | medium | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Cookbook",
"path": "/Chapter01/tuples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nprice1/just-run path: /src/game/powerups.rs
units::Tile = units::Tile(0);
// Animation frames
const WIPEOUT_ANIMATION_FRAME: units::Tile = units::Tile(1);
const NUKE_ANIMATION_FRAME: units::Tile = units::Tile(0);
pub trait Powerup {
fn draw(&self, display: &mut graphics::Graphics);
fn upd... | code_fim | hard | {
"lang": "rust",
"repo": "nprice1/just-run",
"path": "/src/game/powerups.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nprice1/just-run path: /src/game/powerups.rs
FREEZE_FRAME: units::Tile = units::Tile(3);
const CRICKET_FRAME: units::Tile = units::Tile(4);
const BAD_FRAME: units::Tile = units::Tile(5);
const TELEPORT_FRAME: units::Tile = units::Tile(6);
const TELEPORT_ANIMATION_FRAME: units::Tile = units::Til... | code_fim | hard | {
"lang": "rust",
"repo": "nprice1/just-run",
"path": "/src/game/powerups.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_powerup
}
pub fn load_sprite(&mut self,
display: &mut graphics::Graphics,
movement: (sprite::Motion, sprite::Facing)) {
let asset_path = "assets/base/powerups.bmp".to_string();
let motion_frame = NUKE_FRAME;
let facing_frame = units::Tile(0);
let loaded... | code_fim | hard | {
"lang": "rust",
"repo": "nprice1/just-run",
"path": "/src/game/powerups.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdv9so/patricia_tree path: /examples/encode.rs
//! `cargo run --example encode --features binary-format < INPUT_FILE > OUTPUT_FILE`
use bytecodec::io::IoEncodeExt;
use bytecodec::null::NullEncoder;
use bytecodec::Encode;
use patricia_tree::{node::NodeEncoder, PatriciaSet};
use std::io::BufRead;
... | code_fim | medium | {
"lang": "rust",
"repo": "jdv9so/patricia_tree",
"path": "/examples/encode.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut encoder = NodeEncoder::new(NullEncoder);
encoder.start_encoding(set.into()).unwrap();
encoder.encode_all(std::io::stdout()).unwrap();
}<|fim_prefix|>// repo: jdv9so/patricia_tree path: /examples/encode.rs
//! `cargo run --example encode --features binary-format < INPUT_FILE > OUTPUT_F... | code_fim | medium | {
"lang": "rust",
"repo": "jdv9so/patricia_tree",
"path": "/examples/encode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut scene = Scene::new();
scene.add_sphere(Box::new(Sphere::new(
Vec3::new(1.0, 1.0, -1.0),
0.5,
Box::new(Lambertian {
albedo: Vec3::new(0.0, 0.0, 0.0),
}),
)));
let ray = Ray::new(Vec3::new(0.0, 0.0, 0.0)... | code_fim | hard | {
"lang": "rust",
"repo": "onbjerg/foton",
"path": "/src/scenery/scene.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onbjerg/foton path: /src/scenery/scene.rs
use super::hitable::{Hit, Hitable};
use core::ray::Ray;
pub struct Scene {
scenery: Vec<Box<dyn Hitable>>,
}
impl Scene {
pub fn new() -> Scene {
let scenery: Vec<Box<dyn Hitable>> = Vec::new();
Scene { scenery }
}
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "onbjerg/foton",
"path": "/src/scenery/scene.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn init(&mut self) {
unsafe {
consoleInit(self.as_raw());
}
}
pub fn update(&mut self) {
unsafe {
consoleUpdate(self.as_raw());
}
}
pub fn select(&mut self) {
unsafe {
consoleSelect(self.as_raw());
... | code_fim | hard | {
"lang": "rust",
"repo": "leo60228/libnx.rs",
"path": "/src/console.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leo60228/libnx.rs path: /src/console.rs
use std::ffi::c_void;
use std::marker::{PhantomData, PhantomPinned};
use std::pin::Pin;
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
static INITIALIZED: AtomicBool = AtomicBool::new(false);
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash... | code_fim | hard | {
"lang": "rust",
"repo": "leo60228/libnx.rs",
"path": "/src/console.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn crossing_distance_steps(a: &[Step], b: &[Step]) -> i32 {
let map_a = walk(a);
let map_b = walk(b);
let trail_a = map_a.keys().cloned().collect::<HashSet<_>>();
let trail_b = map_b.keys().cloned().collect::<HashSet<_>>();
let wire_crossings = trail_a.intersection(&trail_b);
let c... | code_fim | hard | {
"lang": "rust",
"repo": "sooda/advent-of-code",
"path": "/19/3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sooda/advent-of-code path: /19/3.rs
use std::io::{self, BufRead};
use std::collections::{HashSet, HashMap};
use std::str::FromStr;
use std::num::ParseIntError;
#[derive(Debug, PartialEq)]
struct Step {
direction: char,
length: i32
}
impl FromStr for Step {
type Err = ParseIntError;... | code_fim | hard | {
"lang": "rust",
"repo": "sooda/advent-of-code",
"path": "/19/3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmumn/chat path: /src/messages.rs
use actix::{Addr, Message};
use Session;
<|fim_suffix|>impl Message for ClientConnect {
type Result = u32;
}<|fim_middle|>pub struct ClientConnect {
addr: Addr<Session>,
}
| code_fim | easy | {
"lang": "rust",
"repo": "acmumn/chat",
"path": "/src/messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Message for ClientConnect {
type Result = u32;
}<|fim_prefix|>// repo: acmumn/chat path: /src/messages.rs
use actix::{Addr, Message};
<|fim_middle|>use Session;
pub struct ClientConnect {
addr: Addr<Session>,
}
| code_fim | medium | {
"lang": "rust",
"repo": "acmumn/chat",
"path": "/src/messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmumn/chat path: /src/messages.rs
use actix::{Addr, Message};
<|fim_suffix|>pub struct ClientConnect {
addr: Addr<Session>,
}
impl Message for ClientConnect {
type Result = u32;
}<|fim_middle|>use Session;
| code_fim | easy | {
"lang": "rust",
"repo": "acmumn/chat",
"path": "/src/messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> None
}
/// reversing should also rewind the iterator
fn reverse(&mut self) -> bool {
false
}
/// reversing should also rewind the iterator
fn reversed(&self) -> Option<Box<dyn Iter>> {
None
}
}
pub enum IterKind {
/// A handle referencing its backin... | code_fim | hard | {
"lang": "rust",
"repo": "DrSloth/Crabscript",
"path": "/src/c1/iter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DrSloth/Crabscript path: /src/c1/iter/mod.rs
use crate::{base::DayObject, variables::Variables};
use std::sync::Arc;
pub mod arr_iter;
pub mod map;
pub mod range;
//TODO make acquire not rewind anymore
//NOTE Against the previous plan iterators are internally clone and
//are not stored in an a... | code_fim | hard | {
"lang": "rust",
"repo": "DrSloth/Crabscript",
"path": "/src/c1/iter/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyyu2004/gitoxide path: /git-repository/tests/easy/oid.rs
mod ancestors {
use git_repository::prelude::ReferenceAccessExt;
<|fim_suffix|> let repo = crate::basic_repo()?;
assert_eq!(
repo.head()?
.into_fully_peeled_id()
.expect("b... | code_fim | easy | {
"lang": "rust",
"repo": "andyyu2004/gitoxide",
"path": "/git-repository/tests/easy/oid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let repo = crate::basic_repo()?;
assert_eq!(
repo.head()?
.into_fully_peeled_id()
.expect("born")?
.ancestors()?
.all()
.count(),
2,
"need a specific amount of commits"
... | code_fim | easy | {
"lang": "rust",
"repo": "andyyu2004/gitoxide",
"path": "/git-repository/tests/easy/oid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy)]
pub struct Spotlight {
pub color: Color,
pub position: Vector,
}
pub fn load_scene() -> Scene {
Scene {
camera: Camera {
position: 5.0 * J,
forward: 2.5 * K,
up: 3.0 * J,
right: 4.0 * I,
},
o... | code_fim | hard | {
"lang": "rust",
"repo": "SergeevPavel/rtrace",
"path": "/src/scene.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SergeevPavel/rtrace path: /src/scene.rs
use std::f64;
use math::*;
use figures::{Figure, Sphere, ChessBoard, IntersectionPoint};
use color::*;
use material::*;
#[derive(Debug, Clone, Copy)]
pub struct Camera {
pub position: Vector,
pub forward: Vector,
pub up: Vector,
pub righ... | code_fim | hard | {
"lang": "rust",
"repo": "SergeevPavel/rtrace",
"path": "/src/scene.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Scene {
pub fn trace(&self, ray: Ray) -> Option<IntersectionPoint> {
let mut min = f64::INFINITY;
let mut result: Option<IntersectionPoint> = None;
for obj in self.objects.iter() {
if obj.intersect(ray).is_some() {
let ip = obj.intersect(ray).un... | code_fim | hard | {
"lang": "rust",
"repo": "SergeevPavel/rtrace",
"path": "/src/scene.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>env, ctx),
Expr::LogicalNot(op) => op.eval(env, ctx),
Expr::Map(op) => op.eval(env, ctx),
Expr::Filter(op) => op.eval(env, ctx),
Expr::BoolToSigmaProp(op) => op.eval(env, ctx),
Expr::Upcast(op) => op.eval(env, ctx),
Expr::Downcast(op)... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-interpreter/src/eval/expr.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergotree-interpreter/src/eval/expr.rs
use ergotree_ir::mir::expr::Expr;
use ergotree_ir::mir::value::Value;
use super::Env;
use super::EvalContext;
use super::EvalError;
use super::Evaluable;
impl Evaluable for Expr {
fn eval(&self, env: &Env, ctx: &mut EvalC... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-interpreter/src/eval/expr.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>l(env, ctx),
Expr::OptionGetOrElse(op) => op.eval(env, ctx),
Expr::Negation(op) => op.eval(env, ctx),
Expr::BitInversion(op) => op.eval(env, ctx),
Expr::ForAll(op) => op.eval(env, ctx),
Expr::Tuple(op) => op.eval(env, ctx),
Expr::Deco... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergotree-interpreter/src/eval/expr.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msuriar/erbium path: /src/pktparser/mod.rs
/* Copyright 2021 Perry Lorier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/lic... | code_fim | hard | {
"lang": "rust",
"repo": "msuriar/erbium",
"path": "/src/pktparser/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_get_u16() {
let data = [1, 2, 3, 4];
let mut buffer = Buffer::new(&data);
assert_eq!(buffer.get_be16(), Some(0x0102));
assert_eq!(buffer.get_be16(), Some(0x0304));
assert_eq!(buffer.get_be16(), None)
}
#[test]
fn test_get_u32() {
let data = [1, 2, 3, 4, 5, 6, 7, 8]... | code_fim | hard | {
"lang": "rust",
"repo": "msuriar/erbium",
"path": "/src/pktparser/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = [1, 2, 3, 4, 5, 6, 7, 8];
let mut buffer = Buffer::new(&data);
assert_eq!(buffer.get_ipv4(), Some(std::net::Ipv4Addr::new(1, 2, 3, 4)));
assert_eq!(buffer.get_ipv4(), Some(std::net::Ipv4Addr::new(5, 6, 7, 8)));
assert_eq!(buffer.get_ipv4(), None)
}
#[test]
fn test_size() {
... | code_fim | hard | {
"lang": "rust",
"repo": "msuriar/erbium",
"path": "/src/pktparser/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("mult_acc4(0, 7, 8) = {}", mult_acc4(0, 7, 8));
println!(
"multiply_accumulate0(0, 7, 8) = {}",
multiply_accumulate0(0, 7, 8)
);
println!(
"multiply_accumulate(0, 7, 8) = {}",
8.multiply_accumulate(0, 7)
);
println!(
"multiply_accumu... | code_fim | medium | {
"lang": "rust",
"repo": "insideoutclub/fm2gp",
"path": "/ch07/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insideoutclub/fm2gp path: /ch07/src/main.rs
// Copyright (c) 2014 Alexander A. Stepanov and Daniel E. Rose
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without
// fee, provided that the above copyright notice ... | code_fim | medium | {
"lang": "rust",
"repo": "insideoutclub/fm2gp",
"path": "/ch07/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_no() {
assert!(!the_sue().test(&ur_sue!{ cats: 7, cars: 9 }));
}
#[test]
fn test_slide_yes() {
assert!(the_sue().test(&ur_sue!{ cats: 7, corgis: 2 }));
}
#[test]
fn test_slide_no() {
assert!(!the_sue().test(&ur_sue!{ cats: 7, corgis... | code_fim | hard | {
"lang": "rust",
"repo": "jld/adventofcode-2015-rs",
"path": "/day16/src/sue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn the_get() {
assert_eq!(UrSue::the().facts.get("trees"), Some(&3));
}
#[test]
fn test_yes() {
assert!(the_sue().test(&ur_sue!{ cats: 7, samoyeds: 2 }));
}
#[test]
fn test_no() {
assert!(!the_sue().test(&ur_sue!{ cats: 7, cars: 9 }));
... | code_fim | hard | {
"lang": "rust",
"repo": "jld/adventofcode-2015-rs",
"path": "/day16/src/sue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jld/adventofcode-2015-rs path: /day16/src/sue.rs
use std::collections::HashMap;
pub type Count = u8;
pub type Pred = Box<Fn(Count) -> bool>;
pub struct UrSue<'s> {
pub facts: HashMap<&'s str, Count>,
}
pub struct Sue<'s> {
pub ident: &'s str,
pub facts: HashMap<&'s str, Pred>,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "jld/adventofcode-2015-rs",
"path": "/day16/src/sue.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukealvarez/rtmp-switcher path: /src/lib.rs
//#![warn(clippy::pedantic)]
pub mod http;
pub mod input;
pub mod mixer;
pub mod output;
extern crate gstreamer as gst;
extern crate gstreamer_video as gst_video;
use crate::mixer::Error;
use serde::{Deserialize, Serialize};
type Result<T> = std::res... | code_fim | hard | {
"lang": "rust",
"repo": "lukealvarez/rtmp-switcher",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Display for Mux {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use Mux::*;
let s = match self {
FLV => "flvmux",
MP4 => "mp4mux",
MKV => "matroskamux",
};
f.write_str(s)
}
}
#[derive(serde... | code_fim | hard | {
"lang": "rust",
"repo": "lukealvarez/rtmp-switcher",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gidaio/opengl-renderer-rust path: /src/model_loader.rs
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
enum LineType {
Vertex,
Normal,
Texture,
Face,
Comment,
MaterialReference,
UseMaterial,
Unknown
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Gidaio/opengl-renderer-rust",
"path": "/src/model_loader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if indices.len() < 1 {
panic!("Malformed face tag!");
}
face_points.push(FacePoint {
vertex_index: indices[0],
texture_index: if indices.len() > 1 { indices[1] } else { 0 },... | code_fim | hard | {
"lang": "rust",
"repo": "Gidaio/opengl-renderer-rust",
"path": "/src/model_loader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Eq, PartialEq)]
pub enum Evaluation{ True, False, DoesNotMatter }
#[cfg(test)]
mod test {
use super::*;
#[test]
fn double_push() {
let mut ctx = Context::new();
let foo = ctx.var_from_int(0);
let bar = ctx.var_from_int(25);
ctx.assert(foo);
... | code_fim | hard | {
"lang": "rust",
"repo": "p4l1ly/z3-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: p4l1ly/z3-rust path: /src/lib.rs
//! High level interface to the Z3 SMT solver. Currently, only support for
//! boolean logic is implemented. It is therefore usable only as a SAT solver.
//! We have not yet considered thread safety or reasonable behaviour if multiple
//! contexts are used at onc... | code_fim | hard | {
"lang": "rust",
"repo": "p4l1ly/z3-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/game_control/change_screen_training.rs
use language::operations::{Operation, ParamInfo};
pub struct ChangeScreenTrainingOp;
const DOC : &str = "Opens the character screen for the troop that player is currently talking to. Only works in dial... | code_fim | hard | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/game_control/change_screen_training.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/winrt-rs path: /crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs
const DI_NEEDREBOOT: i32 = 256i32;
#[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"]
pub const DI_NEEDRESTART: i32 = 128i32;
#[doc = "*Required features: `\"W... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
SetupUninstallNewlyCopiedInfs(::core::mem::transmute(filequeue), flags, ::core::mem::transmute(reserved.unwrap_or(::std::ptr::null_mut())))
}
#[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xuxue1/yolo-dl path: /model-config/src/module/module.rs
use super::*;
use crate::common::*;
pub trait ModuleEx {
fn name(&self) -> Option<&ModuleName>;
fn input_paths(&self) -> ModuleInput<'_>;
fn output_shape(&self, input_shape: ShapeInput<'_>) -> Option<ShapeOutput>;
}
#[derive(D... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/model-config/src/module/module.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ModuleEx for Module {
fn name(&self) -> Option<&ModuleName> {
match self {
Module::Input(layer) => layer.name(),
Module::ConvBn2D(layer) => layer.name(),
Module::DeconvBn2D(layer) => layer.name(),
Module::UpSample2D(layer) => layer.name(),
... | code_fim | hard | {
"lang": "rust",
"repo": "Xuxue1/yolo-dl",
"path": "/model-config/src/module/module.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gwyn-art/Simple_2D_rst-amthst_game path: /src/states/menu.rs
use amethyst::{
prelude::*,
ecs::prelude::Entity
};
use crate::entities::{
create_camera,
initialise_menu
};
use crate::states::{
Game,
UserAction,
CurrentState,
GameRunning
};
pub struct Menu {
s... | code_fim | hard | {
"lang": "rust",
"repo": "gwyn-art/Simple_2D_rst-amthst_game",
"path": "/src/states/menu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn update(&mut self, data: &mut StateData<'_, GameData<'_, '_>>) -> SimpleTrans {
let mut game = data.world.write_resource::<Game>();
match game.user_action.take() {
Some(UserAction::StartGame) => Trans::Push(Box::new(GameRunning::default())),
Some(UserAction::Quit) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "gwyn-art/Simple_2D_rst-amthst_game",
"path": "/src/states/menu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>.read(18) == 1 {
if blip_ready {
blips += 1;
blip_ready = false;
// if blips % 10 == 0 {
println!("Blip {}", blips);
// }
}
} else {
blip_ready = true;
}
pigpio::slee... | code_fim | hard | {
"lang": "rust",
"repo": "tghartland/rpi_muons",
"path": "/pi_code/rustpi/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tghartland/rpi_muons path: /pi_code/rustpi/src/main.rs
extern crate testpi;
use testpi::pigpio;
fn main() {
let pi = pigpio::Pi::new();
pi.set_mode(32, pigpio::OUTPUT);
let on_time = 40;
let time_period = 80;
println!("Frequency: {}", 1000/time_period);
let mut total_fla... | code_fim | hard | {
"lang": "rust",
"repo": "tghartland/rpi_muons",
"path": "/pi_code/rustpi/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jyao1/rust-hypervisor-firmware path: /src/fat.rs
{
h.sectors
} else {
u32::from(h.legacy_sectors)
};
self.clusters = self.sectors / u32::from(h.sectors_per_cluster);
self.fat_type = if self.clusters < FAT12_MAX {
FatType::FAT... | code_fim | hard | {
"lang": "rust",
"repo": "jyao1/rust-hypervisor-firmware",
"path": "/src/fat.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.position >= self.size {
return Err(Error::EndOfFile);
}
if self.sector_offset == u64::from(self.filesystem.sectors_per_cluster) {
match self.filesystem.next_cluster(self.active_cluster) {
Err(e) => {
return Err(e)... | code_fim | hard | {
"lang": "rust",
"repo": "jyao1/rust-hypervisor-firmware",
"path": "/src/fat.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sub = match &residual[..]
.find('/')
.or_else(|| (&residual[..]).find('\\'))
{
None => {
let sub = &residual[..];
residual = "";
sub
}
Som... | code_fim | hard | {
"lang": "rust",
"repo": "jyao1/rust-hypervisor-firmware",
"path": "/src/fat.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: actix/actix-web path: /actix-multipart/src/lib.rs
//! Multipart form support for Actix Web.
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(clippy::borrow_interior_mutable_const, clippy::uninlined_format_args)]
#![doc(html_logo_url = "https://actix.rs/img/lo... | code_fim | medium | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-multipart/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod form;
pub use self::{
error::MultipartError,
server::{Field, Multipart},
};<|fim_prefix|>// repo: actix/actix-web path: /actix-multipart/src/lib.rs
//! Multipart form support for Actix Web.
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(clippy::borr... | code_fim | medium | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-multipart/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = format!("{}_{}pt", font_name, config.size);
let start = config.start;
let end = config.end;
let size = config.size as u8;
let height = max_height as u8;
let tokens: Vec<_> = chars
.iter()
.map(|c| {
let width = c.width;
let data =... | code_fim | hard | {
"lang": "rust",
"repo": "ryankurte/rust-micro-gui",
"path": "/src/bin/font-converter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryankurte/rust-micro-gui path: /src/bin/font-converter.rs
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use std::process::Command;
extern crate sdl2;
use std::env;
use std::path::Path;
use sdl2::pixels::{Color, PixelFormatEnum};
use sdl2::rect::Rect;
use sdl2::render::Te... | code_fim | hard | {
"lang": "rust",
"repo": "ryankurte/rust-micro-gui",
"path": "/src/bin/font-converter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Get signing string
let mut signing_string = String::new();
let mut auth_header = String::from(format!("Signature version=\"1\",keyId=\"{}/{}/{}\",algorithm=\"rsa-sha256\",headers=\"", creds.tenant_ocid, creds.user_ocid, creds.pub_cert));
signing_string.push_str(&format!("(request-targe... | code_fim | hard | {
"lang": "rust",
"repo": "mymindstorm/twilio-fax-client",
"path": "/src/request/bucket.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mymindstorm/twilio-fax-client path: /src/request/bucket.rs
use isahc::prelude::*;
use isahc::http::{Uri, HeaderMap};
use chrono::prelude::*;
use std::vec::Vec;
use std::io::prelude::*;
use std::fs::{File, metadata};
use openssl::rsa::Rsa;
use openssl::sha;
use openssl::pkey::PKey;
use openssl::s... | code_fim | hard | {
"lang": "rust",
"repo": "mymindstorm/twilio-fax-client",
"path": "/src/request/bucket.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request = request.method("GET")
.uri(endpoint)
.body(()).unwrap()
.send();
match request {
// TODO: error handling
Ok(result) => {
if result.status().is_success() {
Ok(result.into_body().text().unwrap().replace("\"", ""))
... | code_fim | hard | {
"lang": "rust",
"repo": "mymindstorm/twilio-fax-client",
"path": "/src/request/bucket.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emabee/rust-hdbconnect path: /hdbconnect/tests/test_012_connect_other_user.rs
extern crate serde;
mod test_utils;
use flexi_logger::LoggerHandle;
use hdbconnect::HdbResult;
use log::*;
use std::time::Instant;
#[test]
fn test_012_connect_other_user() -> HdbResult<()> {
let mut log_handle =... | code_fim | hard | {
"lang": "rust",
"repo": "emabee/rust-hdbconnect",
"path": "/hdbconnect/tests/test_012_connect_other_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let after: String = sys_conn
.query("SELECT CURRENT_USER FROM DUMMY")?
.try_into()?;
assert_eq!(after, "THEOTHERONE".to_string());
// _log_handle.pop_temp_spec();
Ok(())
}<|fim_prefix|>// repo: emabee/rust-hdbconnect path: /hdbconnect/tests/test_012_connect_other_user.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "emabee/rust-hdbconnect",
"path": "/hdbconnect/tests/test_012_connect_other_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simdimdim/CA01 path: /common/src/managers/assetmanager.rs
use crate::{managers::AssetManager, Entity, Mesh, Octonion, Quaternion};
use num_traits::{Float, Zero};
use std::{fs, io, path::PathBuf};
use tobj::{
Model,
{self},
};
<|fim_suffix|> pub fn load<T: Float + From<f32>>(
... | code_fim | hard | {
"lang": "rust",
"repo": "simdimdim/CA01",
"path": "/common/src/managers/assetmanager.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn load<T: Float + From<f32>>(
&self,
n: &str,
) -> Entity<T> {
let m = Mesh::<T>::from_tobj_to_mesh(
&self.objects[self.objects.iter().position(|r| r.name == n).unwrap()]
.mesh,
[T::zero(); 3],
0.5,
);
... | code_fim | hard | {
"lang": "rust",
"repo": "simdimdim/CA01",
"path": "/common/src/managers/assetmanager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Pick a corner.
if available_moves.contains(&1) || available_moves.contains(&3) || available_moves.contains(&7)
|| available_moves.contains(&9) {
let corner_rows = vec![1, 3];
let mut rng = rand::thread_rng();
... | code_fim | hard | {
"lang": "rust",
"repo": "muffledcry/rust_tic_tac_toe",
"path": "/rust_tic_tac_toe/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: muffledcry/rust_tic_tac_toe path: /rust_tic_tac_toe/src/game.rs
t_move(self, board: &Board) -> u8 {
match self.player_type {
PlayerType::Human => loop {
println!("Please choose a move.");
let mut move_pick = String::new();
std::... | code_fim | hard | {
"lang": "rust",
"repo": "muffledcry/rust_tic_tac_toe",
"path": "/rust_tic_tac_toe/src/game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //check diagonal
if board.player_choices.contains(&1) && board.player_choices.contains(&5) {
if available_moves.contains(&9) {
return 9
}
}
if board.player_choices.contains(&1) && board.player_choices.contains(&9) {
if ava... | code_fim | hard | {
"lang": "rust",
"repo": "muffledcry/rust_tic_tac_toe",
"path": "/rust_tic_tac_toe/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match pop_costack_u8() {
Ok(v) => push_costack_u8(v),
Err(RecoverableError::ItemDoesntExist) => println!("Error in pop_costack_u8(): {}", ERR_STR_ITEMDOESNTEXIST),
Err(RecoverableError::StackItemTooLarge) => println!("Error in pop_costack_u8(): {}", ERR_STR_STACKITEMTOOLARGE),
... | code_fim | hard | {
"lang": "rust",
"repo": "earlgreytech/neutron-host",
"path": "/tests/contracts/default_env/src/bin/neutron_star_costack_mirror_batch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: earlgreytech/neutron-host path: /tests/contracts/default_env/src/bin/neutron_star_costack_mirror_batch.rs
//! Directly plug a `main` symbol instead of using `#[entry]`
#![deny(warnings)]
#![no_main]
#![no_std]
use neutron_common::*;
use neutron_star::syscalls::*;
use neutron_star::*;
use neutr... | code_fim | hard | {
"lang": "rust",
"repo": "earlgreytech/neutron-host",
"path": "/tests/contracts/default_env/src/bin/neutron_star_costack_mirror_batch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NuiLab/simon-says-touchpad path: /src/engine.rs
use afi;
pub struct Game {
input: afi::Input,
}
<|fim_suffix|> // Do some stuff...
let d = [if input[0] > 120. { 1. } else { 0. },
if input[1] > 120. { 1. } else { 0. },
if input[2] > 120. { 1.... | code_fim | medium | {
"lang": "rust",
"repo": "NuiLab/simon-says-touchpad",
"path": "/src/engine.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Do some stuff...
let d = [if input[0] > 120. { 1. } else { 0. },
if input[1] > 120. { 1. } else { 0. },
if input[2] > 120. { 1. } else { 0. },
if input[3] > 120. { 1. } else { 0. }];
d
}
}<|fim_prefix|>// repo: NuiLab/simon-... | code_fim | medium | {
"lang": "rust",
"repo": "NuiLab/simon-says-touchpad",
"path": "/src/engine.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rokinsky/next.js-rust path: /crate/src/factorial.rs
use wasm_bindgen::prelude::*;
<|fim_suffix|> match n {
0 => acc,
_ => go(n - 1, n * acc),
}
}
go(n, 1)
}<|fim_middle|>#[wasm_bindgen]
pub fn factorial(n: u64) -> u64 {
fn go(n: u64, acc: u64)... | code_fim | medium | {
"lang": "rust",
"repo": "rokinsky/next.js-rust",
"path": "/crate/src/factorial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match n {
0 => acc,
_ => go(n - 1, n * acc),
}
}
go(n, 1)
}<|fim_prefix|>// repo: rokinsky/next.js-rust path: /crate/src/factorial.rs
use wasm_bindgen::prelude::*;
<|fim_middle|>#[wasm_bindgen]
pub fn factorial(n: u64) -> u64 {
fn go(n: u64, acc: u64)... | code_fim | medium | {
"lang": "rust",
"repo": "rokinsky/next.js-rust",
"path": "/crate/src/factorial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>inline(always)]
pub fn ic4lh(&self) -> IC4LH_R {
IC4LH_R::new(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 10 - Interrupt Enable for the RTC Input Capture Channel 0"]
#[inline(always)]
pub fn ic0irqen(&self) -> IC0IRQEN_R {
IC0IRQEN_R::new(((self.bits >> 10) & 0x01) !... | code_fim | hard | {
"lang": "rust",
"repo": "Colin-Suckow/ADuCM302x",
"path": "/src/rtc0/cr2ic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Colin-Suckow/ADuCM302x path: /src/rtc0/cr2ic.rs
#[doc = "Reader of register CR2IC"]
pub type R = crate::R<u16, super::CR2IC>;
#[doc = "Writer for register CR2IC"]
pub type W = crate::W<u16, super::CR2IC>;
#[doc = "Register CR2IC `reset()`'s with value 0x83a0"]
impl crate::ResetValue for super::C... | code_fim | hard | {
"lang": "rust",
"repo": "Colin-Suckow/ADuCM302x",
"path": "/src/rtc0/cr2ic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_approx_eq(s.x, 1.0);
}
#[test]
fn nonpositive_timestep_doesnt_change() {
let mut s = Spring::new();
s.x_target = 1.0;
s.v_target = 0.0;
s.x = 0.5;
s.v = 0.5;
// update with dt == 0
s.update(0.0);
assert_eq!(s.x, 0... | code_fim | hard | {
"lang": "rust",
"repo": "huwb/learningrust",
"path": "/src/spring.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = Spring::new();
s.x_target = 1.0;
s.v_target = 0.0;
s.update(1.5);
assert_approx_eq(s.x, 0.4436);
}
#[test]
fn update_stiff() {
let mut s = Spring::new();
s.x_target = 1.0;
s.v_target = 0.0;
s.undamped_angul... | code_fim | hard | {
"lang": "rust",
"repo": "huwb/learningrust",
"path": "/src/spring.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huwb/learningrust path: /src/spring.rs
pub struct Spring {
x: f32,
v: f32,
x_target: f32,
v_target: f32,
undamped_angular_freq: f32,
damping_ratio: f32,
}
impl Spring {
const MAX_DT: f32 = 1.0 / 60.0;
fn new() -> Spring {
Spring {
x: 0.0,
... | code_fim | hard | {
"lang": "rust",
"repo": "huwb/learningrust",
"path": "/src/spring.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<ByteError> for RuleError
{
fn from(error: ByteError) -> Self
{
RuleError::InvalidByte(error.to_string())
}
}
impl From<DurationError> for RuleError
{
fn from(error: DurationError) -> Self
{
RuleError::InvalidDuration(error.to_string())
}
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "songokas/rust-simple-tunnel",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: songokas/rust-simple-tunnel path: /src/error.rs
use byte_unit::ByteError;
use humantime::DurationError;
use ipnetwork::IpNetworkError;
use std::io;
use std::net;
#[derive(Debug)]
pub enum RuleError
{
InvalidNetwork(String),
InvalidByte(String),
InvalidDuration(String),
}
#[derive(D... | code_fim | medium | {
"lang": "rust",
"repo": "songokas/rust-simple-tunnel",
"path": "/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(v)
}
pub fn save_config_db(config_data: &JuliaupConfig) -> Result<()> {
let path =
get_juliaupconfig_path().with_context(|| "Failed to determine configuration file path.")?;
let display = path.display();
let file = File::create(&path).with_context(|| {
format!(
... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipVinc/juliaup",
"path": "/src/config_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reader = BufReader::new(file);
let v: JuliaupConfig = serde_json::from_reader(reader).with_context(|| {
format!(
"Failed to parse configuration file '{}' for reading.",
display
)
})?;
Ok(v)
}
pub fn save_config_db(config_data: &JuliaupConfig) ... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipVinc/juliaup",
"path": "/src/config_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilipVinc/juliaup path: /src/config_file.rs
use crate::utils::get_juliaupconfig_path;
use anyhow::{bail, Context, Result};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufReader, ErrorKind};
#[derive(Serialize, Deserialize, Clone)]
pub st... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipVinc/juliaup",
"path": "/src/config_file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rrp,
b" (seed %u, test nb %u) \n\x00" as *const u8 as *const libc::c_char,
seed,
testNb,
);
exit(-1i32);
}
crcVerif = XXH64(
verifBuff as *const libc::c_void,
verifSize,
0i32 as libc::c_ulonglong,
);
if crcOrig !=... | code_fim | hard | {
"lang": "rust",
"repo": "mcroomp/fse-rs",
"path": "/src/converted/fuzzer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t libc::c_void =
malloc(sizeCompressed.wrapping_sub(1i32 as libc::c_ulong));
if tooSmallDBuffer.is_null() {
fprintf(
__stderrp,
b"Error => \x00" as *const u8 as *const libc::c_char,
);
fprin... | code_fim | hard | {
"lang": "rust",
"repo": "mcroomp/fse-rs",
"path": "/src/converted/fuzzer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcroomp/fse-rs path: /src/converted/fuzzer.rs
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | code_fim | hard | {
"lang": "rust",
"repo": "mcroomp/fse-rs",
"path": "/src/converted/fuzzer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Arc {
inner: self.inner.clone(),
}
}
}
impl<T> Drop for Arc<T> {
fn drop(&mut self) {
self.inner.ref_cnt.fetch_sub(1, AcqRel);
}
}
impl<T: Default> Default for Arc<T> {
fn default() -> Arc<T> {
Arc::new(Default::default())
}
}
impl<T> From... | code_fim | hard | {
"lang": "rust",
"repo": "Ekleog/loom",
"path": "/src/sync/arc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ptr = &*this as *const _;
mem::forget(this);
ptr as *const T
}
/// Constructs an `Arc` from a raw pointer.
pub unsafe fn from_raw(ptr: *const T) -> Self {
let inner = Rc::from_raw(ptr as *const Inner<T>);
Arc { inner }
}
}
impl<T> ops::Deref fo... | code_fim | hard | {
"lang": "rust",
"repo": "Ekleog/loom",
"path": "/src/sync/arc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ekleog/loom path: /src/sync/arc.rs
use super::atomic::AtomicUsize;
use std::ops;
use std::rc::Rc;
use std::sync::atomic::Ordering::*;
/// Mock implementation of `std::sync::Arc`.
#[derive(Debug)]
pub struct Arc<T> {
inner: Rc<Inner<T>>,
}
#[derive(Debug)]
struct Inner<T> {
// This mu... | code_fim | hard | {
"lang": "rust",
"repo": "Ekleog/loom",
"path": "/src/sync/arc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielvschoor/sc2-pathlib path: /tests/test_map.rs
use common::{get_choke_map, read_vec_from_file};
use sc2pathlib::mapping::map::Map;
mod common;
<|fim_suffix|> let map = get_choke_map();
let r = map.get_borders();
assert_eq!(r.len(), 20 + 16);
}
// Test not working, ignored for no... | code_fim | hard | {
"lang": "rust",
"repo": "danielvschoor/sc2-pathlib",
"path": "/tests/test_map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let map = get_choke_map();
let r = map.get_chokes();
assert_eq!(r.len(), 1);
}<|fim_prefix|>// repo: danielvschoor/sc2-pathlib path: /tests/test_map.rs
use common::{get_choke_map, read_vec_from_file};
use sc2pathlib::mapping::map::Map;
mod common;
#[test]
fn test_find_path_map() {
<|fim_midd... | code_fim | hard | {
"lang": "rust",
"repo": "danielvschoor/sc2-pathlib",
"path": "/tests/test_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Bind to a ZMQ endpoint at the given address.
pub fn bind(self, endpoint: &str) -> crate::Result<T> {
if let Some(err) = self.error {
return Err(err);
}
let socket = self.socket.unwrap();
socket.bind(endpoint)?;
T::from_zmq_socket(socket)
... | code_fim | hard | {
"lang": "rust",
"repo": "cetra3/tmq",
"path": "/src/socket_builder.rs",
"mode": "spm",
"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.