text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let matches = clap::App::new("Your_Name")
.version("0.1.0")
.author("someone")
.arg(clap::Arg::with_name("num-connections")
.long("num-connections")
.required(true)
.takes_value(true))
.get_matches();
let num_conns: u32 = matc... | code_fim | medium | {
"lang": "rust",
"repo": "akshayknarayan/ccp-class-assignment",
"path": "/your_code/src/bin/my_cool_alg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akshayknarayan/ccp-class-assignment path: /your_code/src/bin/my_cool_alg.rs
extern crate clap;
extern crate generic_cong_avoid;
extern crate portus;
#[macro_use]
extern crate slog;
extern crate your_code; // TODO change
<|fim_suffix|> let num_conns: u32 = matches.value_of("num-connections").... | code_fim | hard | {
"lang": "rust",
"repo": "akshayknarayan/ccp-class-assignment",
"path": "/your_code/src/bin/my_cool_alg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BusSuspendRegister {
pub fn set_transfer_on_datx_line(&mut self, transferring: bool) {
self.val.set_bit(0, transferring);
}
pub fn transfer_on_datx_line(&self) -> bool {
self.val.get_bit(0)
}
pub fn set_request_release_status(&mut self, release: bool) {
s... | code_fim | medium | {
"lang": "rust",
"repo": "mvniekerk/mci-rs",
"path": "/mci/src/registers/sdio/cccr/bus_suspend.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvniekerk/mci-rs path: /mci/src/registers/sdio/cccr/bus_suspend.rs
use crate::registers::register_address::RegisterAddress;
use bit_field::BitField;
pub struct BusSuspendRegister {
pub val: u8,
}
<|fim_suffix|> pub fn set_request_release_status(&mut self, release: bool) {
self.v... | code_fim | hard | {
"lang": "rust",
"repo": "mvniekerk/mci-rs",
"path": "/mci/src/registers/sdio/cccr/bus_suspend.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Origen-SDK/o2 path: /rust/origen/src/prog_gen/processors/final_model_extract.rs
use crate::prog_gen::{
Bin, BinType, FlowCondition, LimitSelector, Model, VariableOperation, VariableType, PGM,
};
use crate::Result;
use origen_metal::ast::{Node, Processor, Return};
/// This extracts all defin... | code_fim | hard | {
"lang": "rust",
"repo": "Origen-SDK/o2",
"path": "/rust/origen/src/prog_gen/processors/final_model_extract.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(match &node.attrs {
PGM::ResourcesFilename(name, kind) => {
self.model.set_resources_filename(name.to_owned(), kind);
Return::Unmodified
}
PGM::Condition(cond) => {
match cond {
FlowCondition... | code_fim | hard | {
"lang": "rust",
"repo": "Origen-SDK/o2",
"path": "/rust/origen/src/prog_gen/processors/final_model_extract.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: octopus-network/octopus-relay-contract path: /tests/sim/default.rs
use crate::utils::{init, init_by_previous, register_user};
use near_sdk::json_types::U128;
use near_sdk::serde_json::json;
use near_sdk_sim::{to_yocto, ExecutionResult, UserAccount, DEFAULT_GAS};
use octopus_relay::types::{
A... | code_fim | hard | {
"lang": "rust",
"repo": "octopus-network/octopus-relay-contract",
"path": "/tests/sim/default.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn default_stake(
user: &UserAccount,
oct: &UserAccount,
relay: &UserAccount,
validator_id: &str,
) -> (ExecutionResult, u128) {
register_user(&relay);
let transfer_amount = to_yocto("200");
let mut msg = "stake,testchain,".to_owned();
msg.push_str(validator_id.to_strin... | code_fim | hard | {
"lang": "rust",
"repo": "octopus-network/octopus-relay-contract",
"path": "/tests/sim/default.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Create an error:badmatch exception
// Structure: badmatch(Term)
define_opcode!(_vm, _ctx, curr_p,
name: OpcodeBadmatch, arity: 1,
run: { Self::badmatch(curr_p, val) },
args: load(val),
);
impl OpcodeBadmatch {
#[inline]
pub fn badmatch(curr_p: &mut Process, val: Term) -> RtResult<DispatchRes... | code_fim | hard | {
"lang": "rust",
"repo": "kvakvs/ErlangRT",
"path": "/lib-erlangrt/src/beam/opcodes/op_execution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvakvs/ErlangRT path: /lib-erlangrt/src/beam/opcodes/op_execution.rs
//! Module implements opcodes related to execution control: Calls, jumps,
//! returns etc.
use crate::{
beam::disp_result::DispatchResult,
defs::exc_type::ExceptionType,
emulator::{
gen_atoms,
heap::THeapOwner,
... | code_fim | hard | {
"lang": "rust",
"repo": "kvakvs/ErlangRT",
"path": "/lib-erlangrt/src/beam/opcodes/op_execution.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl OpcodeCallExt {
#[inline]
pub fn call_ext(
vm: &mut VM,
ctx: &mut RuntimeContext,
curr_p: &mut Process,
arity: usize,
dst: Term,
) -> RtResult<DispatchResult> {
let args = ctx.registers_slice(0, arity);
ctx.debug_trace_call("opcode:call_ext", dst, 0, arity);
gene... | code_fim | hard | {
"lang": "rust",
"repo": "kvakvs/ErlangRT",
"path": "/lib-erlangrt/src/beam/opcodes/op_execution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!("install helper script content:");
writeln!(script, "ECHO OFF")?;
trace!("{}", &install_command);
writeln!(script, "{}", install_command)?;
}
info!("install {}", installer.display());
let installer_script = install_helper.int... | code_fim | medium | {
"lang": "rust",
"repo": "Larusso/unity-version-manager",
"path": "/install/uvm_install_core/src/sys/win/msi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let script = install_helper.as_file_mut();
let install_command = self
.cmd()
.replace("/i", &format!(r#"/i "{}""#, installer.display()));
trace!("install helper script content:");
writeln!(script, "ECHO OFF")?;
... | code_fim | hard | {
"lang": "rust",
"repo": "Larusso/unity-version-manager",
"path": "/install/uvm_install_core/src/sys/win/msi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Larusso/unity-version-manager path: /install/uvm_install_core/src/sys/win/msi.rs
use crate::error::*;
use crate::*;
use std::io::Write;
use tempfile::Builder;
pub struct Msi;
pub type ModuleMsiInstaller = Installer<UnityModule, Msi, InstallerWithCommand>;
impl InstallHandler for ModuleMsiInsta... | code_fim | hard | {
"lang": "rust",
"repo": "Larusso/unity-version-manager",
"path": "/install/uvm_install_core/src/sys/win/msi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nagisa/math.rs path: /src/cos.rs
// Read sin.rs for implementation details.
use core::f64;
use core::f64::consts::{PI, FRAC_PI_2, FRAC_PI_4};
use utils::{FRAC_3PI_4, FRAC_5PI_4, FRAC_3PI_2, FRAC_7PI_4, PI_2};
use sin::_sin;
use utils::Float;
<|fim_suffix|> return 1.0 + (i * D2 * i) + (i2 ... | code_fim | hard | {
"lang": "rust",
"repo": "nagisa/math.rs",
"path": "/src/cos.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> i = i % PI_2;
let iabs = i.abs();
if iabs <= FRAC_PI_4 {
_cos(i)
} else if iabs <= FRAC_3PI_4 {
-_sin(iabs - FRAC_PI_2)
} else if iabs <= FRAC_5PI_4 {
-_cos(iabs - PI)
} else if iabs <= FRAC_7PI_4 {
_sin(iabs - FRAC_3PI_2)
} else {
_cos(... | code_fim | hard | {
"lang": "rust",
"repo": "nagisa/math.rs",
"path": "/src/cos.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const KEYPAD_SIZE: Size = Size::new(DISP_WIDTH - 2, BTN_SIZE.height * 4);
pub const DIALIER_VGID: ViewGroupId = 0;<|fim_prefix|>// repo: jonlamb-gh/pinephone-rs-display-prototype path: /src/config.rs
//! Configs
use crate::viewable::ViewGroupId;
use embedded_graphics::prelude::*;
<|fim_middle|>pub... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/pinephone-rs-display-prototype",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/pinephone-rs-display-prototype path: /src/config.rs
//! Configs
use crate::viewable::ViewGroupId;
use embedded_graphics::prelude::*;
pub const DISP_WIDTH: u32 = 720;
pub const DISP_HEIGHT: u32 = 1440;
//pub const DISP_CENTER: Point = Point::new(DISP_WIDTH as i32 / 2, DISP_HEIGHT as ... | code_fim | medium | {
"lang": "rust",
"repo": "jonlamb-gh/pinephone-rs-display-prototype",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arma3modorganizer/delta_patch path: /src/rollsum.rs
// rdiff(rust) -- library for network deltas
// Copyright 2018 Martin Pool.
//! Weak rolling checksums: the first layer of rdiff finding similar blocks between
//! files, even with insertions or removals.
#![allow(dead_code)]
use std::num::W... | code_fim | hard | {
"lang": "rust",
"repo": "arma3modorganizer/delta_patch",
"path": "/src/rollsum.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c_out = Wrapping(c_out as u16);
self.s1 -= c_out + Rollsum1::CHAR_OFFSET;
self.s2 -= self.count * (c_out + Rollsum1::CHAR_OFFSET);
self.count -= Wrapping(1);
}
fn rotate(&mut self, c_out: u8, c_in: u8) {
let c_in = Wrapping(c_in as u16);
let c_o... | code_fim | hard | {
"lang": "rust",
"repo": "arma3modorganizer/delta_patch",
"path": "/src/rollsum.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn run<S: Solution>() {
let test_cases = [
((5, &[3, 4, 1, 1, 0, 0] as &[_]), 1),
((3, &[0, 0, 0, 0]), -1),
((7, &[1, 2, 1, 0, 2, 1, 0, 1]), 3),
];
for ((n, ranges), expected) in test_cases {
assert_eq!(S::min_taps(n, ranges.... | code_fim | easy | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1326_minimum_number_of_taps_to_open_to_water_a_garden/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1326_minimum_number_of_taps_to_open_to_water_a_garden/mod.rs
pub mod greedy;
pub trait Solution {
fn min_taps(n: i32, ranges: Vec<i32>) -> i32;
}
<|fim_suffix|> pub fn run<S: Solution>() {
let test_cases = [
((5, &[3, 4, 1, 1, 0, 0]... | code_fim | easy | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1326_minimum_number_of_taps_to_open_to_water_a_garden/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zakora/adventofcode path: /2016/rust/day3/src/main.rs
extern crate regex;
use regex::Regex;
use std::io::{self, Read};
use std::str::FromStr;
fn is_triangle(a: u32, b: u32, c: u32) -> bool {
(a + b > c) && (a + c > b) && (b + c > a)
}
fn main() {
let mut buffer = String::new();
io... | code_fim | hard | {
"lang": "rust",
"repo": "zakora/adventofcode",
"path": "/2016/rust/day3/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> # third line
\s*(?P<c>\d+)\s*(?P<f>\d+)\s*(?P<i>\d+)\n")
.expect("failed to compile regex");
for capb in reb.captures_iter(&buffer) {
let (a, b, c, d, e, f, g, h, i) = (
u32::from_str(&capb["a"]).expect("failed to cast a"),
u32::from_str(&capb["b... | code_fim | hard | {
"lang": "rust",
"repo": "zakora/adventofcode",
"path": "/2016/rust/day3/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn open(&self, doc: String, ui: &UserInterface) {
ui.send_message(TextMessage::text(
self.text,
MessageDirection::ToWidget,
doc,
));
ui.send_message(WindowMessage::open(
self.window,
MessageDirection::ToWidget,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/utils/doc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /editor/src/utils/doc.rs
use fyrox::{
core::pool::Handle,
gui::{
formatted_text::WrapMode,
message::MessageDirection,
scroll_viewer::ScrollViewerBuilder,
text::TextMessage,
text_box::TextBoxBuilder,
widget::WidgetBui... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/utils/doc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DocWindow {
pub fn new(ctx: &mut BuildContext) -> Self {
let text;
let window = WindowBuilder::new(
WidgetBuilder::new()
.with_name("DocPanel")
.with_width(400.0)
.with_height(300.0),
)
.open(false)
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/utils/doc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BonsaiDen/shooter-rs path: /shared/src/level/traits.rs
// External Dependencies ------------------------------------------------------
use std::f32;
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, decode};
use lithium::{BaseLevel, Renderer};
// Internal Dependencies ------------... | code_fim | hard | {
"lang": "rust",
"repo": "BonsaiDen/shooter-rs",
"path": "/shared/src/level/traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mr = current.r - last.r;
SharedState {
r: (last.r + mr.sin().atan2(mr.cos()) * u) % (f32::consts::PI * 2.0),
x: x - self.border as f32,
y: y - self.border as f32,
mx: last.mx,
my: last.my,
flags: current.flags
... | code_fim | hard | {
"lang": "rust",
"repo": "BonsaiDen/shooter-rs",
"path": "/shared/src/level/traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn to_boolean(&self, idx: isize) -> bool;
fn to_integer(&self, idx: isize) -> i64;
fn to_integerx(&self, idx: isize) -> Option<i64>;
fn to_number(&self, idx: isize) -> f64;
fn to_numberx(&self, idx: isize) -> Option<f64>;
fn to_string(&self, idx: isize) -> String;
fn to_stringx... | code_fim | hard | {
"lang": "rust",
"repo": "fengjixuchui/luago-book",
"path": "/code/rust/ch06/src/api/lua_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengjixuchui/luago-book path: /code/rust/ch06/src/api/lua_state.rs
pub trait LuaState {
/* basic stack manipulation */
fn get_top(&self) -> isize;
fn abs_index(&self, idx: isize) -> isize;
fn check_stack(&mut self, n: usize) -> bool;
fn pop(&mut self, n: usize);
fn copy(&... | code_fim | hard | {
"lang": "rust",
"repo": "fengjixuchui/luago-book",
"path": "/code/rust/ch06/src/api/lua_state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn to_stringx(&self, idx: isize) -> Option<String>;
/* push functions (rust -> stack) */
fn push_nil(&mut self);
fn push_boolean(&mut self, b: bool);
fn push_integer(&mut self, n: i64);
fn push_number(&mut self, n: f64);
fn push_string(&mut self, s: String);
/* comparison a... | code_fim | hard | {
"lang": "rust",
"repo": "fengjixuchui/luago-book",
"path": "/code/rust/ch06/src/api/lua_state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut args = std::env::args_os();
assert!(!args.next().is_none(), "we should receive an argv[0]");
assert!(
args.next().is_none(),
"we aren't expecting any further arguments"
);
}<|fim_prefix|>// repo: iCodeIN/mustang path: /examples/test-args.rs
mustang::can_run_this!()... | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/mustang",
"path": "/examples/test-args.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/mustang path: /examples/test-args.rs
mustang::can_run_this!();
<|fim_suffix|> let mut args = std::env::args_os();
assert!(!args.next().is_none(), "we should receive an argv[0]");
assert!(
args.next().is_none(),
"we aren't expecting any further arguments"
)... | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/mustang",
"path": "/examples/test-args.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: victor-zed/tink-rust path: /signature/src/ecdsa_signer_key_manager.rs
// Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//... | code_fim | hard | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/signature/src/ecdsa_signer_key_manager.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Validate the given [`EcdsaPrivateKey`](tink_proto::EcdsaPrivateKey) and return
/// the parameters.
fn validate_key(key: &tink_proto::EcdsaPrivateKey) -> Result<tink_proto::EcdsaParams, TinkError> {
tink_core::keyset::validate_key_version(key.version, ECDSA_SIGNER_KEY_VERSION)
.map_err(|e| ... | code_fim | hard | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/signature/src/ecdsa_signer_key_manager.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input
.split(',')
.enumerate()
.filter(|&(_, v)| v != "x")
.map(|(idx, v)| {
let v = str::parse::<i64>(v)?;
Ok((v, v - idx as i64))
})
.collect()
}
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
if a == 0 {
(b, 0, 1)
... | code_fim | hard | {
"lang": "rust",
"repo": "vojta7/aoc2020",
"path": "/day13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res: i64 = remainders
.iter()
.zip(inv.iter())
.map(|(&r, &i)| *r as i64 * i)
.sum();
Ok(res % prod)
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = read_to_string(args().nth(1).ok_or("No input file")?)?;
let p1 = part1(&input)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "vojta7/aoc2020",
"path": "/day13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vojta7/aoc2020 path: /day13/src/main.rs
use std::{env::args, fs::read_to_string};
fn parse_bus_ids(input: &str) -> Result<Vec<i32>, std::num::ParseIntError> {
input
.split(',')
.filter(|&v| v != "x")
.map(str::parse::<i32>)
.collect()
}
<|fim_suffix|> let... | code_fim | hard | {
"lang": "rust",
"repo": "vojta7/aoc2020",
"path": "/day13/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cedretaber/codes_for_atcoder path: /abc/044/b.rs
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
... | code_fim | medium | {
"lang": "rust",
"repo": "cedretaber/codes_for_atcoder",
"path": "/abc/044/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let w = get!(String).chars().collect::<Vec<char>>();
let mut cs = vec![0; 26];
for c in w {
cs[((c as i32) - ('a' as i32)) as usize] += 1;
}
for c in cs {
if c%2 == 1 {
println!("No");
return;
}
}
println!("Yes");
}<|fim_prefix|>/... | code_fim | medium | {
"lang": "rust",
"repo": "cedretaber/codes_for_atcoder",
"path": "/abc/044/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dylanbraithwaite/cubical path: /src/ast/terms/face_systems/composition.rs
use std::fmt::{Display, Formatter, Error as FmtErr};
use crate::ast::traits::*;
use crate::ast::{Term, Expr, FaceSystem, Path, Var, Sigma};
use crate::context::Context;
use crate::interval::{IntervalDnf, IsNegated};
use c... | code_fim | hard | {
"lang": "rust",
"repo": "dylanbraithwaite/cubical",
"path": "/src/ast/terms/face_systems/composition.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let witness_left_proj = Term::new(Expr::left_proj(witness.clone()), left_type.expr.clone());
let witness_right_proj = Term::new(Expr::left_proj(witness.clone()), left_type.expr.clone());
let a = Expr::fill(
Var::new(0),
left_type.clone(),
left_system.clone(),
w... | code_fim | hard | {
"lang": "rust",
"repo": "dylanbraithwaite/cubical",
"path": "/src/ast/terms/face_systems/composition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::spawn(io::write_all(socket, noise).map(|_| ()).map_err(|err| {
// Handle error by printing to STDOUT.
error!("error writing noise to socket = {:?}", err);
}));
Ok(())
})
.map_err(|err| {
// Handle error ... | code_fim | hard | {
"lang": "rust",
"repo": "sindreij/crucio",
"path": "/src/modes/random_tcp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sindreij/crucio path: /src/modes/random_tcp.rs
/// This will return a fixed amount of noise, but not valid http.
use std::net::SocketAddr;
use log::{error, info};
use rand::{rngs::StdRng, FromEntropy, RngCore};
use tokio;
use tokio::io;
use tokio::net::TcpListener;
use tokio::prelude::*;
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "sindreij/crucio",
"path": "/src/modes/random_tcp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, (time, fps_counter, mut ui_text, finder): Self::SystemData) {
if let None = self.fps_display {
if let Some(fps_entity) = finder.find("fps_text") {
self.fps_display = Some(fps_entity);
}
}
if let Some(fps_entity) = self.f... | code_fim | medium | {
"lang": "rust",
"repo": "risooonho/fuite-rs",
"path": "/src/systems/fps.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risooonho/fuite-rs path: /src/systems/fps.rs
use amethyst::{
ecs::prelude::*,
core::timing::Time,
ui::{UiFinder, UiText},
utils::fps_counter::FPSCounter,
};
#[allow(unused_imports)]
use log::*;
<|fim_suffix|> fn setup(&mut self, res: &mut Resources) {
Self::SystemDat... | code_fim | hard | {
"lang": "rust",
"repo": "risooonho/fuite-rs",
"path": "/src/systems/fps.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darvin/DOS-Emulator-Rust-Src-Launch path: /src/config.rs
use serde::Deserialize;
use serde::Serialize;
#[derive(Deserialize, Serialize)]
pub struct Config {
pub timing: Timing,
pub audio: Audio,
pub keymap: toml::value::Table
}
<|fim_suffix|>#[derive(Deserialize, Serialize)]
pub st... | code_fim | medium | {
"lang": "rust",
"repo": "darvin/DOS-Emulator-Rust-Src-Launch",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Serialize)]
pub struct Timing {
pub clock_frequency: f64,
pub compensation_frequency: f64,
pub window_update_frequency: f64
}
#[derive(Deserialize, Serialize)]
pub struct Audio {
pub beeper_enabled: bool,
pub sound_blaster_enabled: bool
}<|fim_prefix|>// repo: da... | code_fim | medium | {
"lang": "rust",
"repo": "darvin/DOS-Emulator-Rust-Src-Launch",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiHRaM/vgtk-manpages path: /src/ext.rs
pub(crate) use webkit2gtk::{WebView, WebViewExt};
<|fim_suffix|>impl<WV> WebViewHelpers for WV where WV: WebViewExt {}<|fim_middle|>pub(crate) trait WebViewHelpers: WebViewExt {
fn get_html(&self) -> String {
String::from("No idea how to get th... | code_fim | hard | {
"lang": "rust",
"repo": "LiHRaM/vgtk-manpages",
"path": "/src/ext.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_html(&self, html: String) {
self.load_html(&html, None);
}
}
impl<WV> WebViewHelpers for WV where WV: WebViewExt {}<|fim_prefix|>// repo: LiHRaM/vgtk-manpages path: /src/ext.rs
pub(crate) use webkit2gtk::{WebView, WebViewExt};
<|fim_middle|>pub(crate) trait WebViewHelpers: WebVie... | code_fim | medium | {
"lang": "rust",
"repo": "LiHRaM/vgtk-manpages",
"path": "/src/ext.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
fn sum_odd_num(up_to:i32) -> i32{
let mut sum:i32 = 0;
for i in 0..up_to{
let odd_num = match i%2 == 1 {
true => i,
false => continue,
};
sum += odd_num;
}
return sum;
}
fn main(){
closure_test();
let sum = sum_odd_num(4);
... | code_fim | medium | {
"lang": "rust",
"repo": "csvsoft/rust-note",
"path": "/src/closure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csvsoft/rust-note path: /src/closure.rs
#![allow(dead_code)]
fn closure_test(){
fn plus_one(i:i32) -> i32 {i + 1}
let closure = | i:i32| -> i32 {i+1};
let closure2 = |i:i32| i + 1i32;
println!("function call:{}",plus_one(1));
println!("closure call:{}",closure(1));
pri... | code_fim | medium | {
"lang": "rust",
"repo": "csvsoft/rust-note",
"path": "/src/closure.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sl-sh-dev/sl-console path: /src/event.rs
w(
ErrorKind::Other,
"Input character is not valid UTF-8",
))
}
}
}
}
}
#[cfg(test)]
mod test {
use super::*;
use std::array::IntoIter;
... | code_fim | hard | {
"lang": "rust",
"repo": "sl-sh-dev/sl-console",
"path": "/src/event.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Ok(Event::Mouse(event));
}
}
}
}
}
return Err(Error::new(
ErrorKind::Other,
"Failed to parse xterm mouse encoding. Expected... | code_fim | hard | {
"lang": "rust",
"repo": "sl-sh-dev/sl-console",
"path": "/src/event.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
I: Iterator<Item = Result<u8, Error>>,
{
Ok(match iter.next() {
Some(Ok(b'[')) => match iter.next() {
Some(Ok(val @ b'A'..=b'E')) => Event::Key(Key::new(KeyCode::F(1 + val - b'A'))),
_ => return Err(Error::new(ErrorKind::Other, "Failed to parse csi code [")),
... | code_fim | hard | {
"lang": "rust",
"repo": "sl-sh-dev/sl-console",
"path": "/src/event.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bot1 = pos.y - self.half_height;
let top1 = pos.y + self.half_height;
let bot2 = pos_other.y - other.half_height;
let top2 = pos_other.y + other.half_height;
if bot1 > top2 { return false; }
if top1 < bot2 { return false; }
if right... | code_fim | hard | {
"lang": "rust",
"repo": "GreenPix/lycan",
"path": "/src/entity/hitbox.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn rotated(&self) -> RectangleHitbox {
RectangleHitbox {
half_width: self.half_height,
half_height: self.half_width,
}
}
}<|fim_prefix|>// repo: GreenPix/lycan path: /src/entity/hitbox.rs
use nalgebra::Point2;
#[derive(Debug,Clone,Copy)]
pub struct Rec... | code_fim | hard | {
"lang": "rust",
"repo": "GreenPix/lycan",
"path": "/src/entity/hitbox.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GreenPix/lycan path: /src/entity/hitbox.rs
use nalgebra::Point2;
#[derive(Debug,Clone,Copy)]
pub struct RectangleHitbox {
half_width: f32,
half_height: f32,
}
impl RectangleHitbox {
pub fn new(h_width: f32, h_height: f32) -> RectangleHitbox {
RectangleHitbox {
h... | code_fim | medium | {
"lang": "rust",
"repo": "GreenPix/lycan",
"path": "/src/entity/hitbox.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alecdwm/advent-of-code path: /src/lib.rs
//! Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university co... | code_fim | hard | {
"lang": "rust",
"repo": "alecdwm/advent-of-code",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// "We've detected some temporal anomalies," one of Santa's Elves at the Temporal Anomaly Research and Detection Instrument Station tells you. She sounded pretty worried when she called you down here. "At 500-year intervals into the past, someone has been changing Santa's history!"
///
/// "The good news... | code_fim | medium | {
"lang": "rust",
"repo": "alecdwm/advent-of-code",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Santa has become stranded at the edge of the Solar System while delivering presents to other planets! To accurately calculate his position in space, safely align his warp drive, and return to Earth in time to save Christmas, he needs you to bring him measurements from fifty stars.
///
/// Collect star... | code_fim | hard | {
"lang": "rust",
"repo": "alecdwm/advent-of-code",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evernym/indy-sdk path: /libindy/src/domain/ledger/nym.rs
use super::constants::GET_NYM;
use super::response::{GetReplyResultV0, GetReplyResultV1};
#[derive(Serialize, PartialEq, Debug)]
pub struct GetNymOperation {
#[serde(rename = "type")]
pub _type: String,
pub dest: String
}
imp... | code_fim | medium | {
"lang": "rust",
"repo": "evernym/indy-sdk",
"path": "/libindy/src/domain/ledger/nym.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Eq, PartialEq, Debug)]
pub struct GetNymResultDataV1 {
pub ver: String,
pub id: String,
pub did: String,
pub verkey: Option<String>,
pub role: Option<String>
}<|fim_prefix|>// repo: evernym/indy-sdk path: /libindy/src/domain/ledger/nym.rs
use super::constants::GE... | code_fim | hard | {
"lang": "rust",
"repo": "evernym/indy-sdk",
"path": "/libindy/src/domain/ledger/nym.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/wio/src/console.rs
/
/
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
:
/
/
opensource
.
org
/
licenses
/
MIT... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/wio/src/console.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
transparent
)
]
#
[
derive
(
Copy
Clone
)
]
pub
struct
ScreenBufferInfoEx
(
CONSOLE_SCREEN_BUFFER_INFOEX
)
;
impl
ScreenBufferInfoEx
{
pub
fn
raw_mut
(
&
mut
self
)
-
>
&
mut
CONSOLE_SCREEN_BUFFER_INFOEX
{
&
mut
self
.
0
}
}
#
[
repr
(
transparent
)
]
#
[
derive
(
Copy
Clone
)
]
pub
struct
FontInfoEx
(
C... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/wio/src/console.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn write_bytes<W: Write>(writer: &mut W, bytes: &[u8]) -> TychoStatus {
match writer.write_all(bytes) {
Ok(_) => Ok(()),
Err(e) => Err(TychoError::from(e))
}
}
pub(crate) fn write_buffer<W: Write>(writer: &mut W, buffer: BufWriter<Vec<u8>>) -> TychoStatus {
let byte... | code_fim | medium | {
"lang": "rust",
"repo": "SamHDev/tycho",
"path": "/src/write/func.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SamHDev/tycho path: /src/write/func.rs
use std::io::{BufWriter, Write};
use byteorder::WriteBytesExt;
use crate::error::{TychoError, TychoStatus};
use crate::write::length::write_length;
<|fim_suffix|>pub(crate) fn write_buffer<W: Write>(writer: &mut W, buffer: BufWriter<Vec<u8>>) -> TychoSta... | code_fim | hard | {
"lang": "rust",
"repo": "SamHDev/tycho",
"path": "/src/write/func.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: afaur/artichoke path: /artichoke-backend/src/extn/stdlib/time/mod.rs
use crate::extn::prelude::*;
pub fn init(int<|fim_suffix|>{
interp.def_rb_source_file(b"time.rb", &include_bytes!("time.rb")[..])?;
Ok(())
}<|fim_middle|>erp: &mut Artichoke) -> InitializeResult<()> | code_fim | easy | {
"lang": "rust",
"repo": "afaur/artichoke",
"path": "/artichoke-backend/src/extn/stdlib/time/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
interp.def_rb_source_file(b"time.rb", &include_bytes!("time.rb")[..])?;
Ok(())
}<|fim_prefix|>// repo: afaur/artichoke path: /artichoke-backend/src/extn/stdlib/time/mod.rs
use crate::extn::prelude::*;
pub fn init(int<|fim_middle|>erp: &mut Artichoke) -> InitializeResult<()> | code_fim | easy | {
"lang": "rust",
"repo": "afaur/artichoke",
"path": "/artichoke-backend/src/extn/stdlib/time/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NearlyEnjoyable/Srlash path: /src/main.rs
/*
Srlash - Splash screen written in Rust
Colored output
Reads file as frames which are separated.
TODO: Maybe add caching to tmp
neofetch like system statistics
Use raw libc for SIGTERM. It's a shame Rust stdlib is unable to do ... | code_fim | hard | {
"lang": "rust",
"repo": "NearlyEnjoyable/Srlash",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Set SIGTERM handler to restore cursor */
ctrlc::set_handler(move || {
println!("{}", REINIT_SCREEN);
std::process::exit(0);
}).expect("Error setting SIGTERM handler");
let path = std::path::Path::new(&file); //TODO: default file location where binary is run from
let... | code_fim | hard | {
"lang": "rust",
"repo": "NearlyEnjoyable/Srlash",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = BufReader::new(File::open(&std::env::args().nth(1).unwrap()).unwrap())
.lines();
// "Generator A starts with <number>"
let a = input.next().unwrap().unwrap().split(" ").skip(4).next().unwrap().parse::<u64>().unwrap();
let b = input.next().unwrap().unwrap().split(" "... | code_fim | medium | {
"lang": "rust",
"repo": "sooda/advent-of-code",
"path": "/17/15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sooda/advent-of-code path: /17/15.rs
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
fn matches_in_pairs(a0: u64, b0: u64, num: usize) -> usize {
let a_gen = (0..).scan(a0, |a, _| { *a = *a * 16807 % 2147483647; Some(*a) });
let b_gen = (0..).scan(b0, |b, _| { *b = *b *... | code_fim | hard | {
"lang": "rust",
"repo": "sooda/advent-of-code",
"path": "/17/15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::ops::Add<Vec2> for Rect {
type Output = Rect;
fn add(self, rhs: Vec2) -> Rect {
Rect {
min: self.min + rhs,
max: self.max + rhs,
}
}
}
impl std::ops::Add<Rect> for Vec2 {
type Output = Rect;
fn add(self, rhs: Rect) -> Rect {
... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/utilities/rect.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sanbox-irl/bit-bots path: /src/utilities/rect.rs
use super::Vec2;
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
pub struct Rect {
pub min: Vec2,
pub max: Vec2,
}
impl Rect {
pub fn new(min: Vec2, max: Vec2) -> Self {
Self { min, max }
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/utilities/rect.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub type_: ::std::os::raw::c_int,
pub serial: ::std::os::raw::c_ulong,
pub send_event: ::std::os::raw::c_int,
pub display: *mut Display,
pub event: Window,
pub window: Window,
pub place: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct XCirculateRequestEvent {... | code_fim | hard | {
"lang": "rust",
"repo": "saiprakash-ranjan/crosvm",
"path": "/crosvm/gpu_display/src/generated/xlib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saiprakash-ranjan/crosvm path: /crosvm/gpu_display/src/generated/xlib.rs
d_event: ::std::os::raw::c_int,
pub display: *mut Display,
pub window: Window,
pub x: ::std::os::raw::c_int,
pub y: ::std::os::raw::c_int,
pub width: ::std::os::raw::c_int,
pub height: ::std::os::raw... | code_fim | hard | {
"lang": "rust",
"repo": "saiprakash-ranjan/crosvm",
"path": "/crosvm/gpu_display/src/generated/xlib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saiprakash-ranjan/crosvm path: /crosvm/gpu_display/src/generated/xlib.rs
_pad: ::std::os::raw::c_int,
pub depth: ::std::os::raw::c_int,
pub bytes_per_line: ::std::os::raw::c_int,
pub bits_per_pixel: ::std::os::raw::c_int,
pub red_mask: ::std::os::raw::c_ulong,
pub green_mask:... | code_fim | hard | {
"lang": "rust",
"repo": "saiprakash-ranjan/crosvm",
"path": "/crosvm/gpu_display/src/generated/xlib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_should_pull_accumulator_without_setting_anything() {
let m = [0; AVAILABLE_MEMORY];
let mut cpu = Mos6502Cpu::new(Box::new(m));
cpu.registers.s = 0xfe;
cpu.registers.a = 0;
cpu.memory.set(0x1ff, 0x42);
cpu.execute_instruction(&Mos6502In... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/emulators",
"path": "/mos6502cpu/src/stack.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let m = [0; AVAILABLE_MEMORY];
let mut cpu = Mos6502Cpu::new(Box::new(m));
cpu.registers.s = 0xfe;
cpu.registers.a = 0;
cpu.memory.set(0x1ff, 0x42);
cpu.execute_instruction(&Mos6502Instruction {
instruction: Mos6502InstructionCode::Pla,
... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/emulators",
"path": "/mos6502cpu/src/stack.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AgustinCB/emulators path: /mos6502cpu/src/stack.rs
use instruction::AddressingMode;
use mos6502cpu::ProcessorStatus;
use {CpuError, CpuResult, Mos6502Cpu};
impl Mos6502Cpu {
pub(crate) fn execute_pha(&mut self, addressing_mode: &AddressingMode) -> CpuResult {
if let AddressingMode::... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/emulators",
"path": "/mos6502cpu/src/stack.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os/zCore path: /linux-object/src/fs/ioctl.rs
#![allow(unused)]
// for IOR and IOW:
// 32bits total, command in lower 16bits, size of the parameter structure in the lower 14 bits of the upper 16 bits
// higher 2 bits: 01 = write, 10 = read
#[cfg(not(target_arch = "mips"))]
pub const TCGET... | code_fim | hard | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/linux-object/src/fs/ioctl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(target_arch = "mips"))]
pub const TIOCGPGRP: usize = 0x540F;
// _IOR('t', 119, int)
#[cfg(target_arch = "mips")]
pub const TIOCGPGRP: usize = 0x4_004_74_77;
#[cfg(not(target_arch = "mips"))]
pub const TIOCSPGRP: usize = 0x5410;
// _IOW('t', 118, int)
#[cfg(target_arch = "mips")]
pub const TIOCS... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/linux-object/src/fs/ioctl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// rustc using pipe and ioctl pipe file with this request id
// for non-blocking/blocking IO control setting
pub const FIONBIO: usize = 0x5421;<|fim_prefix|>// repo: rcore-os/zCore path: /linux-object/src/fs/ioctl.rs
#![allow(unused)]
// for IOR and IOW:
// 32bits total, command in lower 16bits, size of... | code_fim | hard | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/linux-object/src/fs/ioctl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgeisler/tokio-serde-bincode path: /examples/server.rs
extern crate bincode;
extern crate futures;
#[macro_use]
extern crate serde_derive;
extern crate tokio;
extern crate tokio_serde_bincode;
use futures::stream;
use tokio::codec::{FramedRead, LengthDelimitedCodec, length_delimited};
use tokio... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/tokio-serde-bincode",
"path": "/examples/server.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "127.0.0.1:17653".parse().unwrap();
// Bind a server socket
let listener = TcpListener::bind(&addr)?;
println!("listening on {:?}", listener.local_addr());
let server = listener
.incoming()
.map_err(... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/tokio-serde-bincode",
"path": "/examples/server.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Bind a server socket
let listener = TcpListener::bind(&addr)?;
println!("listening on {:?}", listener.local_addr());
let server = listener
.incoming()
.map_err(|e| println!("failed to accept socket; error = {:?}", e))
.for_each(move |socket| {
// Spl... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/tokio-serde-bincode",
"path": "/examples/server.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|> let five = Some(0u8);
match five {
Some(3) => println!("ok"),
_ => (),
}
// let six = plus_one(five);
// println!("{}", six.unwrap());
}
fn plus_one(x: Option<i32>) -> Option<i32> {
match x {
None => None,
Some(i) => Some(i + 1),
}
}<|fim_prefix... | code_fim | hard | {
"lang": "rust",
"repo": "yoyoliyang/rust_learn",
"path": "/src/enum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sum = x + y.unwrap(); // option解包取值
let five = Some(0u8);
match five {
Some(3) => println!("ok"),
_ => (),
}
// let six = plus_one(five);
// println!("{}", six.unwrap());
}
fn plus_one(x: Option<i32>) -> Option<i32> {
match x {
None => None,
... | code_fim | hard | {
"lang": "rust",
"repo": "yoyoliyang/rust_learn",
"path": "/src/enum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yoyoliyang/rust_learn path: /src/enum.rs
// 枚举也可以使用ipml方法
#[derive(Debug)]
enum IpAddrKind {
V4([u8; 4]),
V6(String),
}
enum Coin {}
// impl IpAddrKind {
// fn call(&self) {
// self::V4
<|fim_suffix|>fn plus_one(x: Option<i32>) -> Option<i32> {
match x {
None => None,
... | code_fim | hard | {
"lang": "rust",
"repo": "yoyoliyang/rust_learn",
"path": "/src/enum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Out of range, sets ack num and empty flags
let mut peer_acks = PeerAcks { ack_num: 65535, ack_field: 0b101};
let seq_num = 40;
peer_acks.add_seq_num(seq_num);
assert!(peer_acks.ack_num == 40);
assert!(peer_acks.ack_field == 0);
}
#[test]
fn update_ack_map_for_normal_older... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/rust_game_udp",
"path": "/src/ack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // In range, sets correct flag
let mut peer_acks = PeerAcks { ack_num: 20, ack_field: 0b101};
let seq_num = 15;
peer_acks.add_seq_num(seq_num);
assert!(peer_acks.ack_num == 20);
assert!(peer_acks.ack_field == 0b10101);
// Out of range does nothing
let mut peer_acks = PeerA... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/rust_game_udp",
"path": "/src/ack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmcarther/rust_game_udp path: /src/ack.rs
pub use self::ack::{
PeerAcks,
};
mod ack {
#[derive(Debug)]
pub struct PeerAcks {
pub ack_num: u16,
pub ack_field: u32
}
impl PeerAcks {
pub fn add_seq_num(&mut self, seq_num: u16) {
let ack_num_i32: i32 = self.ack_num as ... | code_fim | hard | {
"lang": "rust",
"repo": "acmcarther/rust_game_udp",
"path": "/src/ack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = strings.lookup_const_name(name);
Constant { name, value, attrs }
}<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/hackc/ir/conversions/ir_to_bc/constant.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in t... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/hackc/ir/conversions/ir_to_bc/constant.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/hackc/ir/conversions/ir_to_bc/constant.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
<|fim_suffix|> let name = string... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/hackc/ir/conversions/ir_to_bc/constant.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wveitch/greenhouse-rs path: /src/router/metrics_router.rs
use prometheus::{Encoder, TextEncoder};
use rocket::http::ContentType;
use rocket::http::Status;
use rocket::request::Request;
use rocket::response::{self, Responder};
use std::io;
<|fim_suffix|>impl MetricsHandle {
pub fn new() -> i... | code_fim | medium | {
"lang": "rust",
"repo": "wveitch/greenhouse-rs",
"path": "/src/router/metrics_router.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MetricsHandle {
pub fn new() -> io::Result<MetricsHandle> {
Ok(MetricsHandle {})
}
}
impl<'r> Responder<'r> for MetricsHandle {
fn respond_to(self, req: &Request) -> response::Result<'r> {
let encoder = TextEncoder::new();
let mut buffer = vec![];
let metr... | code_fim | medium | {
"lang": "rust",
"repo": "wveitch/greenhouse-rs",
"path": "/src/router/metrics_router.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let encoder = TextEncoder::new();
let mut buffer = vec![];
let metric_familys = prometheus::gather();
for mf in metric_familys {
match encoder.encode(&[mf], &mut buffer) {
Ok(_) => {}
Err(_) => return Err(Status::InternalServerErr... | code_fim | medium | {
"lang": "rust",
"repo": "wveitch/greenhouse-rs",
"path": "/src/router/metrics_router.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn execute(cmd: Command) {
let body = ReqBody {
name: cmd.name,
email: cmd.email,
status_msg: cmd.status_msg,
description: cmd.description,
instagram: cmd.instagram,
twitter: cmd.twitter,
};
let res = reqwest::Client::new()
.po... | code_fim | hard | {
"lang": "rust",
"repo": "AtsukiTak/window.art",
"path": "/server/artell-cli/src/add_artist.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.