text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>rand;
pub mod utils;
pub mod numpy;
pub mod constants;
pub mod intersection;
pub mod coord_convert;
pub mod stone_group;
pub mod board;
pub mod search;<|fim_prefix|>// repo: y-ich/A9.rs path: /rust_pyaq/src/lib.rs
#![feature(box_syntax)]
extern crate itertools;
#[cfg(feature = "ponder")]
<|fim_middle|>... | code_fim | medium | {
"lang": "rust",
"repo": "y-ich/A9.rs",
"path": "/rust_pyaq/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_operation_update_branch(
input: &crate::input::UpdateBranchInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::Error> {
let mut out = String::new();
let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out);
crate::json_ser::serialize_structure_upda... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/amplify/src/operation_ser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JesseWright/aws-sdk-rust path: /sdk/amplify/src/operation_ser.rs
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn serialize_operation_create_app(
input: &crate::input::CreateAppInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::Error> {
le... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/amplify/src/operation_ser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test2 = static_init!(
TestRandomTimer<'static, VirtualTimer<'static, Ast<'static>>>,
TestRandomTimer::new(virtual_timer2, 37, 'B')
);
virtual_timer2.set_timer_client(test2);
let virtual_timer3 = static_init!(VirtualTimer<'static, Ast<'static>>, VirtualTimer::new(mux));... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/imix/src/multi_timer_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let virtual_timer3 = static_init!(VirtualTimer<'static, Ast<'static>>, VirtualTimer::new(mux));
virtual_timer3.setup();
let test3 = static_init!(
TestRandomTimer<'static, VirtualTimer<'static, Ast<'static>>>,
TestRandomTimer::new(virtual_timer3, 89, 'C')
);
virtual_tim... | code_fim | hard | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/imix/src/multi_timer_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tock/tock path: /boards/imix/src/multi_timer_test.rs
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.
//! Test the behavior of a single alarm.
//! To add this test, include the line
//! ```
/... | code_fim | medium | {
"lang": "rust",
"repo": "tock/tock",
"path": "/boards/imix/src/multi_timer_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shakyShane/topics path: /topics_core/src/print/md.rs
use crate::context::Context;
use crate::doc::Doc;
// use crate::output::OutputDoc;
use crate::print::Print;
#[derive(Debug)]
pub struct MdPrinter;
impl Print for MdPrinter {
fn print_welcome(&self, _docs: &[Doc], _ctx: &Context) -> anyh... | code_fim | medium | {
"lang": "rust",
"repo": "shakyShane/topics",
"path": "/topics_core/src/print/md.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unimplemented!()
}
}
impl MdPrinter {
// pub fn print_md_doc(doc: &Doc, index: Option<usize>) -> Result<OutputDoc> {
// let output = String::new();
// for (i, _item) in doc.topics.iter().enumerate() {
// if let Some(index) = index {
// if i == i... | code_fim | medium | {
"lang": "rust",
"repo": "shakyShane/topics",
"path": "/topics_core/src/print/md.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MdPrinter {
// pub fn print_md_doc(doc: &Doc, index: Option<usize>) -> Result<OutputDoc> {
// let output = String::new();
// for (i, _item) in doc.topics.iter().enumerate() {
// if let Some(index) = index {
// if i == index {
// // l... | code_fim | medium | {
"lang": "rust",
"repo": "shakyShane/topics",
"path": "/topics_core/src/print/md.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set(&self, state: State) {
self.0.store(state as u8, Ordering::SeqCst);
}
pub fn get(&self) -> State {
match self.0.load(Ordering::SeqCst) {
0 => State::Uninitialized,
1 => State::Initializing,
2 => State::Initialized,
3 =... | code_fim | hard | {
"lang": "rust",
"repo": "ebkalderon/tower-lsp",
"path": "/src/service/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ServerState {
pub const fn new() -> Self {
ServerState(AtomicU8::new(State::Uninitialized as u8))
}
pub fn set(&self, state: State) {
self.0.store(state as u8, Ordering::SeqCst);
}
pub fn get(&self) -> State {
match self.0.load(Ordering::SeqCst) {
... | code_fim | medium | {
"lang": "rust",
"repo": "ebkalderon/tower-lsp",
"path": "/src/service/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebkalderon/tower-lsp path: /src/service/state.rs
//! Types representing the current state of the language server.
use std::fmt::{self, Debug, Formatter};
use std::sync::atomic::{AtomicU8, Ordering};
<|fim_suffix|>/// Atomic value which represents the current state of the server.
pub struct Ser... | code_fim | hard | {
"lang": "rust",
"repo": "ebkalderon/tower-lsp",
"path": "/src/service/state.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/rf/trx_gain_bw.rs
#[doc = "Register `trx_gain_bw` reader"]
pub struct R(crate::R<TRX_GAIN_BW_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<TRX_GAIN_BW_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl F... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/rf/trx_gain_bw.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `gc_rbb1` writer - "]
pub struct GC_RBB1_W<'a> {
w: &'a mut W,
}
impl<'a> GC_RBB1_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 3)) ... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/rf/trx_gain_bw.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `gc_lna` writer - "]
pub struct GC_LNA_W<'a> {
w: &'a mut W,
}
impl<'a> GC_LNA_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !0x07) | (value a... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/rf/trx_gain_bw.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut points = 0i32;
if let Ok(lines) = read_lines("./input.txt") {
for res in lines {
if let Ok(line) = res {
let split = line.split(' ');
let vec = split.collect::<Vec<&str>>();
match vec[0] {
"A" => match... | code_fim | hard | {
"lang": "rust",
"repo": "GambuzX/AdventOfCode",
"path": "/2022/Day 02/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GambuzX/AdventOfCode path: /2022/Day 02/main.rs
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
// The output is wrapped in a Result to allow matching on errors
// Returns an Iterator to the Reader of the lines of the file.
fn read_lines<P>(filename: P) -> io::Result<io::L... | code_fim | hard | {
"lang": "rust",
"repo": "GambuzX/AdventOfCode",
"path": "/2022/Day 02/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jac3km4/vakfu path: /src/main.rs
use std::fs::File;
use std::path::PathBuf;
use anyhow::{anyhow, Result};
use assets::jar::JarAssetIo;
use assets::tgam::TgamLoader;
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
use bevy::prelude::*;
use bevy_egui::EguiPlugin;
use map... | code_fim | hard | {
"lang": "rust",
"repo": "jac3km4/vakfu",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let game_path: PathBuf = pargs.value_from_str("--path")?;
let maps_path = game_path.join("contents").join("maps");
let gfx_path = maps_path.join("gfx.jar");
match pargs.value_from_str::<&str, i32>("--map") {
Ok(map_arg) => {
let map_path = maps_path.join("gfx").join(f... | code_fim | hard | {
"lang": "rust",
"repo": "jac3km4/vakfu",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AleoHQ/snarkOS path: /node/tcp/src/protocols/on_connect.rs
// Copyright (C) 2019-2023 Aleo Systems Inc.
// This file is part of the snarkOS library.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may ... | code_fim | hard | {
"lang": "rust",
"repo": "AleoHQ/snarkOS",
"path": "/node/tcp/src/protocols/on_connect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // register the OnConnect handler with the Node
let hdl = Box::new(ProtocolHandler(from_node_sender));
assert!(self.tcp().protocols.on_connect.set(hdl).is_ok(), "the OnConnect protocol was enabled more than once!");
}
/// Any initial actions to be executed after the handsh... | code_fim | hard | {
"lang": "rust",
"repo": "AleoHQ/snarkOS",
"path": "/node/tcp/src/protocols/on_connect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benstiglitz/lunatic path: /uptown_funk/src/types/primitive.rs
use crate::{FromWasm, ToWasm, Trap};
impl FromWasm for u32 {
type From = u32;
type State = ();
fn from(
_state: &mut Self::State,
_executor: &impl crate::Executor,
from: Self::From,
) -> Resul... | code_fim | hard | {
"lang": "rust",
"repo": "benstiglitz/lunatic",
"path": "/uptown_funk/src/types/primitive.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromWasm for i64 {
type From = i64;
type State = ();
fn from(
_state: &mut Self::State,
_executor: &impl crate::Executor,
from: Self::From,
) -> Result<Self, Trap>
where
Self: Sized,
{
Ok(from)
}
}
impl ToWasm for i64 {
type To... | code_fim | hard | {
"lang": "rust",
"repo": "benstiglitz/lunatic",
"path": "/uptown_funk/src/types/primitive.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: senbrow/totalmapper path: /src/default_layouts.rs
// vim: shiftwidth=2
use std::collections::HashMap;
use crate::keys::{Layout, Mapping, KeyCode, Repeat};
use KeyCode::*;
use crate::layout_generation::{USKeyboardLayout, make_us_mappings};
use lazy_static::lazy_static;
use std::default::Default... | code_fim | hard | {
"lang": "rust",
"repo": "senbrow/totalmapper",
"path": "/src/default_layouts.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> row_a: "".to_string(),
row_a_shift: "".to_string(),
row_a_alt_gr: " = &)(/_$".to_string(),
row_a_shift_alt_gr: "".to_string(),
row_z: "".to_string(),
row_z_shift: "".to_string(),
row_z_alt_gr: " !+#".to_string(),
row_z_shift_alt_gr: "".to_string(),
};
let ... | code_fim | hard | {
"lang": "rust",
"repo": "senbrow/totalmapper",
"path": "/src/default_layouts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Mapping { from: vec![I], to: vec![C], repeat: Repeat::Special { keys: vec![F20], delay_ms: 180, interval_ms: 30 }, ..Default::default() },
Mapping { from: vec![K], to: vec![T], repeat: Repeat::Special { keys: vec![LEFTCTRL, F20], delay_ms: 180, interval_ms: 30 }, ..Default::default() },
... | code_fim | hard | {
"lang": "rust",
"repo": "senbrow/totalmapper",
"path": "/src/default_layouts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn start_kernel() {
let kernel = setup::from_devicetree();
kernel.logger.log("Hello from Rust\n");
loop {}
}<|fim_prefix|>// repo: holaymzhang/aarch64 path: /kernel/kernel/src/lib.rs
#![no_std]
extern crate alloc;
extern crate bootstrap;
extern crate devicetree;
ex... | code_fim | medium | {
"lang": "rust",
"repo": "holaymzhang/aarch64",
"path": "/kernel/kernel/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: holaymzhang/aarch64 path: /kernel/kernel/src/lib.rs
#![no_std]
extern crate alloc;
extern crate bootstrap;
extern crate devicetree;
extern crate interrupt;
extern crate log;
extern crate memory;
extern crate numeric;
extern crate pl011;
extern crate runtime;
extern crate sync;
<|fim_suffix|>use... | code_fim | medium | {
"lang": "rust",
"repo": "holaymzhang/aarch64",
"path": "/kernel/kernel/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DemonusPC/ray-tracing-demo path: /src/ray.rs
use crate::vec3::Vec3;
pub struct Ray {
origin: Vec3,
direction: Vec3,
time: f64,
}
impl Ray {
pub fn new(origin: &Vec3, direction: &Vec3, time: f64) -> Ray {
Ray {
origin: origin.clone(),
direction: d... | code_fim | hard | {
"lang": "rust",
"repo": "DemonusPC/ray-tracing-demo",
"path": "/src/ray.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_at() {
let o = Vec3::empty();
let dir = Vec3::new(1.0, 1.0, 1.0);
let result = Ray::new(&o, &dir, 0.0);
equality(&result.at(2.0), 2.0, 2.0, 2.0);
}
}<|fim_prefix|>// repo: DemonusPC/ray-tracing-demo path: /src/ray.rs
use crate::vec3::Vec3;
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "DemonusPC/ray-tracing-demo",
"path": "/src/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let o = Vec3::empty();
let dir = Vec3::new(1.0, 1.0, 1.0);
let result = Ray::new(&o, &dir, 0.0);
equality(&result.at(2.0), 2.0, 2.0, 2.0);
}
}<|fim_prefix|>// repo: DemonusPC/ray-tracing-demo path: /src/ray.rs
use crate::vec3::Vec3;
pub struct Ray {
origin: Vec3,
... | code_fim | hard | {
"lang": "rust",
"repo": "DemonusPC/ray-tracing-demo",
"path": "/src/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[derive(Deserialize, Serialize)]
struct Struct {
hash: CryptoHash,
}
#[test]
fn test_serialize_success() {
let hash = hash(&[0, 1, 2]);
let s = Struct { hash: hash.into() };
let encoded = serde_json::to_strin... | code_fim | hard | {
"lang": "rust",
"repo": "zhiwei-w-luo/near-rpc",
"path": "/src/types/hash.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiwei-w-luo/near-rpc path: /src/types/hash.rs
use std::convert::TryFrom;
use std::fmt;
use std::hash::{Hash, Hasher};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::types::logging::pretty_hash;
use crate::types::serialize::{from_base, to_base, BaseDecode};
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "zhiwei-w-luo/near-rpc",
"path": "/src/types/hash.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hectorip/LearningRust path: /life/src/main.rs
fn sentido() -> String {
<|fim_suffix|> println!("El sentido de la vida: {}", sentido());
println!("Cuando empieza la senectud: {}", senectud());
}<|fim_middle|> "HAcerla chillar".to_string()
}
fn senectud() -> i32 {
let edad = 90;
... | code_fim | medium | {
"lang": "rust",
"repo": "hectorip/LearningRust",
"path": "/life/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("El sentido de la vida: {}", sentido());
println!("Cuando empieza la senectud: {}", senectud());
}<|fim_prefix|>// repo: hectorip/LearningRust path: /life/src/main.rs
fn sentido() -> String {
"HAcerla chillar".to_string()
}
<|fim_middle|>fn senectud() -> i32 {
let edad = 90;
... | code_fim | medium | {
"lang": "rust",
"repo": "hectorip/LearningRust",
"path": "/life/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let edad = 90;
edad
}
fn main() {
println!("El sentido de la vida: {}", sentido());
println!("Cuando empieza la senectud: {}", senectud());
}<|fim_prefix|>// repo: hectorip/LearningRust path: /life/src/main.rs
fn sentido() -> String {
<|fim_middle|> "HAcerla chillar".to_string()
}
fn... | code_fim | medium | {
"lang": "rust",
"repo": "hectorip/LearningRust",
"path": "/life/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ),
&style
);
println!("Writing a.png");
buffer.save("a.png").unwrap()
}<|fim_prefix|>// repo: eterevsky/grapheq path: /examples/test1.rs
use grapheq;
use image::Luma;
fn main() {
let style: grapheq::Style<Luma<u8>> = grapheq::Style::new();
let stretch = 100.0;
let ... | code_fim | medium | {
"lang": "rust",
"repo": "eterevsky/grapheq",
"path": "/examples/test1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eterevsky/grapheq path: /examples/test1.rs
use grapheq;
use image::Luma;
fn main() {
let style: grapheq::Style<Luma<u8>> = grapheq::Sty<|fim_suffix|>/ x).sin(),
&|x, _y| (
stretch * (stretch/x).cos() / (x*x),
1.,
),
&style
);
println!(... | code_fim | medium | {
"lang": "rust",
"repo": "eterevsky/grapheq",
"path": "/examples/test1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filecoin-project/bls-signatures path: /bls-signatures-ffi/src/responses.rs
use crate::{BLSDigest, BLSPrivateKey, BLSPublicKey, BLSSignature};
/// HashResponse
#[repr(C)]
pub struct HashResponse {
pub digest: BLSDigest,
}
<|fim_suffix|>/// AggregateResponse
#[repr(C)]
pub struct Aggregate... | code_fim | medium | {
"lang": "rust",
"repo": "filecoin-project/bls-signatures",
"path": "/bls-signatures-ffi/src/responses.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// PrivateKeyPublicKeyResponse
#[repr(C)]
pub struct PrivateKeyPublicKeyResponse {
pub public_key: BLSPublicKey,
}
#[no_mangle]
pub unsafe extern "C" fn destroy_private_key_public_key_response(
ptr: *mut PrivateKeyPublicKeyResponse,
) {
let _ = Box::from_raw(ptr);
}<|fim_prefix|>// repo: fi... | code_fim | medium | {
"lang": "rust",
"repo": "filecoin-project/bls-signatures",
"path": "/bls-signatures-ffi/src/responses.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<&str> for Symbol {
fn from(s: &str) -> Self {
s.parse().unwrap()
}
}<|fim_prefix|>// repo: NathanSWard/gemini path: /gemini/src/symbol.rs
use serde::{Deserialize, Serialize};
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
<|fim_middle|>#[derive(
Deseriali... | code_fim | hard | {
"lang": "rust",
"repo": "NathanSWard/gemini",
"path": "/gemini/src/symbol.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NathanSWard/gemini path: /gemini/src/symbol.rs
use serde::{Deserialize, Serialize};
use strum_macros::{AsRefStr, Display, EnumString, IntoStaticStr};
<|fim_suffix|>impl From<&str> for Symbol {
fn from(s: &str) -> Self {
s.parse().unwrap()
}
}<|fim_middle|>#[derive(
Deseriali... | code_fim | hard | {
"lang": "rust",
"repo": "NathanSWard/gemini",
"path": "/gemini/src/symbol.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: radioreptile/szyszka path: /src/class_dialog_rule_add_text.rs
use gtk::prelude::*;
#[derive(Clone)]
pub struct GuiAddText {
pub radio_button_add_text_before_name: gtk::RadioButton,
pub radio_button_add_text_after_name: gtk::RadioButton,
pub entry_add_text_text_to_add: gtk::Entry,
}... | code_fim | medium | {
"lang": "rust",
"repo": "radioreptile/szyszka",
"path": "/src/class_dialog_rule_add_text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
radio_button_add_text_before_name,
radio_button_add_text_after_name,
entry_add_text_text_to_add,
}
}
}<|fim_prefix|>// repo: radioreptile/szyszka path: /src/class_dialog_rule_add_text.rs
use gtk::prelude::*;
#[derive(Clone)]
pub struct GuiAd... | code_fim | hard | {
"lang": "rust",
"repo": "radioreptile/szyszka",
"path": "/src/class_dialog_rule_add_text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entry_add_text_text_to_add: gtk::Entry = builder.object("entry_add_text_text_to_add").unwrap();
Self {
radio_button_add_text_before_name,
radio_button_add_text_after_name,
entry_add_text_text_to_add,
}
}
}<|fim_prefix|>// repo: radiorept... | code_fim | hard | {
"lang": "rust",
"repo": "radioreptile/szyszka",
"path": "/src/class_dialog_rule_add_text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lower = s.to_lowercase();
match lower.as_str() {
"linux" => Ok(OsType::Linux),
"macos" | "darwin" => Ok(OsType::Darwin),
// TODO: test if this actually matches
"dragonfly" => Ok(OsType::Dragonfly),
// TODO: test if this actual... | code_fim | medium | {
"lang": "rust",
"repo": "editorconfig-checker/editorconfig-checker.rust",
"path": "/src/ostype.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: editorconfig-checker/editorconfig-checker.rust path: /src/ostype.rs
use std::str::FromStr;
use crate::error::{Error, Result};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_os_type() {
assert!("HALLO".parse::<OsType>().is_err());
assert_eq!("Linux".pa... | code_fim | hard | {
"lang": "rust",
"repo": "editorconfig-checker/editorconfig-checker.rust",
"path": "/src/ostype.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ConsoleTVs/EVM path: /tests/addition.rs
mod tests {
extern crate evm;
use evm::opcodes::Opcode;
use evm::values::Value;
// The program instructions to add two numbers and print it.
static CODE: &[Opcode] = &[
Opcode::Load(0, 0), // Load to register 0, the value from ... | code_fim | hard | {
"lang": "rust",
"repo": "ConsoleTVs/EVM",
"path": "/tests/addition.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn bool_addition() {
// The constant pool.
let constants = &[
Value::VBoolean(true), // true (bool).
Value::VBoolean(true), // true (bool).
];
// The registers to use (They can be default-initialized).
let registers = &mut REG... | code_fim | hard | {
"lang": "rust",
"repo": "ConsoleTVs/EVM",
"path": "/tests/addition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jinjagit/shortest_path path: /src/random.rs
#[path = "utils.rs"]
mod utils;
use rand::prelude::*;
#[derive(Debug)] // This annotation allows debugging print of struct
#[derive(Clone)]
struct Ant {
route: Vec<usize>,
visited: Vec<bool>,
not_visited: Vec<usize>,
}
#[allow(dead_code)... | code_fim | hard | {
"lang": "rust",
"repo": "jinjagit/shortest_path",
"path": "/src/random.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set each ant to start at a random city.
ants[i].visit(rng.gen_range(0..n));
}
// let mut best_route: Vec<usize> = vec![];
let mut best_route_length: f32 = 0.0;
let mut worst_route: Vec<usize> = vec![];
let mut worst_route_length: f32 = 0.0;
let mut all_lengths... | code_fim | hard | {
"lang": "rust",
"repo": "jinjagit/shortest_path",
"path": "/src/random.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if j == 0 {
best_route_length = length;
worst_route_length = length;
// best_route = route.clone();
worst_route = route.clone();
}
if length < best_route_length {
best_route_length = length... | code_fim | hard | {
"lang": "rust",
"repo": "jinjagit/shortest_path",
"path": "/src/random.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krixi/remud path: /remud-lib/src/world/action/immortal/room.rs
.to_string(),
),
}
} else {
Err(
"Enter a room subcommand: info, desc, link, new, regions, remove, or unlink."
.to_string(),
)
}
}
#[derive(De... | code_fim | hard | {
"lang": "rust",
"repo": "krixi/remud",
"path": "/remud-lib/src/world/action/immortal/room.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let removed = room.remove_exit(direction).is_some();
updates.persist(persist::room::RemoveExit::new(room.id(), *direction));
let message = if removed {
format!("Removed exit {}.", direction.as_to_str())
} else {
format!("The... | code_fim | hard | {
"lang": "rust",
"repo": "krixi/remud",
"path": "/remud-lib/src/world/action/immortal/room.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct RoomRemove {
pub actor: Entity,
}
into_action!(RoomRemove);
#[tracing::instrument(name = "remove room system", skip_all)]
pub fn room_remove_system(
mut commands: Commands,
mut action_reader: EventReader<Action>,
mut queued_action_w... | code_fim | hard | {
"lang": "rust",
"repo": "krixi/remud",
"path": "/remud-lib/src/world/action/immortal/room.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leakingtapan/buildkite-rs path: /buildkite/src/build.rs
use crate::types::{Build, Result};
use crate::http::HttpClient;
use crate::http;
<|fim_suffix|>impl<'a> BuildService<'a> {
pub fn new(client: &'a HttpClient) -> BuildService {
BuildService {
client: client,
... | code_fim | medium | {
"lang": "rust",
"repo": "leakingtapan/buildkite-rs",
"path": "/buildkite/src/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn list(&self, org: &str, pipeline: &str) -> Result<Vec<Build>> {
let base_url = http::org_url(org);
let url = format!("{}/pipelines/{}/builds", base_url, pipeline);
self.client.get_response(url.as_str())
}
}<|fim_prefix|>// repo: leakingtapan/buildkite-rs path: /bui... | code_fim | hard | {
"lang": "rust",
"repo": "leakingtapan/buildkite-rs",
"path": "/buildkite/src/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:new();
hasher.update(b"Hashing is a good way to take up CPU time.");
let _res = hasher.finalize();
}
}<|fim_prefix|>// repo: xjzi/OS-Overhead path: /work/src/lib.rs
#![no_std]
use blake2::{Blake2b, Digest};
pub fn work() {
<|fim_middle|> for _ in 0..10_000_000 {
let mut ... | code_fim | medium | {
"lang": "rust",
"repo": "xjzi/OS-Overhead",
"path": "/work/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xjzi/OS-Overhead path: /work/src/lib.rs
#![no_std]
use blake2::{Blake2b, Digest};
pub fn work() {
<|fim_suffix|> up CPU time.");
let _res = hasher.finalize();
}
}<|fim_middle|> for _ in 0..10_000_000 {
let mut hasher = Blake2b::new();
hasher.update(b"Hashing is a... | code_fim | medium | {
"lang": "rust",
"repo": "xjzi/OS-Overhead",
"path": "/work/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GabrielMajeri/dustbox-rs path: /exeinfo/src/bin/exeinfo-main.rs
use clap::{Arg, App};
use dustbox::tools::read_binary;
use dustbox::format::ExeFile;
const VERSION: &str = "0.1";
<|fim_suffix|> match ExeFile::from_data(&data) {
Ok(exe) => exe.print_details(),
Err(e) => panic... | code_fim | hard | {
"lang": "rust",
"repo": "GabrielMajeri/dustbox-rs",
"path": "/exeinfo/src/bin/exeinfo-main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches = App::new("dustbox-exeinfo")
.version(VERSION)
.arg(Arg::with_name("INPUT")
.help("Sets the input file to use")
.required(true)
.index(1))
.get_matches();
let filename = matches.value_of("INPUT").unwr... | code_fim | medium | {
"lang": "rust",
"repo": "GabrielMajeri/dustbox-rs",
"path": "/exeinfo/src/bin/exeinfo-main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/test-logs path: /src/main.rs
#[macro_use]
extern crate log;
extern crate log4rs;
fn main() {
<|fim_suffix|> trace!("[topicA] booting up");
debug!("[topicB] booting up");
info!("[topicC] booting up");
warn!("[topicD] booting up");
error!("[topicE] booting up");
/... | code_fim | medium | {
"lang": "rust",
"repo": "fossabot/test-logs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/test-logs path: /src/main.rs
#[macro_use]
extern crate log;
extern crate log4rs;
<|fim_suffix|> log4rs::init_file("config/log4rs.yaml", Default::default()).unwrap();
trace!("[topicA] booting up");
debug!("[topicB] booting up");
info!("[topicC] booting up");
warn!("[... | code_fim | easy | {
"lang": "rust",
"repo": "fossabot/test-logs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!("[topicA] booting up");
debug!("[topicB] booting up");
info!("[topicC] booting up");
warn!("[topicD] booting up");
error!("[topicE] booting up");
// ...
}<|fim_prefix|>// repo: fossabot/test-logs path: /src/main.rs
#[macro_use]
extern crate log;
extern crate log4rs;
fn ma... | code_fim | medium | {
"lang": "rust",
"repo": "fossabot/test-logs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wakizaka/BTC-Parachain path: /crates/bitcoin/src/error.rs
use frame_support::dispatch::DispatchError;
#[derive(Debug)]
pub enum Error {
MalformedMerkleProof,
InvalidMerkleProof,
EOS,
MalformedHeader,
MalformedTransaction,
UnsupportedInputFormat,
MalformedWitnessOutpu... | code_fim | medium | {
"lang": "rust",
"repo": "wakizaka/BTC-Parachain",
"path": "/crates/bitcoin/src/error.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> DispatchError::Module {
// FIXME: this should be set to the module returning the error
// It should be super easy to do if Substrate has an "after request"
// kind of middleware but not sure if it does
index: 0,
error: error as u8,
... | code_fim | medium | {
"lang": "rust",
"repo": "wakizaka/BTC-Parachain",
"path": "/crates/bitcoin/src/error.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> (x, y)
}
}
#[derive(Clone, Copy, Debug)]
enum Direction {
East,
SouthEast,
SouthWest,
West,
NorthWest,
NorthEast,
}
fn parse_direction(i: &str) -> IResult<&str, Direction, Error<&str>> {
let east = value(Direction::East, tag("e"));
let southeast = value(Direct... | code_fim | hard | {
"lang": "rust",
"repo": "cwhakes/AdventOfCode2020",
"path": "/day24/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cwhakes/AdventOfCode2020 path: /day24/src/main.rs
use nom::{
branch::alt,
bytes::complete::tag,
combinator::value,
error::Error,
IResult,
multi::many0,
};
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::Read;
fn main() {
let mut buf = Strin... | code_fim | hard | {
"lang": "rust",
"repo": "cwhakes/AdventOfCode2020",
"path": "/day24/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
Call(r, args) => {
r.set_real(&mut regs);
for reg in args {
reg.set_real(&mut regs);
}
}
Ret(r1, r2) => {
r1.rm = A1;
... | code_fim | hard | {
"lang": "rust",
"repo": "yomaytk/ruscaml",
"path": "/src/regalloc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yomaytk/ruscaml path: /src/regalloc.rs
use super::*;
use vm::*;
pub const REG_SIZE: usize = 10;
pub const A1: i32 = 0;
pub fn regalloc(pg: &mut vm::Program) {
let mut regs: [i32; REG_SIZE] = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
for decl in &mut pg.decls {
for instr in &mut... | code_fim | hard | {
"lang": "rust",
"repo": "yomaytk/ruscaml",
"path": "/src/regalloc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Reaction {
fn new(description: String) -> Reaction {
Regex::new(r"<x=(?P<x>-?\d+), y=(?P<y>-?\d+), z=(?P<z>-?\d+)>")
.unwrap()
.captures_iter(&contents)
.map(|capture| {
[
Particle::new(capture["x"].parse().unwrap()),... | code_fim | hard | {
"lang": "rust",
"repo": "nventuro/adventofcode-rust",
"path": "/day-14/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nventuro/adventofcode-rust path: /day-14/src/main.rs
use std::collections::HashMap;
use std::fs;
extern crate regex;
use regex::Regex;
fn main() {
let filename = "input";
let contents = fs::read_to_string(filename)
.unwrap_or_else(|_| panic!("Failed to read from file '{}'", fil... | code_fim | medium | {
"lang": "rust",
"repo": "nventuro/adventofcode-rust",
"path": "/day-14/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lightsing/Yemantic-UI path: /src/collections/label/label.rs
use either::Either;
use yew::prelude::*;
use crate::{cx, sui};
use crate::helper::*;
use crate::collections::Icon;
use crate::collections::label::LabelDetail;
/// A label displays content classification.
pub struct Label {
link: C... | code_fim | hard | {
"lang": "rust",
"repo": "lightsing/Yemantic-UI",
"path": "/src/collections/label/label.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<LabelAttachedPosition> for &'static str {
fn from(l: LabelAttachedPosition) -> Self {
use LabelAttachedPosition::*;
match l {
Top => "top",
Bottom => "bottom",
TopRight => "top right",
TopLeft => "top left",
BottomL... | code_fim | hard | {
"lang": "rust",
"repo": "lightsing/Yemantic-UI",
"path": "/src/collections/label/label.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= 0
};
S0_COLOR_MODER { bits }
}
#[doc = "Bits 8:9 - s1 to s0 factor mode"]
#[inline]
pub fn s1_s0_factor_mode(&self) -> S1_S0_FACTOR_MODER {
let bits = {
const MASK: u8 = 3;
const OFFSET: u8 = 8;
((self.bits >> OFFSET) & MASK as ... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/pxp/porter_duff_ctrl/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/pxp/porter_duff_ctrl/mod.rs
bits: u32,
}
impl super::PORTER_DUFF_CTRL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/pxp/porter_duff_ctrl/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ub struct _S1_GLOBAL_ALPHA_MODEW<'a> {
w: &'a mut W,
}
impl<'a> _S1_GLOBAL_ALPHA_MODEW<'a> {
#[doc = r" Writes raw bits to the field"]
#[inline]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
const MASK: u8 = 3;
const OFFSET: u8 = 10;
self.w.bits &= !((MASK as u... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/pxp/porter_duff_ctrl/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SteveBattista/ring-fuzzer path: /src/main.rs
#![forbid(unsafe_code)]
#[macro_use]
extern crate honggfuzz;
use rand::*;
use ring::aead::{AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305};
use ring::agreement::{ECDH_P256, ECDH_P384, X25519};
use ring::digest::{Context, SHA256, SHA384, SHA512, SHA512_2... | code_fim | hard | {
"lang": "rust",
"repo": "SteveBattista/ring-fuzzer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data: &[u8],
random1: &[u8],
random2: &[u8],
algo:ring::pbkdf2::Algorithm,
) {
let mut out = vec![0; random1.len()];
let iterations = random2.len();
let iterations = std::num::NonZeroU32::new(iterations as u32).unwrap();
ring::pbkdf2::derive(algo, iterations, &random2, &dat... | code_fim | hard | {
"lang": "rust",
"repo": "SteveBattista/ring-fuzzer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Verify the signature of the message using the public key. Normally the
// verifier of the message would parse the inputs to this code out of the
// protocol message(s) sent by the signer.
let peer_public_key =
ring::signature::UnparsedPublicKey::new(verifyalgo, peer_public_key_b... | code_fim | hard | {
"lang": "rust",
"repo": "SteveBattista/ring-fuzzer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Keith-S-Thompson/fizzbuzz-polyglot path: /fizzbuzz.rs
// Language: Rust
// Web site: https://www.rust-lang.org/
// Last tested on: Ubuntu 22.04.1
<|fim_suffix|> 0 => println!("FizzBuzz"),
3 | 6 | 9 | 12 => println!("Fizz"),
5 | 10 =>... | code_fim | medium | {
"lang": "rust",
"repo": "Keith-S-Thompson/fizzbuzz-polyglot",
"path": "/fizzbuzz.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 5 | 10 => println!("Buzz"),
_ => println!("{}", i),
}
}
}<|fim_prefix|>// repo: Keith-S-Thompson/fizzbuzz-polyglot path: /fizzbuzz.rs
// Language: Rust
// Web site: https://www.rust-lang.org/
// Last tested on: Ubuntu 22.04.1
<|fim_middle|>// Re... | code_fim | hard | {
"lang": "rust",
"repo": "Keith-S-Thompson/fizzbuzz-polyglot",
"path": "/fizzbuzz.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makarchuk/aoc2015 path: /day10/src/main.rs
use std::io::{self, Read};
fn transform(st: &str) -> String {
let mut last_char = '\n';
let mut counter = 0;
let mut result = String::new();
for ch in st.chars() {
if ch == last_char {
counter += 1
} else {
... | code_fim | medium | {
"lang": "rust",
"repo": "makarchuk/aoc2015",
"path": "/day10/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!(
"Len for 50 is {}",
(1..=50)
.fold(input, |acc, i| {
if i == 41 {
println!("Len for 40 is {}", acc.chars().count())
}
... | code_fim | medium | {
"lang": "rust",
"repo": "makarchuk/aoc2015",
"path": "/day10/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::fun::translate(sess, out, item.ident, &inputs[..], output, &**block);
}
ast::ItemMac(_) => {
diag.span_bug(item.span, "macros should be gone by now");
}
ast::ItemStruct(ref def, ref generics) => {
if generics.is_parameterized() {
... | code_fim | hard | {
"lang": "rust",
"repo": "loafofpiecrust/glassful",
"path": "/src/item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loafofpiecrust/glassful path: /src/item.rs
use std::fmt::Write;
use syntax::ast;
use syntax::abi;
use syntax::parse::ParseSess;
use syntax::attr::AttrMetaMethods;
use ::Program;
pub fn translate(sess: &ParseSess, out: &mut String, prog: &mut Program, stages: &[&str], item: &ast::Item) {
le... | code_fim | hard | {
"lang": "rust",
"repo": "loafofpiecrust/glassful",
"path": "/src/item.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = match *output {
ast::NoReturn(..) => {
diag.span_err(item.span, "function doesn't return");
return;
}
ast::DefaultReturn(..) => None,
ast::Return(ref t) => Some(&**t),
... | code_fim | hard | {
"lang": "rust",
"repo": "loafofpiecrust/glassful",
"path": "/src/item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_string(s1: &String) {
println!("{}", *s1);
}<|fim_prefix|>// repo: novito/rust-hello-world path: /src/heap_play_2.rs
fn main() {
let s1 = String::from("hello");
// Here we are NOT transfering ownership of s1 into print_string, so after the
// function call we should still refer ... | code_fim | medium | {
"lang": "rust",
"repo": "novito/rust-hello-world",
"path": "/src/heap_play_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: novito/rust-hello-world path: /src/heap_play_2.rs
fn main() {
let s1 = String::from("hello");
// Here we are NOT transfering ownership of s1 into print_string, so after the
// function call we should still refer to s1
// What we are doing here is passing a reference to s1, but t... | code_fim | medium | {
"lang": "rust",
"repo": "novito/rust-hello-world",
"path": "/src/heap_play_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Function {
pub fn new(func: Rc<DynFunc>) -> Self {
Function {
imp: FunctionImpl::new(func),
}
}
pub fn call(&self, env: &mut Env, vs: Vec<DefaultTypes>) -> Vec<DefaultTypes> {
self.imp.call(env, vs)
}
pub fn from_raw(data: Statements) -> Self {
... | code_fim | medium | {
"lang": "rust",
"repo": "Lucerna-Lang/Lucerna",
"path": "/Structures/src/structs/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lucerna-Lang/Lucerna path: /Structures/src/structs/functions.rs
use super::Statements;
use crate::structs::{DefaultTypes, Env, Statement};
use std::fmt::{Debug};
use std::rc::Rc;
use super::bridge::FunctionImpl;
use crate::structs::bridge::DynFunc;
<|fim_suffix|>impl Function {
pub fn new(f... | code_fim | medium | {
"lang": "rust",
"repo": "Lucerna-Lang/Lucerna",
"path": "/Structures/src/structs/functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn setup_physics(
mut params: ResMut<IntegrationParameters>,
mut rapier_config: ResMut<RapierConfiguration>,
) {
rapier_config.timestep_mode = TimestepMode::VariableTimestep;
params.dt = 3.0 / 60.0
}
fn enable_physics_profiling(mut pipeline: ResMut<PhysicsPipeline>) {
pipeline.co... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_gym",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slyedoc/bevy_slyedoc_gym path: /src/main.rs
mod config;
mod environment;
mod environments;
mod helpers;
mod models;
mod menu;
use bevy::prelude::*;
use bevy_egui::EguiPlugin;
use bevy_inspector_egui::WorldInspectorParams;
use bevy_prototype_debug_lines::{DebugLines, DebugLinesPlugin};
use bevy_... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_gym",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add environment
match config.environment {
Some(e) => {
load_environment(&mut app, e, !config.simulation, config.human);
app.add_state(AppState::Environment(e));
}
None => {
app.add_state(AppState::Menu);
},
}
app.add_... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_slyedoc_gym",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct WorkerResponder {}
impl<AGN> Responder<AGN> for WorkerResponder
where
AGN: Agent,
<AGN as Agent>::Input: Serialize + for<'de> Deserialize<'de>,
<AGN as Agent>::Output: Serialize + for<'de> Deserialize<'de>,
{
fn respond(&self, id: HandlerId, output: AGN::Output) {
let msg =... | code_fim | hard | {
"lang": "rust",
"repo": "intendednull/yew",
"path": "/packages/yew/src/agent/worker/public.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intendednull/yew path: /packages/yew/src/agent/worker/public.rs
use super::WorkerExt;
use super::*;
use crate::callback::Callback;
use crate::scheduler::Shared;
use anymap::{self, AnyMap};
use queue::Queue;
use slab::Slab;
use std::any::TypeId;
use std::cell::RefCell;
use std::fmt;
use std::mark... | code_fim | hard | {
"lang": "rust",
"repo": "intendednull/yew",
"path": "/packages/yew/src/agent/worker/public.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svartalf/rust-battery path: /battery/src/errors.rs
//! Errors handling
use std::borrow::Cow;
use std::error::Error as StdError;
use std::fmt;
use std::io;
use std::result;
pub type Result<T> = result::Result<T, Error>;
/// Battery routines error.
///
/// Since all operations are basically I/O... | code_fim | hard | {
"lang": "rust",
"repo": "svartalf/rust-battery",
"path": "/battery/src/errors.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::Error;
impl From<nix::Error> for Error {
fn from(e: nix::Error) -> Self {
match e {
nix::Error::Sys(errno) => Error {
source: io::Error::from_raw_os_error(errno as i32),
description: Some(errno.desc().into()),
... | code_fim | hard | {
"lang": "rust",
"repo": "svartalf/rust-battery",
"path": "/battery/src/errors.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Top-level machine
const DEFAULT_FREQUENCY: u64 = 600;
const PERIOD_60HZ: f32 = 1000.0 / 60.0;
pub struct Chip8<C: CPU, M: Memory> {
pub freq: u64,
cycles: f64,
counter_60hz: f32,
pub cpu: C,
pub ram: M,
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "fmdkdd/chipers",
"path": "/src/chip8/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fmdkdd/chipers path: /src/chip8/mod.rs
pub mod cpu;
pub mod memory;
pub mod screen;
pub mod keyboard;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Traits used as interfaces for plugging different components into the machine
pub trait CPU {
fn reset(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "fmdkdd/chipers",
"path": "/src/chip8/mod.rs",
"mode": "psm",
"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.