text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: lpartan/zotero-to-obsidian path: /src/json_parser.rs
use std::collections::HashMap;
use std::fmt;
// use option type to get every single possible thing you want
#[derive(Serialize, Deserialize, Debug)]
pub struct Item {
#[serde(rename(serialize = "citationKey", deserialize = "citationKey"... | code_fim | hard | {
"lang": "rust",
"repo": "lpartan/zotero-to-obsidian",
"path": "/src/json_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgx-test/test path: /enclave/src/tests.rs
use std::prelude::v1::*;
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
<|fim_suffix|> let a = BigInt::from_bytes_be(Sign::Plus, b"Hello world!AAAAAA");
println!("2");
let b = BigInt::from_bytes_be(Sign::Plus, b"Hello w... | code_fim | medium | {
"lang": "rust",
"repo": "sgx-test/test",
"path": "/enclave/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("2");
let b = BigInt::from_bytes_be(Sign::Plus, b"Hello world!BBBBBB");
println!("{}", a * b);
}<|fim_prefix|>// repo: sgx-test/test path: /enclave/src/tests.rs
use std::prelude::v1::*;
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
use num_bigint::{BigInt, Sign, ... | code_fim | medium | {
"lang": "rust",
"repo": "sgx-test/test",
"path": "/enclave/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe extern "C" fn handle_callback<F>(this: raw::Local, func: raw::Local, callback: *mut c_void)
where
F: FnOnce(&mut EventContext, Handle<JsValue>, Handle<JsFunction>),
F: Send + 'static,
{
EventContext::with(|mut cx: EventContext| {
let this = JsValue::new_internal(this);
l... | code_fim | hard | {
"lang": "rust",
"repo": "PrimeGoose/neon",
"path": "/src/event/event_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PrimeGoose/neon path: /src/event/event_handler.rs
//! Helper to run a callback in the libuv main thread.
use std::os::raw::c_void;
use crate::context::internal::ContextInternal;
use crate::context::Context;
use crate::handle::{Handle, Managed};
use crate::types::*;
use neon_runtime;
use neon_r... | code_fim | hard | {
"lang": "rust",
"repo": "PrimeGoose/neon",
"path": "/src/event/event_handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burrbull/vl6180x path: /src/als.rs
pub fn als_get_lux(&mut self, i2c) -> Result<Lux, I2cError>
{
int status;
uint16_t RawAls;
uint32_t luxValue = 0;
uint32_t IntPeriod;
uint32_t AlsAnGain;
uint32_t GainFix;
uint32_t AlsScaler;
#if LUXRES_FIX_PREC != GAIN_FIX_PR... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/vl6180x",
"path": "/src/als.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
int status;
uint8_t IntStatus;
LOG_FUNCTION_START("%p", pIntStatus);
status = self.read(RESULT_INTERRUPT_STATUS_GPIO, &IntStatus).bits();
*pIntStatus = (IntStatus >> 3) & 0x07;
LOG_FUNCTION_END_FMT(status, "%d", (int)*pIntStatus);
return status;
}
int VL6180x_AlsWaitDevice... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/vl6180x",
"path": "/src/als.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /abc276/src/bin/b.rs
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
<|fim_suffix|>#[allow(unused_macros)]
macr... | code_fim | medium | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc276/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
n: usize,
m: usize,
ab: [(Usize1, Usize1); m],
}
let mut graph = vec![vec![]; n];
for &(ai, bi) in ab.iter() {
graph[ai].push(bi);
graph[bi].push(ai);
}
for u in 0..n {
graph[u].sort();
let mut values = vec![format!("... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/abc276/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Liby99/llir path: /src/values/instruction/macros.rs
macro_rules! impl_instr_debug {
($id:ident) => {
impl<'ctx> std::fmt::Debug for $id<'ctx> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
<|fim_suffix|> let op = $op::from_llvm(unsafe { $op_getter(ptr) ... | code_fim | hard | {
"lang": "rust",
"repo": "Liby99/llir",
"path": "/src/values/instruction/macros.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let op = $op::from_llvm(unsafe { $op_getter(ptr) });
Self(op, ptr, PhantomData)
}
}
}
}<|fim_prefix|>// repo: Liby99/llir path: /src/values/instruction/macros.rs
macro_rules! impl_instr_debug {
($id:ident) => {
impl<'ctx> std::fmt::Debug for $id<'ctx> {
fn fmt(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "Liby99/llir",
"path": "/src/values/instruction/macros.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0378_kth_smallest_element_in_a_sorted_matrix/binary_search_2.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn kth_smallest(matrix: Vec<V... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0378_kth_smallest_element_in_a_sorted_matrix/binary_search_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TobiasFranek/IPPC-ROBOT path: /rust/src/robust_arduino.rs
//! # Robust Arduino Serial
//!
//! `robust_arduino_serial` is a simple and robust serial communication protocol.
//! It was designed to make two arduinos communicate, but can also be useful
//! when you want a computer (e.g. a Raspberry ... | code_fim | hard | {
"lang": "rust",
"repo": "TobiasFranek/IPPC-ROBOT",
"path": "/rust/src/robust_arduino.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Write two bytes int to a file/serial port.
/// It returns the number of bytes written
///
/// # Example
///
/// ```
/// use std::io::Cursor;
/// use robust_arduino_serial::*;
///
/// let mut buffer = Cursor::new(Vec::new());
/// let number: i16 = 366;
///
/// // write 16 bits (two bytes) to the buffer... | code_fim | hard | {
"lang": "rust",
"repo": "TobiasFranek/IPPC-ROBOT",
"path": "/rust/src/robust_arduino.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/cc13x2-cc26x2-pac path: /src/aux_tdc/trigsrc.rs
s |= ((value & MASK) as u32) << OFFSET;
self.w
}
}
#[doc = "Values that can be written to the field `START_SRC`"]
pub enum START_SRCW {
#[doc = "No event."]
NO_EVENT,
#[doc = "Select TDC Prescaler event which is ... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/cc13x2-cc26x2-pac",
"path": "/src/aux_tdc/trigsrc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_TIMER2_EV1,
#[doc = "AUX_EVCTL:EVSTAT3.AUX_TIMER2_EV0"]
AUX_TIMER2_EV0,
#[doc = "AUX_EVCTL:EVSTAT2.AUX_COMPB"]
AUX_COMPB,
#[doc = "AUX_EVCTL:EVSTAT2.AUX_COMPA"]
AUX_COMPA,
#[doc = "AUX_EVCTL:EVSTAT2.MCU_OBSMUX1"]
MCU_OBSMUX1,
#[doc = "AUX_EVCTL:EVSTAT2.MCU_OBSMUX0"]
... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/cc13x2-cc26x2-pac",
"path": "/src/aux_tdc/trigsrc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/cc13x2-cc26x2-pac path: /src/aux_tdc/trigsrc.rs
.bit(variant._bits())
}
}
#[doc = "TDC conversion starts when low level is detected."]
#[inline]
pub fn low(self) -> &'a mut W {
self.variant(START_POLW::LOW)
}
#[doc = "TDC conversion starts when... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/cc13x2-cc26x2-pac",
"path": "/src/aux_tdc/trigsrc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod account_info;
mod account_model;
mod account_properties;
mod account_type;
mod address_model;
mod internally;
mod public_account_model;<|fim_prefix|>// repo: proximax-storage/rust-xpx-chain-sdk path: /src/models/account/mod.rs
/*
* Copyright 2018 ProximaX Limited. All rights reserved.
* Use of this... | code_fim | hard | {
"lang": "rust",
"repo": "proximax-storage/rust-xpx-chain-sdk",
"path": "/src/models/account/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proximax-storage/rust-xpx-chain-sdk path: /src/models/account/mod.rs
/*
* Copyright 2018 ProximaX Limited. All rights reserved.
* Use of this source code is governed by the Apache 2.0
* license that can be found in the LICENSE file.
*/
<|fim_suffix|>mod account_info;
mod account_model;
mod ... | code_fim | hard | {
"lang": "rust",
"repo": "proximax-storage/rust-xpx-chain-sdk",
"path": "/src/models/account/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut deliveries = Vec::with_capacity(34_000_000);
for i in 0..deliveries.capacity() {
deliveries.push(1);
}
for elf in 2..deliveries.len() {
let mut i = 0;
for house in (elf-1..deliveries.len()).step_by(elf) {
deliveries[house] += elf * 11;
... | code_fim | medium | {
"lang": "rust",
"repo": "seeday/aoc",
"path": "/aoc20/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for elf in 2..deliveries.len() {
let mut i = 0;
for house in (elf-1..deliveries.len()).step_by(elf) {
deliveries[house] += elf * 11;
i += 1;
if i >= 50 { break; }
}
if deliveries[elf - 1] >= 34_000_000 {
println!("Delivere... | code_fim | hard | {
"lang": "rust",
"repo": "seeday/aoc",
"path": "/aoc20/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seeday/aoc path: /aoc20/src/main.rs
#![feature(step_by)]
fn main() {
presentsforhouse();
//lazyelves();
}
fn presentsforhouse() {
let mut presents = Vec::with_capacity(3_400_000);
for _ in 0..presents.capacity() {
presents.push(10);
}
<|fim_suffix|> for elf in 2... | code_fim | hard | {
"lang": "rust",
"repo": "seeday/aoc",
"path": "/aoc20/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let final_score = board.get_score();
if final_score[0] > final_score[1]{
mcts_wins += 1;
}
if final_score[0] == final_score[1]{
draws += 1;
}
if final_score[1] > final_score[0]{
mcts_h_wins += 1;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ckass19/Reversi-with-MTCS",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let coordinates = board.ai_move(board.current_player);
let _ai_move = board.do_move(coordinates[0].x, coordinates[0].y);
}else{
let list_of_moves = board.legal_moves(board.current_player);
if list_of_moves.is_empty(){
... | code_fim | hard | {
"lang": "rust",
"repo": "ckass19/Reversi-with-MTCS",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ckass19/Reversi-with-MTCS path: /src/main.rs
//use std::io;
mod game;
fn game_loop(){
let mut mcts_wins = 0;
let mut draws = 0;
let mut mcts_h_wins = 0;
for _x in 0..100{
let mut board = game::Board::default();
while !board.is_game_over() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ckass19/Reversi-with-MTCS",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengalin/media-toc path: /ui/src/export/dispatcher.rs
use crate::{
export,
generic_output::{self, prelude::*},
main_panel,
};
<|fim_suffix|>pub struct Dispatcher;
impl OutputDispatcher for Dispatcher {
type CtrlImpl = export::ControllerImpl;
fn ctrl(main_ctrl: &main_panel::... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/ui/src/export/dispatcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn ctrl(main_ctrl: &main_panel::Controller) -> &export::Controller {
&main_ctrl.export
}
fn ctrl_mut(main_ctrl: &mut main_panel::Controller) -> &mut export::Controller {
&mut main_ctrl.export
}
}<|fim_prefix|>// repo: fengalin/media-toc path: /ui/src/export/dispatcher.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/ui/src/export/dispatcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: legokichi/rust-sandbox path: /nalgebra-sandbox/src/main.rs
use nalgebra::base::*;
use nalgebra_lapack::Eigen;
use plotters::prelude::*;
use font_kit::family_name::FamilyName;
use font_kit::handle::Handle;
use font_kit::source::SystemSource;
use font_kit::properties::{Properties, Style, Weight};
... | code_fim | hard | {
"lang": "rust",
"repo": "legokichi/rust-sandbox",
"path": "/nalgebra-sandbox/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn real_linear_space_2d(){
// scalar (field)
let zero = 0.0;
let one = 1.0;
// field operation
// addition
// zero as addition identity element
assert_eq!(zero + zero, zero);
assert_eq!(zero + one, one);
assert_eq!(one + one, one + one);
assert_eq!(one + -one, zero)... | code_fim | hard | {
"lang": "rust",
"repo": "legokichi/rust-sandbox",
"path": "/nalgebra-sandbox/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cLazyZombie/raytrace-rs path: /src/camera.rs
use crate::{mat, point, vector, Angle, Matrix, Matrix4, Ray, Vec4};
pub struct Camera {
pub hsize: u32,
pub vsize: u32,
pub fov: Angle, // vertical fov
pub aspect: f32, // w / h
pub inv_transform: Matrix4, /... | code_fim | hard | {
"lang": "rust",
"repo": "cLazyZombie/raytrace-rs",
"path": "/src/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
#[test]
fn identity_view_transform() {
let view_transform = view_transform(point(0.0, 0.0, 0.0), point(0.0, 0.0, 1.0), vector(0.0, 1.0, 0.0));
assert_almost_eq_mat(view_transform, Matrix4::identity());
}
#[test]
fn view_transform_move_world() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cLazyZombie/raytrace-rs",
"path": "/src/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = Person::new("Taro", 20);
p.say_name().say_age();
print!("hello");
println!("hello {}", "world");
eprint!("hello {}", "error");
eprintln!("hello");
let mut w = Vec::new();
write!(&mut w, "{}", "ABC");
writeln!(&mut w, " is 123");
dbg!(w);
//panic!("it ... | code_fim | hard | {
"lang": "rust",
"repo": "gakitoru/rust-learning",
"path": "/sample3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gakitoru/rust-learning path: /sample3/src/main.rs
use std::io::Write;
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn abs(number: i32) -> i32 {
if number < 0 {
return -number;
}
number
}
struct Person {
name: String,
age: u32,
}
impl Person {
fn new(name: &str, ... | code_fim | hard | {
"lang": "rust",
"repo": "gakitoru/rust-learning",
"path": "/sample3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.sink.process_token(token, self.current_line)
}
fn run(&mut self, input: &mut String) -> TokenizerResult<Sink::Handle> {
// loop {
// match self
// }
TokenizerResult::Done
}
}
// END
// shorthand for common state machine behaviours.
macro_rules... | code_fim | hard | {
"lang": "rust",
"repo": "jzsplk/pineapple",
"path": "/src/tokenizer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jzsplk/pineapple path: /src/tokenizer/mod.rs
#[warn(unused_imports)]
use self::states::{Data,TagOpen,EndTagOpen,State};
use self::interface::{Token,TokenSink,TagKind,Attribute,TokenSinkResult};
// use self::states::{};
use log::debug;
pub mod states;
mod interface;
pub enum ProcessResult<Hand... | code_fim | hard | {
"lang": "rust",
"repo": "jzsplk/pineapple",
"path": "/src/tokenizer/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn process_token(&mut self, token: Token) -> TokenSinkResult<Sink::Handle> {
self.sink.process_token(token, self.current_line)
}
fn run(&mut self, input: &mut String) -> TokenizerResult<Sink::Handle> {
// loop {
// match self
// }
TokenizerResult::D... | code_fim | hard | {
"lang": "rust",
"repo": "jzsplk/pineapple",
"path": "/src/tokenizer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Operation {
pub fn new_symbol(symbol: Symbol) -> Self {
Operation {
operation: OperationType::Symbol { symbol },
}
}
pub fn new_call(func: String, args: Vec<Operation>) -> Self {
Operation {
operation: OperationType::Call { func, args },
... | code_fim | hard | {
"lang": "rust",
"repo": "HyeockJinKim/zoker",
"path": "/compiler/src/symbol.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HyeockJinKim/zoker path: /compiler/src/symbol.rs
use num_bigint::BigUint;
use std::fmt;
use zoker_parser::ast::{Specifier, Type};
#[derive(Debug, Clone, PartialEq)]
pub enum SymbolType {
Uint256,
Int256,
String,
Address,
Bytes32,
Bool,
None,
}
pub fn token_to_type(t... | code_fim | hard | {
"lang": "rust",
"repo": "HyeockJinKim/zoker",
"path": "/compiler/src/symbol.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq)]
pub struct Operation {
pub operation: OperationType,
}
impl Operation {
pub fn new_symbol(symbol: Symbol) -> Self {
Operation {
operation: OperationType::Symbol { symbol },
}
}
pub fn new_call(func: String, args: Vec<Operatio... | code_fim | hard | {
"lang": "rust",
"repo": "HyeockJinKim/zoker",
"path": "/compiler/src/symbol.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_samples() {
assert_eq!(choc_count(10, 2, 5), 6);
assert_eq!(choc_count(12, 4, 4), 3);
assert_eq!(choc_count(6, 2, 2), 5);
}
}<|fim_prefix|>// repo: fendersperth/kata path: /miqid/chocolate_feast/main.rs
use std... | code_fim | medium | {
"lang": "rust",
"repo": "fendersperth/kata",
"path": "/miqid/chocolate_feast/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fendersperth/kata path: /miqid/chocolate_feast/main.rs
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let params : Vec<u32> = line
.unwrap()
.split_whit... | code_fim | hard | {
"lang": "rust",
"repo": "fendersperth/kata",
"path": "/miqid/chocolate_feast/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dstockhouse/mr-fusion-capstone path: /guidance/rust_code/src/network/mod.rs
use std::net::{Ipv4Addr, SocketAddrV4};
use std::io::Write;
use cfg_if::cfg_if;
use crate::ui::TO_UI;
cfg_if! {
// This can be thought of as a #ifdef in c. In this case, if cargo test is run, then compile the
... | code_fim | hard | {
"lang": "rust",
"repo": "dstockhouse/mr-fusion-capstone",
"path": "/guidance/rust_code/src/network/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const GUIDANCE_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 1, 1);
const CONTROL_PORT: u16 = 31401;
const NAV_PORT: u16 = 31402;
const IMAG_PROC_PORT: u16 = 31403;
pub struct TcpStreams {
nav: TcpStream,
control: TcpStream,
imag_proc: TcpStream
}
impl TcpStreams {
pub fn setup() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "dstockhouse/mr-fusion-capstone",
"path": "/guidance/rust_code/src/network/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match tcp_listener.accept() {
Ok((tcp_stream, _socket_addr)) => tcp_stream,
Err(error) => {
let message = format!("Guidance unable to accept: {}", error);
TO_UI.lock().unwrap() // Acquired mutex
.write_all(message.as_bytes()).unwrap... | code_fim | hard | {
"lang": "rust",
"repo": "dstockhouse/mr-fusion-capstone",
"path": "/guidance/rust_code/src/network/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn pos_to_square_test() {
//Macro (sort of)
fn local(i: usize) -> u16 {
let a = CoordConverter::new(3);
a.pos_to_square(i).get_value(3)
}
assert_eq!(1, local(0));
assert_eq!(1, local(1));
assert_eq!(1, local(2));
assert_eq!(2, local(3));
assert_eq!(2... | code_fim | hard | {
"lang": "rust",
"repo": "cyrille-blanchet-1974/sudoku",
"path": "/src/objects/coordconverter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrille-blanchet-1974/sudoku path: /src/objects/coordconverter.rs
use super::cardinal::*;
use super::metrics::*;
use std::convert::TryInto;
#[derive(Debug, Copy, Clone)]
pub struct CoordConverter {
metrics: Metrics,
}
impl CoordConverter {
pub fn new(squareside: u16) -> CoordConverter ... | code_fim | hard | {
"lang": "rust",
"repo": "cyrille-blanchet-1974/sudoku",
"path": "/src/objects/coordconverter.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let coord = self.pos_to_coord(pos);
let res = match coord.0 {
1..=3 => match coord.1 {
1..=3 => 1,
4..=6 => 2,
7..=9 => 3,
_ => 0,
},
4..=6 => match coord.1 {
1..=3 => 4,
... | code_fim | hard | {
"lang": "rust",
"repo": "cyrille-blanchet-1974/sudoku",
"path": "/src/objects/coordconverter.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example_1() {
assert_eq!(10, Solution::largest_rectangle_area(vec![2, 1, 5, 6, 2, 3]));
}
}<|fim_prefix|>// repo: sugyan/leetcode path: /others/december-leetcoding-challenge/week-5/3587/lib.rs
pub struct Solution {}
impl Solution {
pub fn largest_rectangle_area(heights... | code_fim | hard | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/december-leetcoding-challenge/week-5/3587/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sugyan/leetcode path: /others/december-leetcoding-challenge/week-5/3587/lib.rs
pub struct Solution {}
impl Solution {
pub fn largest_rectangle_area(heights: Vec<i32>) -> i32 {
let mut heights = heights;
heights.push(0);
let mut stack = Vec::new();
let mut ans... | code_fim | hard | {
"lang": "rust",
"repo": "sugyan/leetcode",
"path": "/others/december-leetcoding-challenge/week-5/3587/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vorner/mandel path: /src/packed.rs
use multiversion::multiversion;
use packed_simd::{f32x8, u8x8, SimdVector};
use rayon::prelude::*;
use super::{Complex, Compute, Image, LIMIT};
type V = f32x8;
type I = u8x8;
const L: usize = V::LANES;
#[multiversion]
#[clone(target = "[x86|x86_64]+sse+sse2+... | code_fim | medium | {
"lang": "rust",
"repo": "vorner/mandel",
"path": "/src/packed.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..255 {
z = z * z + c;
let over_limit = z.len_sq().ge(V::splat(LIMIT));
inc = over_limit.select(I::default(), inc);
iter_cnt += inc;
if inc == I::default() {
break;
}
}
iter_cnt.wri... | code_fim | hard | {
"lang": "rust",
"repo": "vorner/mandel",
"path": "/src/packed.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_should_fail_to_convert_invalid_values_to_epochs() {
let empty_epoch = "".parse::<Epoch>();
assert!(empty_epoch.is_err());
let invalid_epoch = "invalid".parse::<Epoch>();
assert!(invalid_epoch.is_err());
}
#[tes... | code_fim | hard | {
"lang": "rust",
"repo": "CarloMicieli/trenako",
"path": "/crates/catalog/src/catalog_items/epoch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CarloMicieli/trenako path: /crates/catalog/src/catalog_items/epoch.rs
use itertools::Itertools;
use std::fmt;
use std::fmt::Formatter;
use std::str;
use thiserror::Error;
/// The model railway industry adopted an 'Era', or 'Epoch' system; the idea being to group models
/// into a defined time b... | code_fim | hard | {
"lang": "rust",
"repo": "CarloMicieli/trenako",
"path": "/crates/catalog/src/catalog_items/epoch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Writer {
column_position: usize,
row_position: usize,
color_code: ColorCode,
}
impl Writer {
pub fn write_byte(&mut self, byte: u8) {
use core::fmt::Write;
match byte {
b'\t' => {
self.write_str(" ");
},
b'\... | code_fim | hard | {
"lang": "rust",
"repo": "arbel03/os",
"path": "/src/vga_buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Buffer {
chars: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT],
}
pub struct Writer {
column_position: usize,
row_position: usize,
color_code: ColorCode,
}
impl Writer {
pub fn write_byte(&mut self, byte: u8) {
use core::fmt::Write;
match byte {
b'\t' ... | code_fim | hard | {
"lang": "rust",
"repo": "arbel03/os",
"path": "/src/vga_buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arbel03/os path: /src/vga_buffer.rs
use core::fmt;
#[allow(dead_code)]
#[repr(u8)]
pub enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
LightGray = 7,
DarkGray = 8,
LightBlue ... | code_fim | hard | {
"lang": "rust",
"repo": "arbel03/os",
"path": "/src/vga_buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mxork/gitui path: /src/tabs/revlog.rs
use crate::{
components::{
visibility_blocking, CommandBlocking, CommandInfo,
CommitDetailsComponent, CommitList, Component,
DrawableComponent,
},
keys,
queue::{InternalEvent, Queue},
strings,
ui::style::Shared... | code_fim | hard | {
"lang": "rust",
"repo": "mxork/gitui",
"path": "/src/tabs/revlog.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn commands(
&self,
out: &mut Vec<CommandInfo>,
force_all: bool,
) -> CommandBlocking {
if self.visible || force_all {
self.list.commands(out, force_all);
}
out.push(CommandInfo::new(
commands::LOG_DETAILS_TOGGLE,
... | code_fim | hard | {
"lang": "rust",
"repo": "mxork/gitui",
"path": "/src/tabs/revlog.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn data(word: u16) -> u8 { (word >> 4) as u8 }
fn par() -> [u16; 4] { PAR }
fn locs() -> [u16; 16] { LOCATIONS }
}
}
/// Defines code-specific decoding functions.
trait HammingDecoder {
/// The type of the data bit output.
type Data;
/// Convert the codeword to da... | code_fim | hard | {
"lang": "rust",
"repo": "ohc192/p25.rs",
"path": "/src/coding/hamming.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ohc192/p25.rs path: /src/coding/hamming.rs
//! Encoding and decoding of the (15, 11, 3) standard and (10, 6, 3) shortened Hamming
//! codes described by P25.
//!
//! Both codes can correct up to 1 error. These algorithms are sourced from *Coding Theory
//! and Cryptography: The Essentials*, Hank... | code_fim | hard | {
"lang": "rust",
"repo": "ohc192/p25.rs",
"path": "/src/coding/hamming.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match s {
"begin" => 1,
"if" => 2,
"then" => 3,
"while" => 4,
"do" => 5,
"end" => 6,
"+" => 13,
"-" => 14,
"*" => 15,
"/" => 16,
":" => 17,
":=" => 18,
"<" => 20,
"<>" => 21,
"<=" =>... | code_fim | hard | {
"lang": "rust",
"repo": "ParadoxZW/compiler-homework",
"path": "/lexier/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DFA {
fn transaction(&mut self, c: &char) {
match (self.0, c) {
(0, '0'..='9') => self.0 = 1,
(0, 'a'..='z')|(0, 'A'..='Z') => self.0 = 2,
(2, '0'..='9') => self.0 = 2,
(2, 'a'..='z')|(1, 'A'..='Z') => self.0 = 2,
(1, '0'..='9') ... | code_fim | hard | {
"lang": "rust",
"repo": "ParadoxZW/compiler-homework",
"path": "/lexier/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ParadoxZW/compiler-homework path: /lexier/src/main.rs
/*
* @Author: Canopus (https://github.com/ParadoxZW)
* @Date: 2019-04-07 16:31:32
* @Last Modified by: Canopus (https://github.com/ParadoxZW)
* @Last Modified time: 2019-04-07 17:27:39
*/
use std::env;
use std::fs;
extern crate rayon;
e... | code_fim | hard | {
"lang": "rust",
"repo": "ParadoxZW/compiler-homework",
"path": "/lexier/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexApps99/nx-decomp-tools path: /viking/src/functions.rs
use crate::repo;
use anyhow::{bail, ensure, Context, Result};
use lazy_static::lazy_static;
use rayon::prelude::*;
use rustc_hash::FxHashMap;
use std::{
collections::HashSet,
path::{Path, PathBuf},
};
#[derive(Clone, Debug, Parti... | code_fim | hard | {
"lang": "rust",
"repo": "AlexApps99/nx-decomp-tools",
"path": "/viking/src/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = match status_code {
Some('m') => Status::NonMatchingMinor,
Some('M') => Status::NonMatchingMajor,
Some('O') => Status::Matching,
Some('U') => Status::NotDecompiled,
Some('W') => Status::Wip,
Some('L') => Status::Library,
Some(code) =... | code_fim | hard | {
"lang": "rust",
"repo": "AlexApps99/nx-decomp-tools",
"path": "/viking/src/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for function in functions {
if function.name.is_empty() {
continue;
}
known_functions.insert(function.addr, function);
}
known_functions
}
/// Demangle a C++ symbol.
pub fn demangle_str(name: &str) -> Result<String> {
if !name.starts_with("_Z") {
... | code_fim | hard | {
"lang": "rust",
"repo": "AlexApps99/nx-decomp-tools",
"path": "/viking/src/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Reader<T>
{
// temporary public
pub buffer : String,
pub count : usize,
pub reader : BufReader<T>,
}
impl<T: Read> ItemReader for Reader<T>
{
fn lookahead(&mut self) -> String { self.buffer.to_string() }
fn x9(&mut self) -> String
{
self.buffer.clear()... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/sch/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehennes775/bbcmd path: /src/sch/reader.rs
use std::io::{BufReader, Read, BufRead};
use crate::sch::item_params::ItemParams;
use crate::sch::item::Item;
use crate::sch::{arc, complex, r#box, text, circle, bus, pin, net, line, path};
use crate::sch::arc::Arc;
use crate::sch::text::Text;
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/sch/reader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn lookahead(&self) -> String
{
self.buffer.to_string()
}
pub fn x1(&mut self) -> String
{
self.buffer.clear();
self.count = self.reader.read_line(&mut self.buffer).unwrap();
self.buffer.to_string()
}
pub fn x2(&mut self) -> Result<Item... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/sch/reader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SuperiorJT/twilight path: /http/src/request/channel/get_pins.rs
use crate::{
client::Client,
request::Request,
response::{marker::ListBody, ResponseFuture},
routing::Route,
};
use twilight_model::{channel::Message, id::ChannelId};
/// Get the pins of a channel.
#[must_use = "req... | code_fim | medium | {
"lang": "rust",
"repo": "SuperiorJT/twilight",
"path": "/http/src/request/channel/get_pins.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mokomull/x11_client path: /src/bin/client_init.rs
use x11_client::*;
use std::io::prelude::*;
use std::os::unix::net::UnixStream;
fn main() {
let mut socket = UnixStream::connect("/tmp/.X11-unix/X0").unwrap();
let client_init: Vec<_> = ClientInit::new().into();
socket.write_all(&c... | code_fim | hard | {
"lang": "rust",
"repo": "mokomull/x11_client",
"path": "/src/bin/client_init.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("\tdepths:");
for depth in screen.allowed_depths {
println!("\t\tdepth: {}", depth.depth);
println!("\t\tvisuals:");
for visual in depth.visuals {
println!("\t\t\tvisual_id: {}", visual.id);
println!("\t\t\tclass... | code_fim | hard | {
"lang": "rust",
"repo": "mokomull/x11_client",
"path": "/src/bin/client_init.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/serde_with/tests/serde_as/key_value_map.rs
use
super
:
:
*
;
use
core
:
:
str
:
:
FromStr
;
use
serde_test
:
:
Configure
;
use
serde_with
:
:
{
serde_as
KeyValueMap
}
;
use
std
:
:
net
:
:
IpAddr
;
#
[
serde_as
]
#
[
derive
(
Debug
Clone
Partia... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_with/tests/serde_as/key_value_map.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>(
vec
!
[
"
c
"
.
to_string
(
)
"
d
"
.
to_string
(
)
"
2
"
.
to_string
(
)
]
)
]
}
;
is_equal
(
kvmap
expect
!
[
[
r
#
"
{
"
a
"
:
[
"
b
"
"
1
"
]
"
c
"
:
[
"
d
"
"
2
"
]
}
"
#
]
]
)
;
}
#
[
test
]
fn
test_kvmap_complex_key_serde_test
(
)
{
#
[
derive
(
Debug
Clone
PartialEq
Eq
Serialize
Deserialize
)
]
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_with/tests/serde_as/key_value_map.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(
0
)
U8
(
0
)
U8
(
0
)
TupleEnd
U8
(
24
)
TupleEnd
Struct
{
name
:
"
ComplexKey
"
len
:
2
}
Str
(
"
bar
"
)
Str
(
"
b
"
)
Str
(
"
baz
"
)
I32
(
1
)
StructEnd
Tuple
{
len
:
2
}
NewtypeVariant
{
name
:
"
IpAddr
"
variant
:
"
V6
"
}
Tuple
{
len
:
16
}
U8
(
0
)
U8
(
0
)
U8
(
0
)
U8
(
0
)
U8
(
0
)
U8
(
0
)
U... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_with/tests/serde_as/key_value_map.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("similar image: {}", checker.is_similar(img1, img2)) // true !
}<|fim_prefix|>// repo: po3rin/rust_playground path: /try-simimg/src/main.rs
use simimgrs;
use image;
fn main() {
let img1 = image::open("testdata/go1.jpg").unwrap();
let img2 = image::open("testdata/go2.jpg").unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "po3rin/rust_playground",
"path": "/try-simimg/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let checker = simimgrs::SimilarChecker::new().threshold(10).compression_size(8, 8);
println!("similar image: {}", checker.is_similar(img1, img2)) // true !
}<|fim_prefix|>// repo: po3rin/rust_playground path: /try-simimg/src/main.rs
use simimgrs;
use image;
fn main() {
<|fim_middle|> let img... | code_fim | medium | {
"lang": "rust",
"repo": "po3rin/rust_playground",
"path": "/try-simimg/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: po3rin/rust_playground path: /try-simimg/src/main.rs
use simimgrs;
use image;
fn main() {
<|fim_suffix|> println!("similar image: {}", checker.is_similar(img1, img2)) // true !
}<|fim_middle|> let img1 = image::open("testdata/go1.jpg").unwrap();
let img2 = image::open("testdata/go2.jp... | code_fim | hard | {
"lang": "rust",
"repo": "po3rin/rust_playground",
"path": "/try-simimg/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: another-s347/rusty-p4 path: /example/src/bin/mycontroller.rs
#[macro_use]
extern crate rusty_p4;
use rusty_p4::util::flow::*;
use rusty_p4::util::value::*;
use std::net::Ipv4Addr;
use std::path::Path;
use std::str::FromStr;
use rusty_p4::p4rt::bmv2::Bmv2SwitchConnection;
use rusty_p4::p4rt::pi... | code_fim | hard | {
"lang": "rust",
"repo": "another-s347/rusty-p4",
"path": "/example/src/bin/mycontroller.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ingress_sw.write_table_entry(table_entry).unwrap();
// let table_entry = build_table_entry(
// pipeconf.get_p4info(),
// "MyIngress.myTunnel_exact",
// &[("hdr.myTunnel.dst_id", EXACT(tunnel_id))],
// false,
// "MyIngress.myTunnel_forward"... | code_fim | hard | {
"lang": "rust",
"repo": "another-s347/rusty-p4",
"path": "/example/src/bin/mycontroller.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ipp-collect/ipp.rs path: /ipp/src/client/client_isahc.rs
use futures_util::io::BufReader;
use http::Method;
use isahc::{
config::{RedirectPolicy, SslOption},
prelude::*,
Body,
};
use log::debug;
use crate::{
client::{IppClient, IppError, CONNECT_TIMEOUT},
proto::{parser::Ipp... | code_fim | hard | {
"lang": "rust",
"repo": "ipp-collect/ipp.rs",
"path": "/ipp/src/client/client_isahc.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.0.ignore_tls_errors {
debug!("Setting dangerous TLS options");
builder = builder.ssl_options(
SslOption::DANGER_ACCEPT_INVALID_CERTS
| SslOption::DANGER_ACCEPT_REVOKED_CERTS
| SslOption::DANGER_ACCEPT_INVALID_H... | code_fim | medium | {
"lang": "rust",
"repo": "ipp-collect/ipp.rs",
"path": "/ipp/src/client/client_isahc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> IsahcClient<'a> {
pub async fn send_request(&self, request: IppRequestResponse) -> Result<IppRequestResponse, IppError> {
let mut builder = Request::builder();
if let Some(timeout) = self.0.request_timeout {
debug!("Setting request timeout to {:?}", timeout);
... | code_fim | hard | {
"lang": "rust",
"repo": "ipp-collect/ipp.rs",
"path": "/ipp/src/client/client_isahc.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Seiichi-Yahiro/bomberman path: /src/game_states/game_state_builder.rs
use crate::game_states::state_manager::{GameState, Resources};
use crate::utils::asset_storage::{Asset, AssetStorage};
pub struct GameStateBuilder {
pub build: Box<dyn FnOnce(&Resources) -> Box<dyn GameState>>,
}
#[deriv... | code_fim | hard | {
"lang": "rust",
"repo": "Seiichi-Yahiro/bomberman",
"path": "/src/game_states/game_state_builder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.asset_loaders.push(Box::new(f));
self
}
pub fn load_asset_with(mut self, f: impl FnOnce(&mut AssetStorage) + 'static) -> Self {
self.asset_loaders.push(Box::new(f));
self
}
pub fn build(
self,
f: impl FnOnce(&Resources) -> Box<dyn Game... | code_fim | hard | {
"lang": "rust",
"repo": "Seiichi-Yahiro/bomberman",
"path": "/src/game_states/game_state_builder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn build(
self,
f: impl FnOnce(&Resources) -> Box<dyn GameState> + 'static,
) -> GameStateBuilder {
let builder = move |resources: &Resources| {
self.asset_loaders.into_iter().for_each(|load| {
load(&mut *resources.asset_storage.write().unwra... | code_fim | medium | {
"lang": "rust",
"repo": "Seiichi-Yahiro/bomberman",
"path": "/src/game_states/game_state_builder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if valid_separator {
criteria.extend_from_slice("Ok: Every pair of hexadecimal digits must be \
separated by ':'\n".as_bytes());
} else {
criteria.extend_from_slice("Err: Every pair of hexadecimal digits must be \
separated by ':'\n".as_bytes());
}
if valid_values {
criteria.extend_from_sli... | code_fim | hard | {
"lang": "rust",
"repo": "troyhonegger/siip",
"path": "/node/pallets/siip/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: troyhonegger/siip path: /node/pallets/siip/src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
/// Edit this file to define custom logic or remove it if it is not needed.
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
/// https://substrate.dev/docs/en/knowledgebas... | code_fim | hard | {
"lang": "rust",
"repo": "troyhonegger/siip",
"path": "/node/pallets/siip/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Ensures that there is some modification
ensure!(cert != old_cert, Error::<T>::NoModifications);
CertificateMap::<T>::take(&domain);
CertificateMap::<T>::insert(&domain, cert.clone());
//Modifies the reverse lookup map
let mut certs = ReverseMap::<T>::take(&ip_addr.clone());
certs.... | code_fim | hard | {
"lang": "rust",
"repo": "troyhonegger/siip",
"path": "/node/pallets/siip/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_lss.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_lss.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn lss_3() {
run_test(&Instruction { mnemonic: Mnemonic::LSS, operand1: Some(Direct(SI)), operand2: Some(IndirectScaledIndexed(RSI, RAX, Eight, Some(OperandSize::Far16), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcas... | code_fim | hard | {
"lang": "rust",
"repo": "purpleposeidon/rust-x86asm",
"path": "/src/test/instruction_tests/instr_lss.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Knight-Ops/raspi-os path: /src/runtime_init.rs
pub trait RuntimeInit {
unsafe fn init(&self) -> ! {
extern "C" {
static mut __bss_start: u64;
static mut __bss_end: u64;
}
r0::zero_bss(&mut __bss_start, &mut __bss_end);
<|fim_suffix|>struct Se... | code_fim | easy | {
"lang": "rust",
"repo": "Knight-Ops/raspi-os",
"path": "/src/runtime_init.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gba-rs/gba-emu path: /src/thumb_formats/add_subtract.rs
#![allow(non_camel_case_types)]
use crate::operations::instruction::Instruction;
use crate::operations::{arm_arithmetic};
use crate::cpu::{cpu::CPU};
use std::fmt;
use crate::memory::memory_bus::MemoryBus;
#[derive(Debug, PartialEq)]
pub e... | code_fim | hard | {
"lang": "rust",
"repo": "gba-rs/gba-emu",
"path": "/src/thumb_formats/add_subtract.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn add_i() {
let a: AddSubtract = AddSubtract::from(0x1CD1);
assert_eq!(a.destination_register, 1);
assert_eq!(a.source_register, 2);
assert_eq!(a.op_register, 3);
assert_eq!(a.opcode, OpCodes::ADD_I);
assert_eq!(a.immediate, 1);
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "gba-rs/gba-emu",
"path": "/src/thumb_formats/add_subtract.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn row_parsed(i: &str) -> IResult<&str, RowParsed> {
alt((transition, infinity_final_state, final_state))(i)
}
pub fn vec_rows_parsed(i: &str) -> IResult<&str, Vec<RowParsed>> {
separated_list(tag("\n"), row_parsed)(i)
}<|fim_prefix|>// repo: noeddl/rustfst path: /rustfst/src/parsers/text_fst/no... | code_fim | hard | {
"lang": "rust",
"repo": "noeddl/rustfst",
"path": "/rustfst/src/parsers/text_fst/nom_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noeddl/rustfst path: /rustfst/src/parsers/text_fst/nom_parser.rs
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::tab;
use nom::combinator::opt;
use nom::multi::separated_list;
use nom::number::complete::float;
use nom::sequence::preceded;
use nom::IResult;
use... | code_fim | hard | {
"lang": "rust",
"repo": "noeddl/rustfst",
"path": "/rustfst/src/parsers/text_fst/nom_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn final_state(i: &str) -> IResult<&str, RowParsed> {
let (i, state) = num(i)?;
let (i, weight) = optional_weight(i)?;
Ok((i, RowParsed::FinalState(FinalState { state, weight })))
}
fn infinity_final_state(i: &str) -> IResult<&str, RowParsed> {
let (i, state) = num(i)?;
let (i, _) = t... | code_fim | hard | {
"lang": "rust",
"repo": "noeddl/rustfst",
"path": "/rustfst/src/parsers/text_fst/nom_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deciduously/mifkad path: /src/backend/handlers.rs
// handlers.rs defines the actix_web handlers
use crate::data::{init_db, reset_db, reset_extday, write_db};
use crate::schema::{ExtendedDayConfig, School};
use crate::AppState;
use actix_web::{
self, fs::NamedFile, AsyncResponder, HttpRequest... | code_fim | hard | {
"lang": "rust",
"repo": "deciduously/mifkad",
"path": "/src/backend/handlers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
// Grab a blocking write lock inside inner scope
let mut a = state.school.write().unwrap();
// Perform the mutation
match action {
Toggle => (*a).toggle_kid(id),
AddExt => (*a).addext_kid(id),
Collect => (*a).collect_room(id),
... | code_fim | hard | {
"lang": "rust",
"repo": "deciduously/mifkad",
"path": "/src/backend/handlers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Assert
assert_eq!(dot, 1.0*1.0 + 2.0*2.0 + 3.0*3.0);
}
#[test]
fn len_unit_vector() {
// Arrange
let v = Vec3D::new(1.0, 0.0, 0.0);
// Act
let len = v.len();
// Assert
assert_eq!(len, 1.0);
}
#[test]
fn len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "SneManden/RustRaytracer",
"path": "/src/ray_tracer/vector_library.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.