text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: hawkinsw/iwtrit path: /episode3/src/main.rs
use volatile::Volatile;
fn main() {
<|fim_suffix|> for _ in 0..1000000000 {
v.write(v.read() + 1);
}
}<|fim_middle|> let mut j = 0;
let mut v = Volatile::new(&mut j);
| code_fim | easy | {
"lang": "rust",
"repo": "hawkinsw/iwtrit",
"path": "/episode3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut j = 0;
let mut v = Volatile::new(&mut j);
for _ in 0..1000000000 {
v.write(v.read() + 1);
}
}<|fim_prefix|>// repo: hawkinsw/iwtrit path: /episode3/src/main.rs
use volatile::Volatile;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "hawkinsw/iwtrit",
"path": "/episode3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !map.contains_key(start) {
return orbits;
}
let mut sum = 0;
for v in &map[start] {
sum += count_orbit(v, map, orbits + 1);
}
sum + orbits
}
#[test]
fn test1() {
let s = "COM)B
B)C
C)D
D)E
E)F
B)G
G)H
D)I
E)J
J)K
K)L";
assert_eq!(part1(&generator(s))... | code_fim | hard | {
"lang": "rust",
"repo": "nambrosini/adventofcode",
"path": "/2019/src/day06.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nambrosini/adventofcode path: /2019/src/day06.rs
use itertools::Itertools;
use std::collections::{HashMap, HashSet};
#[aoc_generator(day06)]
pub fn generator(input: &str) -> HashMap<String, Vec<String>> {
let mut map: HashMap<String, Vec<String>> = HashMap::new();
for i in input.lines()... | code_fim | hard | {
"lang": "rust",
"repo": "nambrosini/adventofcode",
"path": "/2019/src/day06.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(ld_mem_hl_e().estimated_duration().unwrap(), 2);
assert_eq!(ld_e_mem_hl().estimated_duration().unwrap(), 2);
assert_eq!(ld_d_mem_hl().estimated_duration().unwrap(), 2);
assert_eq!(out_c_d().estimated_duration().unwrap(), 4);
}
#[test]
fn is_valid_... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/implementation/tokens.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-asm/src/implementation/tokens.rs
Some(DataAccess::IndexRegister8(_)) => 2,
Some(DataAccess::Expression(_)) => 2,
Some(DataAccess::MemoryRegister16(_)) => 2,
Some(DataAccess::I... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/implementation/tokens.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Dest in 16bits reg
Some(DataAccess::Register16(ref dst)) => {
match arg2 {
Some(DataAccess::Expression(_)) => 3,
Some(DataAccess::Memory(_)) if... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-asm/src/implementation/tokens.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
for idx in 0..(digits.len()) / 2 {
if digits[idx] != digits[digits.len() - 1 - idx] {
return false;
}
}
true
}
}
struct Solution;<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/palindrome_number.rs
//! 9. Palindr... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/rust-alg",
"path": "/src/leetcode/palindrome_number.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/palindrome_number.rs
//! 9. Palindrome Number
impl Solution {
// convert to string
pub fn is_palindrome(mut x: i32) -> bool {
if x < 0 {
return false;
}
let bytes = x.to_string().into_by<|fim_suffix|>
}
... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/rust-alg",
"path": "/src/leetcode/palindrome_number.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iferc/possible-rs path: /src/refs.rs
use super::Possible;
use core::pin::Pin;
impl<T> Possible<T> {
/// Converts from `&Possible<T>` to `Possible<&T>`.
///
/// # Examples
///
/// Converts an `Possible<`[`String`]`>` into an `Possible<`[`usize`]`>`, preserving the original.
... | code_fim | hard | {
"lang": "rust",
"repo": "iferc/possible-rs",
"path": "/src/refs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Converts from [`Pin`]`<&mut Possible<T>>` to `Possible<`[`Pin`]`<&mut T>>`.
#[inline]
pub fn as_pin_mut(self: Pin<&mut Self>) -> Possible<Pin<&mut T>> {
// SAFETY: `get_unchecked_mut` is never used to move the `Possible` inside `self`.
// `x` is guaranteed to be pinned beca... | code_fim | hard | {
"lang": "rust",
"repo": "iferc/possible-rs",
"path": "/src/refs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let logger = (&*Arc::from_raw(params.logger)).clone();
let dispatcher: Box<GuiDispatcher> = Box::from_raw(params.dispatcher);
let settings: Box<HashMap<Setting, String>> = Box::from_raw(params.settings);
match Gui::create(event, instance, dispatcher, logger,... | code_fim | hard | {
"lang": "rust",
"repo": "chrde/cloppy",
"path": "/src/gui/wnd_proc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrde/cloppy path: /src/gui/wnd_proc.rs
use actions::ComposedAction;
use actions::SimpleAction;
use dispatcher::GuiDispatcher;
use errors::failure_to_string;
use gui::accel_table::*;
use gui::event::Event;
use gui::FILE_LIST_ID;
use gui::get_string;
use gui::Gui;
use gui::GuiCreateParams;
use gu... | code_fim | hard | {
"lang": "rust",
"repo": "chrde/cloppy",
"path": "/src/gui/wnd_proc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn default_snippets_dir() -> PathBuf {
if let Some(dir) = var_os(NEKKO_SNIPPETS_HOME) {
return PathBuf::from(dir);
}
let mut dir = match var_os(XDG_CONFIG_HOME) {
Some(dir) => PathBuf::from(dir),
None => {
let mut dir = dirs::home_dir().unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "Ryooooooga/nekko",
"path": "/src/config/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryooooooga/nekko path: /src/config/mod.rs
pub mod placeholder;
pub mod snippet;
pub use placeholder::*;
pub use snippet::*;
use std::env::var_os;
use std::path::PathBuf;
static NEKKO_SNIPPETS_HOME: &str = "NEKKO_SNIPPETS_HOME";
static XDG_CONFIG_HOME: &str = "XDG_CONFIG_HOME";
<|fim_suffix|>... | code_fim | medium | {
"lang": "rust",
"repo": "Ryooooooga/nekko",
"path": "/src/config/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn selfdestruct(&mut self, address: &Address, refund_address: &Address) -> bool;
fn sha3(&self, input: &[u8]) -> H256;
// is_empty returns whether the given account is empty. Empty
// is defined according to EIP161 (balance = nonce = code = 0).
fn is_empty(&self, address: &Address) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "citahub/cita-vm",
"path": "/src/evm/ext.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: citahub/cita-vm path: /src/evm/ext.rs
use ethereum_types::{Address, H256, U256};
use crate::evm::err;
use crate::evm::interpreter;
use crate::evm::opcodes;
pub trait DataProvider {
fn get_balance(&self, address: &Address) -> U256;
fn add_refund(&mut self, address: &Address, n: u64);
... | code_fim | medium | {
"lang": "rust",
"repo": "citahub/cita-vm",
"path": "/src/evm/ext.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn selfdestruct(&mut self, address: &Address, refund_address: &Address) -> bool;
fn sha3(&self, input: &[u8]) -> H256;
// is_empty returns whether the given account is empty. Empty
// is defined according to EIP161 (balance = nonce = code = 0).
fn is_empty(&self, address: &Address) ->... | code_fim | hard | {
"lang": "rust",
"repo": "citahub/cita-vm",
"path": "/src/evm/ext.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: koba04/excercises-for-grokking-algorithms path: /src/search/binary_search.rs
#[allow(dead_code)]
pub fn search(target: i32, list: &[i32]) -> i32 {
let mut start = 0;
let mut end = list.len() - 1;
let mut index = 0;
while start <= end {
index = index + 1;
let midd... | code_fim | medium | {
"lang": "rust",
"repo": "koba04/excercises-for-grokking-algorithms",
"path": "/src/search/binary_search.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(search(1, &[1,2,3]), 0);
assert_eq!(search(2, &[1,2,3]), 1);
assert_eq!(search(3, &[1,2,3]), 2);
assert_eq!(search(4, &[1,2,3]), -1);
}<|fim_prefix|>// repo: koba04/excercises-for-grokking-algorithms path: /src/search/binary_search.rs
#[allow(dead_code)]
pub fn search(target: i... | code_fim | hard | {
"lang": "rust",
"repo": "koba04/excercises-for-grokking-algorithms",
"path": "/src/search/binary_search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: halfzebra/learning-rust path: /course-notes/video-033/src/main.rs
trait Printable
{
fn format(&self) -> String;
}
impl Printable for i32
{
fn format(&self) -> String
{
format!("i32: {}", *self)
}
}
impl Printable for String
{
fn format(&self) -> String
<|fim_suffix|... | code_fim | medium | {
"lang": "rust",
"repo": "halfzebra/learning-rust",
"path": "/course-notes/video-033/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_value(v: &Printable)
{
// the lookup of corresponding .format is happening at runtime.
println!("{}", v.format())
}
fn main() {
print_value(&"bye".to_string());
print_value(&32);
}<|fim_prefix|>// repo: halfzebra/learning-rust path: /course-notes/video-033/src/main.rs
trait Prin... | code_fim | hard | {
"lang": "rust",
"repo": "halfzebra/learning-rust",
"path": "/course-notes/video-033/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn drying() {
// When PET is greater than rainfall the effective rainfall is
// negative and drying occurs
let mut soil = SoilMoistureDeficitStore {
direct_percolation: 1.0,
potential_drying_constant: 70.0,
gradient_drying_curve: ... | code_fim | hard | {
"lang": "rust",
"repo": "snorfalorpagus/catchmod-rs",
"path": "/src/soil.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snorfalorpagus/catchmod-rs path: /src/soil.rs
pub struct SoilMoistureDeficitStore {
pub direct_percolation: f64,
pub potential_drying_constant: f64,
pub gradient_drying_curve: f64,
pub upper_deficit: f64,
pub lower_deficit: f64,
}
impl SoilMoistureDeficitStore {
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "snorfalorpagus/catchmod-rs",
"path": "/src/soil.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobinSc006/pi path: /src/gui.rs
use __core::fmt::Debug;
use imgui::*;
use std::time::Duration;
pub const MESSAGE_STATUS_GENERATING: &str = "Generating...";
pub const MESSAGE_STATUS_SEARCHING: &str = "Searching...";
pub const MESSAGE_STATUS_DONE: &str = "Ready";
pub const TEXT_QUERY_NOT_FOUND:... | code_fim | hard | {
"lang": "rust",
"repo": "RobinSc006/pi",
"path": "/src/gui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let window = Window::new(im_str!("Info"))
.size([200.0, 350.0], Condition::Always)
.position([0.0, 0.0], Condition::Always);
window.build(&ui, || {
ui.text(im_str!("Status: {}", state.status));
ui.text(im_str!(
"Digits: {}",
state.current_pi... | code_fim | hard | {
"lang": "rust",
"repo": "RobinSc006/pi",
"path": "/src/gui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut response = Response::new();
response.status = StatusCode::BAD_REQUEST;
response
}
fn format_response(response: Response) -> Vec<u8> {
let mut result;
let status_reason = match response.status.canonical_reason() {
Some(reason) => reason,
None => "",
};
... | code_fim | hard | {
"lang": "rust",
"repo": "levidyrek/blog-rust-http-server",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn format_response(response: Response) -> Vec<u8> {
let mut result;
let status_reason = match response.status.canonical_reason() {
Some(reason) => reason,
None => "",
};
result = format!(
"HTTP/1.0 {} {}\n",
response.status.as_str(),
status_reason,
... | code_fim | hard | {
"lang": "rust",
"repo": "levidyrek/blog-rust-http-server",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: levidyrek/blog-rust-http-server path: /src/lib.rs
use std::{io, fs};
use std::io::prelude::*;
use std::io::ErrorKind;
use std::net::TcpStream;
use bufstream::BufStream;
use chrono::prelude::*;
use http::StatusCode;
struct Request {
http_version: String,
method: String,
path: Strin... | code_fim | hard | {
"lang": "rust",
"repo": "levidyrek/blog-rust-http-server",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matrix-Zhang/qrcode-rust path: /src/render/image.rs
#![cfg(feature="image")]
use render::{Pixel, Canvas};
use types::Color;
use image::{Pixel as ImagePixel, Rgb, Rgba, Luma, LumaA, Primitive, ImageBuffer};
macro_rules! impl_pixel_for_image_pixel {
($p:ident<$s:ident>: $c:pat => $d:expr) =... | code_fim | hard | {
"lang": "rust",
"repo": "Matrix-Zhang/qrcode-rust",
"path": "/src/render/image.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(image.dimensions(), (12, 12));
assert_eq!(image.into_raw(), expected);
}
#[test]
fn test_render_resized_max() {
let image = Renderer::<Luma<u8>>::new(&[
Color::Dark, Color::Light,
Color::Light, Color::Dark,
], 2, 1).max_dimens... | code_fim | hard | {
"lang": "rust",
"repo": "Matrix-Zhang/qrcode-rust",
"path": "/src/render/image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let upper = 100;
let ceiling = 1_000_000;
let mut counter = 0;
let ceiling: BigUint = FromPrimitive::from_usize(ceiling).unwrap();
for n in 23..upper+1 {
for r in 1..n {
if combinatorics(n , r) > ceiling {
counter += 1;
}
}
}... | code_fim | easy | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_53/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: derrickbaldwin/euler-project path: /rust/problem_53/src/main.rs
extern crate problem_53;
extern crate num;
use problem_53::combinatorics;
use num::{BigUint, FromPrimitive};
<|fim_suffix|> let upper = 100;
let ceiling = 1_000_000;
let mut counter = 0;
let ceiling: BigUint = From... | code_fim | easy | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_53/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
pub struct User {
pub username: String,
pub name: String,
pub email: String,
}
pub enum UserFetchError<'a> {
DataJsonLoadingFailed(),
UserNotFound(&'a str),
}
#[derive(Deserialize)]
pub struct UserRelationshipShape {
pub followers: Vec<String>,
}<|fim_prefix|>// repo:... | code_fim | hard | {
"lang": "rust",
"repo": "axross/rust-example-api-server",
"path": "/src/repository/user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: axross/rust-example-api-server path: /src/repository/user.rs
use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
use serde::Deserialize;
pub fn get_all_users<'a>() -> Result<Vec<User>, UserFetchError<'a>> {
let json = include_str!("../../data/users.json");
match serde_js... | code_fim | hard | {
"lang": "rust",
"repo": "axross/rust-example-api-server",
"path": "/src/repository/user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `satisfy_unwrap!` makes it a little easier to implement a `satisfy_map`
/// body that matches a particular `Value` enum case, otherwise returning `None`.
#[macro_export]
macro_rules! satisfy_unwrap {
( $cas: path, $var: ident, $body: block ) => {
satisfy_map(|x: edn::Value| if let $cas($va... | code_fim | hard | {
"lang": "rust",
"repo": "shaunstanislaus/mentat",
"path": "/parser-utils/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaunstanislaus/mentat path: /parser-utils/src/lib.rs
// Copyright 2016 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICE... | code_fim | hard | {
"lang": "rust",
"repo": "shaunstanislaus/mentat",
"path": "/parser-utils/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut is_ready = true;
if !instr.is_reg() {
match instr.arg() {
Expr::Tup(tup) => {
for term in tup.term() {
is_ready = term_is_ready(env, term);
if !is_ready {
break;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ptorru/reticle",
"path": "/src/langs/ir/src/helpers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ptorru/reticle path: /src/langs/ir/src/helpers.rs
use crate::ast::*;
use crate::errors::Error;
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
impl Prim {
pub fn is_any(&self) -> bool {
matches!(self, Prim::Any)
... | code_fim | hard | {
"lang": "rust",
"repo": "ptorru/reticle",
"path": "/src/langs/ir/src/helpers.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn instr_is_ready(env: &HashSet<Id>, instr: &Instr) -> bool {
let mut is_ready = true;
if !instr.is_reg() {
match instr.arg() {
Expr::Tup(tup) => {
for term in tup.term() {
is_ready = term_is_ready(env, term);
if !is_ready... | code_fim | hard | {
"lang": "rust",
"repo": "ptorru/reticle",
"path": "/src/langs/ir/src/helpers.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const FRAME_BLOCK_SIZE: BlockSize = BlockSize::Max64KB;
pub fn stream<W: Write>(w: W) -> Encoder<W> {
let mut config = FrameInfo::new();
config.block_size = FRAME_BLOCK_SIZE;
config.block_mode = BlockMode::Linked;
config.block_checksums = false;
Encoder::with_frame_info(config, ... | code_fim | medium | {
"lang": "rust",
"repo": "rhdxmr/infinitree",
"path": "/infinitree/src/compress.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rhdxmr/infinitree path: /infinitree/src/compress.rs
use lz4_flex::frame::{BlockMode, BlockSize, FrameInfo};
pub use lz4_flex::{
block::{
compress_into, decompress, decompress_into, get_maximum_output_size, CompressError,
DecompressError,
},
frame::{FrameDecoder as Dec... | code_fim | medium | {
"lang": "rust",
"repo": "rhdxmr/infinitree",
"path": "/infinitree/src/compress.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn stream<W: Write>(w: W) -> Encoder<W> {
let mut config = FrameInfo::new();
config.block_size = FRAME_BLOCK_SIZE;
config.block_mode = BlockMode::Linked;
config.block_checksums = false;
Encoder::with_frame_info(config, w)
}
pub fn destream<R: Read>(r: R) -> Decoder<R> {
Deco... | code_fim | medium | {
"lang": "rust",
"repo": "rhdxmr/infinitree",
"path": "/infinitree/src/compress.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Walks up the file system, looking for a Cargo.toml file
/// If one is found before reaching the root, then the current_dir's package belongs to that parent workspace if it's listed on [workspace.members].
///
/// If this package is part of a workspace, returns the path to the workspace directory
/// O... | code_fim | hard | {
"lang": "rust",
"repo": "truexin1292/tauri",
"path": "/cli/core/src/build/rust.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: truexin1292/tauri path: /cli/core/src/build/rust.rs
use std::{fs::File, io::Read, path::PathBuf, process::Command, str::FromStr};
use serde::Deserialize;
use crate::helpers::{app_paths::tauri_dir, config::Config};
use tauri_bundler::{AppCategory, BundleBinary, BundleSettings, PackageSettings};... | code_fim | hard | {
"lang": "rust",
"repo": "truexin1292/tauri",
"path": "/cli/core/src/build/rust.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> temp_event: EventGroupMonster,
events_vec: &mut Vec<EventGroupMonster>,
) {
// шлем просителю сообщение что он стал членом стаи
if temp_event.event_type != EventTypeMonster::None {
events_vec.push(temp_event);
pr... | code_fim | hard | {
"lang": "rust",
"repo": "Gexon/dotakiller",
"path": "/src/ground/event_systems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gexon/dotakiller path: /src/ground/event_systems.rs
nsterEventSystem {
fn aspect(&self) -> Aspect {
aspect_all!(MonsterClass)
}
fn data_aspects(&self) -> Vec<Aspect> {
vec![aspect_all![ClassGround]]
}
fn process_all(&mut self, entities: &mut Vec<&mut Entity>... | code_fim | hard | {
"lang": "rust",
"repo": "Gexon/dotakiller",
"path": "/src/ground/event_systems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gexon/dotakiller path: /src/ground/event_systems.rs
entities);
// ВОЖДЬ покидает стаю
self.exec_lead_leave_group(events_vec, EventTypeMonster::LeadLeaveGroup, entities);
// Обновление координат ВОЖДЯ у членов
self.exec_update_lead_point(events_ve... | code_fim | hard | {
"lang": "rust",
"repo": "Gexon/dotakiller",
"path": "/src/ground/event_systems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut moves = 0;
let mut floor = 0;
let mut visited_basement = false;
for c in input.chars() {
match c {
'(' => floor += 1,
')' => floor -= 1,
_ => bail!("unexpected character '{}'", c),
}
if !visited_basement {
move... | code_fim | medium | {
"lang": "rust",
"repo": "letheed/aoc",
"path": "/rust/src/y2015/d01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: letheed/aoc path: /rust/src/y2015/d01.rs
use anyhow::bail;
use crate::{Date, Day, Puzzle, Result};
const DATE: Date = Date::new(Day::D01, super::YEAR);
pub(super) const PUZZLE: Puzzle = Puzzle::new(DATE, solve);
<|fim_suffix|> let mut moves = 0;
let mut floor = 0;
let mut visited_b... | code_fim | medium | {
"lang": "rust",
"repo": "letheed/aoc",
"path": "/rust/src/y2015/d01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vini84200/luminance-hello-world path: /src/main.rs
use luminance_front::shader::Uniform;
use glfw::{Action, Context as _, Key, WindowEvent};
use luminance_front::context::GraphicsContext;
use luminance::pipeline::PipelineState;
use luminance_glfw::GlfwSurface;
use luminance_windowing::{WindowDim... | code_fim | hard | {
"lang": "rust",
"repo": "vini84200/luminance-hello-world",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> vertex_cache.insert(*key, vertex_index);
vertices.push(vertex);
indices.push(vertex_index);
}
}
} else {
return Err("unsupported non-triangle shape".to_owned());
}
}
Ok(Obj { vertices, indices })
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "vini84200/luminance-hello-world",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
P: AsRef<Path>,
{
let file_content = {
let mut file = File::open(path).map_err(|e| format!("cannot open file: {}", e))?;
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
content
};
let obj_set = obj::parse(fi... | code_fim | hard | {
"lang": "rust",
"repo": "vini84200/luminance-hello-world",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zer0x64/pbkdf2-identifier path: /pbkdf2-identifier/src/wasm.rs
use wasm_bindgen::prelude::*;
use crate::hash_primitive::HashPrimitive;
<|fim_suffix|>#[wasm_bindgen]
pub fn identify_iterations(
password: &[u8],
hash: &[u8],
salt: &[u8],
primitive: HashPrimitive,
max: Option<... | code_fim | hard | {
"lang": "rust",
"repo": "zer0x64/pbkdf2-identifier",
"path": "/pbkdf2-identifier/src/wasm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
pub struct Pbkdf2Parameters {
pub primitive: HashPrimitive,
pub iterations: usize,
}
#[wasm_bindgen]
pub fn primitive_name(p: HashPrimitive) -> String {
String::from(p.name())
}
#[wasm_bindgen]
pub fn identify_iterations(
password: &[u8],
hash: &[u8],
salt: &[u8],... | code_fim | medium | {
"lang": "rust",
"repo": "zer0x64/pbkdf2-identifier",
"path": "/pbkdf2-identifier/src/wasm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbeckeriv/rust-aha-fs path: /src/main.rs
extern crate dirs;
extern crate dotenv;
extern crate envy;
extern crate termion;
#[macro_use]
extern crate failure;
extern crate env_logger;
extern crate log;
extern crate reqwest;
#[macro_use]
extern crate serde;
extern crate serde_json;
#[macro_use]
ext... | code_fim | hard | {
"lang": "rust",
"repo": "sbeckeriv/rust-aha-fs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if valid_connector(&path) {
let uri = path_to_uri(&path)?;
println!("AFS lookup: {} -> {}", path.display(), uri);
/*
match self.client.data(&uri).into_type() {
Ok(data_item) => Ok(build_dir_entry(&data_item).metadata),
... | code_fim | hard | {
"lang": "rust",
"repo": "sbeckeriv/rust-aha-fs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Transform to an iterator of frame start addresses:
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
// Create `PhysFrame` types from the start addresses:
frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
}
}
unsafe impl ... | code_fim | hard | {
"lang": "rust",
"repo": "jo12bar/rust_os",
"path": "/src/memory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Map each region to its address range:
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
// Transform to an iterator of frame start addresses:
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
// Create `PhysFrame... | code_fim | hard | {
"lang": "rust",
"repo": "jo12bar/rust_os",
"path": "/src/memory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jo12bar/rust_os path: /src/memory.rs
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
use x86_64::{
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
PhysAddr, VirtAddr,
};
/// Initialize a new `OffsetPageTable`.
//,/
/// # Safety
/// This fu... | code_fim | hard | {
"lang": "rust",
"repo": "jo12bar/rust_os",
"path": "/src/memory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
address: ap.address,
ty: ap.path[0],
hash: ap.path[1..=HashValue::LENGTH].to_vec(),
suffix: String::from_utf8_lossy(&ap.path[1 + HashValue::LENGTH..]).to_string(),
}
}
}
#[derive(Debug, Serialize)]
#[serde(tag = "type", content = ... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/starcoin",
"path": "/cmd/starcoin/src/view.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/starcoin path: /cmd/starcoin/src/view.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use anyhow::{format_err, Error};
use forkable_jellyfish_merkle::proof::SparseMerkleProof;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Serialize, Se... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/starcoin",
"path": "/cmd/starcoin/src/view.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize)]
pub struct MoveExplainView {
pub category_code: u64,
pub category_name: Option<String>,
pub reason_code: u64,
pub reason_name: Option<String>,
}
pub fn serialize_bytes_to_hex<S>(bytes: &[u8], s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
s.ser... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/starcoin",
"path": "/cmd/starcoin/src/view.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CDL-Project-Euler/solutions path: /000-025/p001/komron.rs
fn main() {
let top = 1000;
let mut total = 0;
let multiples: [i32; 2] = [3, 5];
for i in 0..top {
if (i % multiples[0] == 0) && !(i % multiples[1] == 0) {
total += i;
} else<|fim_suffix|>e... | code_fim | medium | {
"lang": "rust",
"repo": "CDL-Project-Euler/solutions",
"path": "/000-025/p001/komron.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (i % multiples[1] == 0) && !(i % multiples[0] == 0) {
total += i;
} else if (i % multiples[0] == 0) && (i % multiples[1] == 0) {
total += i;
};
};
println!("{}", total);
}<|fim_prefix|>// repo: CDL-Project-Euler/solutions path: /000-025/p001/komron.rs
... | code_fim | medium | {
"lang": "rust",
"repo": "CDL-Project-Euler/solutions",
"path": "/000-025/p001/komron.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub struct Format {
pub audio: String,
pub captions: String,
pub container: Option<String>,
pub drm: String,
pub video: String,
pub video_res: Option<String>,
}
#[derive(Debug, Deserialize)]
pub struct Buffering {
pub current: String,
pub max:... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/roku-ecp-rs",
"path": "/src/api/query/media_player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
pub struct NewStream {
pub speed: String,
}
#[derive(Debug, Deserialize)]
pub struct StreamSegment {
pub bitrate: u32,
pub media_sequence: u32,
pub segment_type: String,
pub time: u32,
}<|fim_prefix|>// repo: Hermitter/roku-ecp-rs path: /src/api/query/me... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/roku-ecp-rs",
"path": "/src/api/query/media_player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hermitter/roku-ecp-rs path: /src/api/query/media_player.rs
use super::{from_str, Deserialize, Device, Error};
impl Device {
/// Information on the current media player state. This includes the current stream segment and position of the content being played, the running time of the content, ... | code_fim | hard | {
"lang": "rust",
"repo": "Hermitter/roku-ecp-rs",
"path": "/src/api/query/media_player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: getsentry/sentry-rust path: /sentry/examples/panic-demo.rs
fn main() {
let _sentry = sentry::init(sentry::ClientOptions {
release: sentry::release_name!(),
debug: true,
..Default::default()
});
{
let _guard <|fim_suffix|>pe.set_tag("foo", "bar");
... | code_fim | medium | {
"lang": "rust",
"repo": "getsentry/sentry-rust",
"path": "/sentry/examples/panic-demo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pe.set_tag("foo", "bar");
});
panic!("Holy shit everything is on fire!");
}
}<|fim_prefix|>// repo: getsentry/sentry-rust path: /sentry/examples/panic-demo.rs
fn main() {
let _sentry = sentry::init(sentry::ClientOptions {
release: sentry::rele<|fim_middle|>ase_name!(),
... | code_fim | medium | {
"lang": "rust",
"repo": "getsentry/sentry-rust",
"path": "/sentry/examples/panic-demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ul/sound-garden-0x2 path: /sound_garden_vst/src/lib.rs
#[macro_use]
extern crate vst;
use alloc_counter::no_alloc;
use audio_program::{compile_program, Context, PARAMETERS};
use audio_server::Message;
use audio_vm::{AtomicFrame, AtomicSample, Program, Sample, CHANNELS, VM};
use crossbeam_channe... | code_fim | hard | {
"lang": "rust",
"repo": "ul/sound-garden-0x2",
"path": "/sound_garden_vst/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(msg) = self.server.receiver().try_recv() {
if let ServerOutput::Program(program) = msg {
let garbage = self.vm.load_program(program);
self.server
.sender()
.send(ServerInput::Garbage(garbage))
... | code_fim | hard | {
"lang": "rust",
"repo": "ul/sound-garden-0x2",
"path": "/sound_garden_vst/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bvssvni/last_order_logic path: /src/runtime.rs
//! Runtime.
use crate::*;
use std::sync::Arc;
/// Reduces expression using definitions.
pub fn reduce(expr: &Expr, defs: &[(Arc<String>, Expr)]) -> Expr {
let mut expr = expr.clone();
loop {
let mut found = false;
for (nam... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/last_order_logic",
"path": "/src/runtime.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = String::new();
let mut file = match File::open(&*file_name) {
Ok(x) => x,
Err(err) => {
eprintln!("Could not open `{}`, {}", file_name, err);
... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/last_order_logic",
"path": "/src/runtime.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MattWindsor91/baps3-cli-rs path: /src/lib.rs
//! Support library for BAPS3 command-line interfaces.
#![feature(unboxed_closures)]
extern crate baps3_protocol;
extern crate docopt;
#[macro_use] extern crate docopt_macros;
use std::borrow::ToOwned;
use std::error::{ Error, FromError };
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "MattWindsor91/baps3-cli-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // It doesn't matter if the client has already quit.
let _ = request_tx.send(Request::Quit);
Ok(())
}
pub struct Baps3<L: Fn(&str)> {
client: Client,
logger: L,
features: Vec<String>
}
impl<L: Fn(&str)> Baps3<L> {
/// Constructs a new Baps3.
pub fn new<T>(logger: L... | code_fim | hard | {
"lang": "rust",
"repo": "MattWindsor91/baps3-cli-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'l: loop {
match response_rx.recv() {
Ok(Response::Message(msg)) => match msg.as_str_vec().as_slice() {
["FEATURES", have..] => {
log!(log, "Server features: {:?}", have);
if missing_features(needed, have) {
... | code_fim | hard | {
"lang": "rust",
"repo": "MattWindsor91/baps3-cli-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use crate::LbrynetApi;
use serde_json::Value;
use serde_json::json;
#[test]
fn it_works() {
let mut lbry = LbrynetApi::new();
let result0: Value = lbry.call("status", json!({}));
let result1: Value = lbry.call("resolve", json!({"uri":"lb... | code_fim | hard | {
"lang": "rust",
"repo": "zxawry/lbry-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use jsonrpc_client_http::HttpHandle;
use jsonrpc_client_http::HttpTransport;
const LBRYNET_SERVER_ADDRESS: &str = "http://localhost:5279";
pub struct LbrynetApi {
transport_handle: HttpHandle,
}
impl LbrynetApi {
pub fn new() -> Self {
let transport = HttpTransport::new().standalone().unwrap();... | code_fim | medium | {
"lang": "rust",
"repo": "zxawry/lbry-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zxawry/lbry-rs path: /src/lib.rs
extern crate serde_json;
extern crate jsonrpc_client_core;
extern crate jsonrpc_client_http;
pub use serde_json::{Value, Map, Number};
pub use serde_json::json;
use jsonrpc_client_core::call_method;
use jsonrpc_client_http::HttpHandle;
use jsonrpc_client_http:... | code_fim | hard | {
"lang": "rust",
"repo": "zxawry/lbry-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Thumbnailer/thumbnailer_cli path: /src/commands/brighten.rs
use thumbnailer::GenericThumbnail;
use crate::commands::Command;
/// Representation of the brighten-command as a struct
pub struct CmdBrighten {
/// Contains the `index` as u32 of arguments list
index: u32,
/// Contains th... | code_fim | hard | {
"lang": "rust",
"repo": "Thumbnailer/thumbnailer_cli",
"path": "/src/commands/brighten.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eirikhl/projects path: /rust/math/src/main.rs
use read_input::prelude::*;
fn main() {
let x: f64 = input().msg("Please enter a number \n").get();
println!("Your first number is {}", x);
<|fim_suffix|> println!("Your second number is {}", y);
let op: char = input().msg("Please e... | code_fim | medium | {
"lang": "rust",
"repo": "eirikhl/projects",
"path": "/rust/math/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Your second number is {}", y);
let op: char = input().msg("Please enter an operation \n").get();
match op {
'+' => println!("The result is: {}", x+y),
'-' => println!("The result is: {}", x-y),
'*' => println!("The result is: {}", x*y),
'/' => println... | code_fim | medium | {
"lang": "rust",
"repo": "eirikhl/projects",
"path": "/rust/math/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/resourceconnector/src/package_2021_10_31_preview/models.rs
rage/storageAccounts\""]
#[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
impl Resource {
pub fn new() -> Self {
Se... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/services/mgmt/resourceconnector/src/package_2021_10_31_preview/models.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Commit, squeeze 81 trytes and compare to the codeword.
pub fn unwrap_mac(s: &mut Spongos, b: &mut TritConstSlice) -> Result<()> {
let n = sizeof_mac();
guard(n <= b.size(), Err::Eof)?;
s.commit();
let mut t = trits::Trits::zero(n);
s.squeeze(t.mut_slice());
guard(b.advance(n) =... | code_fim | medium | {
"lang": "rust",
"repo": "zesterer/iota_mam",
"path": "/pb3/cmd/mac.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zesterer/iota_mam path: /pb3/cmd/mac.rs
//! Composite `MAC` operation essentially implements the following PB3 message:
//!
//! ```pb3
//! message MAC {
//! commit;
//! squeeze tryte tag[81];
//! }
//! ```
//!
//! # Fields
//!
//! * `tag` -- 81 trytes of authentication tag.
<|fim_suffix... | code_fim | medium | {
"lang": "rust",
"repo": "zesterer/iota_mam",
"path": "/pb3/cmd/mac.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_passes/rvalue_promotion.rs
ure_base_def_id(def_id);
if outer_def_id != def_id {
return tcx.rvalue_promotable_map(outer_def_id);
}
let mut visitor = CheckCrateVisitor {
tcx,
tables: &ty::TypeckTables::empty(N... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_passes/rvalue_promotion.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn borrow(&mut self,
borrow_id: hir::HirId,
_borrow_span: Span,
cmt: &mc::cmt_<'tcx>,
_loan_region: ty::Region<'tcx>,
bk: ty::BorrowKind,
loan_cause: euv::LoanCause) {
debug!(
"borrow(borrow_id={:?}... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_passes/rvalue_promotion.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_passes/rvalue_promotion.rs
y_owner_kind(item_id) {
hir::BodyOwnerKind::Closure |
hir::BodyOwnerKind::Fn => self.in_fn = true,
hir::BodyOwnerKind::Static(_) => self.in_static = true,
_ => {}
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_passes/rvalue_promotion.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/chain-wallet-libs path: /wallet/src/scheme/mod.rs
use chain_impl_mockchain::{
fragment::Fragment,
transaction::{Input, Output, Witness},
};
pub(crate) fn on_tx_output<FO>(fragment: &Fragment, on_output: FO)
where
FO: FnMut((usize, Output<chain_addr::Address>)),
{
... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-wallet-libs",
"path": "/wallet/src/scheme/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tx: &chain_impl_mockchain::transaction::Transaction<Extra>,
on_output: F,
) where
F: FnMut((usize, Output<chain_addr::Address>)),
{
tx.as_slice()
.outputs()
.iter()
.enumerate()
.for_each(on_output)
}
pub(crate) fn on_tx_input_and_witnesses<FI>(fragment: &F... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-wallet-libs",
"path": "/wallet/src/scheme/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Logicalshift/nuc-build-led path: /src/rainbow.rs
use futures::*;
use futures::stream;
use serde_json::Value;
use tokio::timer::Delay;
use std::io::{Error, ErrorKind};
use std::time::{Duration, Instant};
/// Time between each colour
const DELAY_MILLIS: u64 = 150;
/// Time to display the final ... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/nuc-build-led",
"path": "/src/rainbow.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Finally, display the last colour a bit longer before disabling the colours entirely
let start_time = Instant::now();
let final_time = (num_colors as u64) * DELAY_MILLIS + FINAL_DELAY;
let final_time = start_time + Duration::from_millis(final_time);
let final_delay ... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/nuc-build-led",
"path": "/src/rainbow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CoderCharmander/pokemon-engine path: /src/events.rs
use crate::party::RelativePartyId;
pub enum Event {
Damaged {
party_id: u8,
damage_amount: u32,
},
<|fim_suffix|> damage_amount: u32,
},
Effected {
rel_party_id: RelativePartyId,
descriptio... | code_fim | hard | {
"lang": "rust",
"repo": "CoderCharmander/pokemon-engine",
"path": "/src/events.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> damage_amount: u32,
},
Effected {
rel_party_id: RelativePartyId,
description: String,
},
}<|fim_prefix|>// repo: CoderCharmander/pokemon-engine path: /src/events.rs
use crate::party::RelativePartyId;
pub enum Event {
Damaged {
party_id: u8,
damage_a... | code_fim | medium | {
"lang": "rust",
"repo": "CoderCharmander/pokemon-engine",
"path": "/src/events.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexcarol/exercism-rust path: /gigasecond/src/lib.rs
extern crate chrono;
use chrono::*;
<|fim_suffix|> d.checked_add(duration).unwrap()
}<|fim_middle|>pub fn after(d: DateTime<UTC>) -> DateTime<UTC> {
let duration = UTC.ymd(2043, 1, 1).and_hms(1,46,40) - UTC.ymd(2011, 4, 25).and_hms(0,0... | code_fim | medium | {
"lang": "rust",
"repo": "alexcarol/exercism-rust",
"path": "/gigasecond/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> d.checked_add(duration).unwrap()
}<|fim_prefix|>// repo: alexcarol/exercism-rust path: /gigasecond/src/lib.rs
extern crate chrono;
use chrono::*;
<|fim_middle|>pub fn after(d: DateTime<UTC>) -> DateTime<UTC> {
let duration = UTC.ymd(2043, 1, 1).and_hms(1,46,40) - UTC.ymd(2011, 4, 25).and_hms(0,0... | code_fim | medium | {
"lang": "rust",
"repo": "alexcarol/exercism-rust",
"path": "/gigasecond/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cc::Build::new()
.no_default_flags(true)
.cpp(false)
.include("src/osxfuse/common") // for fuse_param.h etc
.include("src/osxfuse/example")
.include("src/osxfuse/include")
.include("src/osxfuse/lib")
.define("FUSE_USE_VERSION", "26") // fuse vers... | code_fim | hard | {
"lang": "rust",
"repo": "pwang7/ffi_osxfuse",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwang7/ffi_osxfuse path: /build.rs
// cc
// -Iexample/50d858e@@hello_ll@exe
// -Iexample
// -I../example
// -Iinclude
// -I../include
// -Ilib
// -I../lib
// -I.
// -I../
// -Wall
// -Wextra
// -Winvalid-pch
// -Wmissing-declarations
// -Wno-sign-compare
// -Wno-unused-result
// ... | code_fim | hard | {
"lang": "rust",
"repo": "pwang7/ffi_osxfuse",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flip1995/dirty-bench path: /benches/lint_test2.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use benches::*;
fn index_bench(c: &mut Criterion) {
c.bench_function("lint_test2_index", |b| {
b.iter(|| {
index2::foo(
black_box(&m... | code_fim | hard | {
"lang": "rust",
"repo": "flip1995/dirty-bench",
"path": "/benches/lint_test2.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.