text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mark-jordanovic-lewis/learning_rust path: /12_navigation.rs
use std::env;
use std::path::PathBuf;
use std::os::unix::fs::PermissionsExt;
use std::fs;
use std::io;
fn main() {
// having a look to see if our cargo dir is in the std place:
let home = env::home_dir().expect("There's no home... | code_fim | hard | {
"lang": "rust",
"repo": "mark-jordanovic-lewis/learning_rust",
"path": "/12_navigation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>!("permissions: {:o}", data.permissions().mode());
println!("touched: {:?}", data.modified());
},
Err(e) => println!("Error: {:?}", e)
}
break;
} else {
path.pop(); // popping the file name off the path
... | code_fim | hard | {
"lang": "rust",
"repo": "mark-jordanovic-lewis/learning_rust",
"path": "/12_navigation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get either top, global firsts, or recent scores of a user,
/// i.e. a vec of [`Score`](crate::model::score::Score).
///
/// If no score type is specified by either
/// [`best`](crate::request::GetUserScores::best),
/// [`firsts`](crate::request::GetUserScores::firsts),
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "iptq/rosu-v2",
"path": "/src/client/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the vec of [`Spotlight`](crate::model::ranking::Spotlight).
#[inline]
pub fn spotlights(&self) -> GetSpotlights {
GetSpotlights::new(self)
}
/// Get a [`User`](crate::model::user::User).
///
/// The following options will be filled if the user specified them:
... | code_fim | hard | {
"lang": "rust",
"repo": "iptq/rosu-v2",
"path": "/src/client/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iptq/rosu-v2 path: /src/client/mod.rs
ets from Sotarks that have a map with no more than AR 9.
/// let query = "creator=sotarks ar<9";
///
/// // Loved mapsets from Camellia including at least one map above 8 stars
/// let query = "status=loved artist=camellia stars>8";
/// `... | code_fim | hard | {
"lang": "rust",
"repo": "iptq/rosu-v2",
"path": "/src/client/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: florian1345/optolith-rs path: /src/data/personality_trait.rs
use crate::data::{TranslationsTranslatable, Translations};
use crate::data::effects_localization::EffectsLocalization;
use crate::data::prerequisite::PersonalityTraitListPrerequisite;
use crate::data::src::SourceRefs;
use crate::id::{C... | code_fim | hard | {
"lang": "rust",
"repo": "florian1345/optolith-rs",
"path": "/src/data/personality_trait.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The lower-level personality trait(s) this trait can be combined with.
#[serde(rename = "canBeCombinedWith")]
pub can_be_combined_with: Option<Vec<u32>>,
pub src: SourceRefs,
pub translations: Translations<EffectsLocalization>
}
impl Identifiable for PersonalityTrait {
fn id(&s... | code_fim | hard | {
"lang": "rust",
"repo": "florian1345/optolith-rs",
"path": "/src/data/personality_trait.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Identifiable for PersonalityTrait {
fn id(&self) -> Id {
Id::new(Category::PersonalityTraits, self.id)
}
}
impl TranslationsTranslatable for PersonalityTrait {
type Localization = EffectsLocalization;
fn translations(&self) -> &Translations<EffectsLocalization> {
&se... | code_fim | hard | {
"lang": "rust",
"repo": "florian1345/optolith-rs",
"path": "/src/data/personality_trait.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kstep/event-travel-planner path: /src/frontend/routes.rs
use anyhow::Error;
use serde::de::DeserializeOwned;
use yew::format::{Json, Nothing};
use yew::services::fetch::{FetchTask, Request, Response};
use yew::services::FetchService;
use yew::{html, Component, ComponentLink, Html, Properties, Sh... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/event-travel-planner",
"path": "/src/frontend/routes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn view(&self) -> Html {
html! {
<div class="container">
<h1>{ <T as Table>::title() }</h1>
<table class="table">
<thead>
{ <T as Table>::render_header() }
</thead>
<... | code_fim | hard | {
"lang": "rust",
"repo": "kstep/event-travel-planner",
"path": "/src/frontend/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mich101mich/game_rs path: /src/backend/mod.rs
#[cfg(target_arch = "wasm32")]
mod web_backend;
#[cfg(target_arch = "wasm32")]
pub use web_backend::{Backend, Color};
#[cfg(not(target_arch = "wasm32"))]
mod window_backend;
#[cfg(not(target_arch = "wasm32"))]
pub use window_backend::{Backend, Color... | code_fim | hard | {
"lang": "rust",
"repo": "mich101mich/game_rs",
"path": "/src/backend/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Draws `text` at `pos`
fn draw_text<T: Into<GamePos>>(&mut self, text: &str, pos: T, color: Colors);
/// Draws a segment of an image from `tile` at `target_pos`
fn draw_asset<T: Into<GamePos>>(&mut self, tile: (usize, usize), target_pos: T);
/// Draw the cached background
fn draw_background(&mu... | code_fim | hard | {
"lang": "rust",
"repo": "mich101mich/game_rs",
"path": "/src/backend/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn file_grep(
name: &str,
contents: &str,
pattern: &GrepPattern,
flags: &Flags,
many_files: bool,
) -> Vec<String> {
let mut candidate = contents
.lines()
.enumerate()
.map(|(i, line)| GrepLine::new(line, name, i))
.filter(|line| line.include(pattern... | code_fim | hard | {
"lang": "rust",
"repo": "k-hamada/exercism",
"path": "/rust/grep/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k-hamada/exercism path: /rust/grep/src/lib.rs
use failure::Error;
use std::fs;
pub struct Flags {
n: bool,
i: bool,
l: bool,
x: bool,
v: bool,
}
impl Flags {
pub fn new(flags: &[&str]) -> Self {
Flags {
n: flags.contains(&"-n"),
i: flags.... | code_fim | hard | {
"lang": "rust",
"repo": "k-hamada/exercism",
"path": "/rust/grep/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 60ke/wasm_contract_tools path: /contract/json/src/lib.rs
#![no_std]
#![allow(non_snake_case)]
#![feature(proc_macro_hygiene)]
use wasm_std::types::{U256, Address};
use wasm_mid;
use lazy_static;
use wasm2ct::types::*;
use wasm2ct_derive::gen_contract;
use wasm_std::{String};
use wasm2ct::types... | code_fim | hard | {
"lang": "rust",
"repo": "60ke/wasm_contract_tools",
"path": "/contract/json/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
// fn convert_num(a:u32)->Vec<u8>{
// let mut sink = Sink::new(1);
// sink.push(a);
// sink.finalize_panicking()
// }
fn h256_add(a:&H256,b:U256)->H256{
H256::from(U256::from(a) + b)
}
fn storage_read(key: &H256)->String{
// 读取数据长度
let list = wasm_mid::read(&h256_add(key, U... | code_fim | hard | {
"lang": "rust",
"repo": "60ke/wasm_contract_tools",
"path": "/contract/json/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: esbraff/moonlight-lang path: /src/lexer.rs
use std::vec::Vec;
use tokens::Token;
use tokens::TokenType;
pub struct Lexer<'a> {
pub input: &'a str,
lenght: usize,
pub output: Vec<Token>,
position: usize
}
impl<'a> Lexer<'a> {
pub fn new(input: &'a str) -> Lexer<'a> {
... | code_fim | hard | {
"lang": "rust",
"repo": "esbraff/moonlight-lang",
"path": "/src/lexer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while self.position < self.lenght {
let curr_ch = self.peek(0);
if curr_ch == '\"' {
self.next();
self.tokenize_string();
} else if curr_ch == '<' {
self.tokenize_setter();
} else if curr_ch == '>' {
... | code_fim | hard | {
"lang": "rust",
"repo": "esbraff/moonlight-lang",
"path": "/src/lexer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: najamelan/async_executors path: /examples/tokio_tp.rs
use
{
futures::task :: { Spawn, SpawnExt } ,
async_executors :: { TokioTp } ,
futures::channel :: { oneshot, oneshot::Sender } ,
};
fn lib_function( exec: impl Spawn, tx: Sender<&'static str> )
{
exec.spawn... | code_fim | hard | {
"lang": "rust",
"repo": "najamelan/async_executors",
"path": "/examples/tokio_tp.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = async
{
let (tx, rx) = oneshot::channel();
lib_function( &exec, tx );
println!( "{}", rx.await.expect( "receive on channel" ) );
};
exec.block_on( program );
}<|fim_prefix|>// repo: najamelan/async_executors path: /examples/tokio_tp.rs
use
{
futures::task :: { Spawn, SpawnEx... | code_fim | hard | {
"lang": "rust",
"repo": "najamelan/async_executors",
"path": "/examples/tokio_tp.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the position of the right side of the rectangle.
pub fn right(&self) -> Scalar {
self.pos.x + self.size.w
}
/// Computes a scaled rectangle with the same position as self.
pub fn scaled<T: Into<Size>>(self, v: T) -> Rect {
let v: Size = v.into();
Re... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/shapes",
"path": "/src/rect.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PistonDevelopers/shapes path: /src/rect.rs
use std::convert::From;
use graphics::math::{ self, Scalar };
use { Point, Size };
/// A rectangle.
#[derive(Clone, Copy, Debug)]
pub struct Rect {
/// The position of the top left corner of the rectangle.
pub pos: Point,
/// The width and... | code_fim | hard | {
"lang": "rust",
"repo": "PistonDevelopers/shapes",
"path": "/src/rect.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger = logger.level(level.into());
logger = match output {
Output::Stdout => logger.chain(std::io::stdout()),
Output::Stderr => logger.chain(std::io::stderr()),
Output::File(file) => logger.chain(log_file(file)?),
};
logger.apply()?;
Ok(())
}<|fim_prefix|>// ... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cms",
"path": "/crates/brace-cms-logger/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brace-rs/brace-cms path: /crates/brace-cms-logger/src/lib.rs
use chrono::Local;
use fern::colors::ColoredLevelConfig;
use fern::{log_file, Dispatch, InitError};
use brace_cms_core::config::Config;
use self::level::Level;
use self::output::Output;
pub mod level;
pub mod output;
pub fn init(co... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cms",
"path": "/crates/brace-cms-logger/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger = match output {
Output::File(_) => logger.format(move |out, message, record| {
out.finish(format_args!(
"[{} {} {}] {}",
Local::now().format("%Y-%m-%dT%H:%M:%SZ"),
record.level(),
record.target(),
... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cms",
"path": "/crates/brace-cms-logger/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dvlden/rustlings path: /exercises/standard_library_types/box1.rs
#[derive(PartialEq, Debug)]
pub enum List {
Cons(i32, Box<List>),
Nil,
}
fn main() {
<|fim_suffix|> assert_eq!(List::Nil, create_empty_list())
}
#[test]
fn test_create_non_empty_list() {
assert_... | code_fim | hard | {
"lang": "rust",
"repo": "dvlden/rustlings",
"path": "/exercises/standard_library_types/box1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_create_non_empty_list() {
assert_ne!(create_empty_list(), create_non_empty_list())
}
}<|fim_prefix|>// repo: dvlden/rustlings path: /exercises/standard_library_types/box1.rs
#[derive(PartialEq, Debug)]
pub enum List {
Cons(i32, Box<List>),
Nil,
}
<|fim_middle|... | code_fim | hard | {
"lang": "rust",
"repo": "dvlden/rustlings",
"path": "/exercises/standard_library_types/box1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("This is an empty cons list: {:?}", create_empty_list());
println!("This is a non-empty cons list: {:?}", create_non_empty_list());
}
pub fn create_empty_list() -> List {
List::Nil
}
pub fn create_non_empty_list() -> List {
List::Cons(1, Box::new(
List::Cons(2, Box::new(... | code_fim | medium | {
"lang": "rust",
"repo": "dvlden/rustlings",
"path": "/exercises/standard_library_types/box1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dopitz/vulkanism path: /nobs-imgui/src/shell/command/args/file.rs
use crate::shell::command::args::Arg;
use crate::shell::command::args::ArgDesc;
/// Special Argument specifying the command name at `index == 0`
#[derive(Clone, Debug)]
pub struct File {
desc: ArgDesc,
ext: Option<String>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-imgui/src/shell/command/args/file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::path::Path;
let filename_prefix = "".to_string();
let (dirname, filename_prefix) = match prefix.chars().last() {
Some('/') | Some('\\') => (Path::new(prefix), filename_prefix),
_ => {
let p = Path::new(prefix);
let filename_prefix = match p.file_name().and... | code_fim | hard | {
"lang": "rust",
"repo": "dopitz/vulkanism",
"path": "/nobs-imgui/src/shell/command/args/file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assertify!(1 + 2 != 3);
}
#[test]
#[should_panic(
expected = "failed: 1 + 2 > 4\n actual: 3\n expected: > 4\n"
)]
fn fail_simple_gt() {
assertify!(1 + 2 > 4);
}
fn result(good: bool) -> Result<(), &'static str> {
if good {
Ok(())
} else {
Err("bad")
}
}
#[t... | code_fim | hard | {
"lang": "rust",
"repo": "danielparks/assertify",
"path": "/tests/assertify.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assertify!(1 + 2 > 4);
}
fn result(good: bool) -> Result<(), &'static str> {
if good {
Ok(())
} else {
Err("bad")
}
}
#[test]
#[should_panic(
expected = "failed: result(false) == Ok(())\n actual: Err(\"bad\")\n expected: == Ok(())\n"
)]
fn fail_result_ok() {
... | code_fim | hard | {
"lang": "rust",
"repo": "danielparks/assertify",
"path": "/tests/assertify.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielparks/assertify path: /tests/assertify.rs
#![allow(deprecated)]
use assertify::assertify;
#[test]
fn assertify_simple_expr() {
assertify!(1 - 2 == -1);
}
#[test]
#[should_panic(
expected = "failed: 1 + 2 == 0\n actual: 3\n expected: == 0\n"
)]
fn fail_simple_eq() {
as... | code_fim | medium | {
"lang": "rust",
"repo": "danielparks/assertify",
"path": "/tests/assertify.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /util/gen-types/src/conversion/network.rs
use crate::{packed, prelude::*};
impl_conversion_for_packed_iterator_pack!(IndexTransaction, IndexTrans<|fim_suffix|>gest, HeaderDigestVec);
impl_conversion_for_packed_iterator_pack!(VerifiableHeader, VerifiableHeaderVec);<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/gen-types/src/conversion/network.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>gest, HeaderDigestVec);
impl_conversion_for_packed_iterator_pack!(VerifiableHeader, VerifiableHeaderVec);<|fim_prefix|>// repo: nervosnetwork/ckb path: /util/gen-types/src/conversion/network.rs
use crate::{packed, prelude::*};
impl_conversion_for_packed_iterator_pack!(IndexTransaction, IndexTransactionV... | code_fim | medium | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/gen-types/src/conversion/network.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: papamitra/compositor-rust path: /src/wl_surface.rs
use wayland_server::protocol::{wl_surface};
use wayland_server::Resource;
use surface::*;
pub fn wl_surface_implementation() -> wl_surface::Implementation<()> {
wl_surface::Implementation {
destroy: |_evlh, _data, _client, _surfac... | code_fim | hard | {
"lang": "rust",
"repo": "papamitra/compositor-rust",
"path": "/src/wl_surface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> surface.callback_done();
surface.buffer_release();
},
set_buffer_transform: |_, _, _, _, _| {
println!("call wl_surface.set_buffer_transform()");
},
set_buffer_scale: |_, _, _, _, _| {
println!("call wl_surface.set_buffer_sc... | code_fim | hard | {
"lang": "rust",
"repo": "papamitra/compositor-rust",
"path": "/src/wl_surface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nibrivia/simcomp path: /rustasim/src/scheduler.rs
use radix_heap::RadixHeapMap;
use std::cmp::Ordering;
use crate::nic;
pub enum EventType {
NICRx {nic: usize, packet: nic::Packet},
NICEnable { nic: usize },
}
pub struct Event {
pub time: u64,
pub event_type: EventType,
//f... | code_fim | hard | {
"lang": "rust",
"repo": "nibrivia/simcomp",
"path": "/rustasim/src/scheduler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.time == other.time
}
}
impl Eq for Event {} // don't use function
pub struct Scheduler {
time: u64,
limit: u64,
//queue: BinaryHeap<Event>,
queue: RadixHeapMap<i64, Event>,
// network elements
NICs: Vec<nic::NIC>,
}
impl Scheduler {
pub fn new() -> Scheduler... | code_fim | hard | {
"lang": "rust",
"repo": "nibrivia/simcomp",
"path": "/rustasim/src/scheduler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match brush_size {
1 => {
let digger_idx = map.xy_idx(x, y);
map.tiles[digger_idx] = TileType::Floor;
}
_ => {
let half_brush_size = brush_size / 2;
for brush_y in y-half_brush_size .. y+half_brush_size {
for brus... | code_fim | hard | {
"lang": "rust",
"repo": "thibautRe/rustrogueliketutorial",
"path": "/chapter-38-rooms/src/map_builders/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let idx = map.xy_idx(x, y);
map.tiles[idx] = TileType::Floor;
}
}
pub fn paint(map: &mut Map, mode: Symmetry, brush_size: i32, x: i32, y:i32) {
match mode {
Symmetry::None => apply_paint(map, brush_size, x, y),
Symmetry::Horizontal => {
let center_x = m... | code_fim | hard | {
"lang": "rust",
"repo": "thibautRe/rustrogueliketutorial",
"path": "/chapter-38-rooms/src/map_builders/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thibautRe/rustrogueliketutorial path: /chapter-38-rooms/src/map_builders/common.rs
use super::{Map, TileType};
use std::cmp::{max, min};
#[derive(PartialEq, Copy, Clone)]
#[allow(dead_code)]
pub enum Symmetry { None, Horizontal, Vertical, Both }
pub fn apply_horizontal_tunnel(map : &mut Map, x... | code_fim | hard | {
"lang": "rust",
"repo": "thibautRe/rustrogueliketutorial",
"path": "/chapter-38-rooms/src/map_builders/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: s3rvac/retdec-rust path: /tests/fileinfo.rs
//! Integration tests for the `fileinfo` service and tool.
//!
//! Unit tests are in each module in the `src` directory.
extern crate json;
extern crate retdec;
#[allow(dead_code)]
mod common;
use common::path_to_sample;
use common::run_tool;
<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "s3rvac/retdec-rust",
"path": "/tests/fileinfo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn fileinfo_correctly_analyzes_input_file() {
let output = run_tool(
"fileinfo", &[
"--output-format", "json",
"--verbose",
&path_to_sample("pe-hello.exe")
]
);
// There should be no errors.
let stderr = String::from_utf8_lossy(&... | code_fim | medium | {
"lang": "rust",
"repo": "s3rvac/retdec-rust",
"path": "/tests/fileinfo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use common::path_to_sample;
use common::run_tool;
#[test]
fn fileinfo_correctly_analyzes_input_file() {
let output = run_tool(
"fileinfo", &[
"--output-format", "json",
"--verbose",
&path_to_sample("pe-hello.exe")
]
);
// There should be no... | code_fim | medium | {
"lang": "rust",
"repo": "s3rvac/retdec-rust",
"path": "/tests/fileinfo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group.bench_function("zstd", |b| {
let rt = actix_rt::Runtime::new().unwrap();
let identity_svc = fn_service(|_: Request| async move {
let mut res = Response::with_body(StatusCode::OK, ());
let body = black_box(Encoder::response(
ContentEncoding... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-http/benches/response-body-compression.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: actix/actix-web path: /actix-http/benches/response-body-compression.rs
#![allow(clippy::uninlined_format_args)]
use std::convert::Infallible;
use actix_http::{encoding::Encoder, ContentEncoding, Request, Response, StatusCode};
use actix_service::{fn_service, Service as _};
use criterion::{blac... | code_fim | hard | {
"lang": "rust",
"repo": "actix/actix-web",
"path": "/actix-http/benches/response-body-compression.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: semtexzv/dp path: /code/deps/strat-eval/src/lib.rs
#![allow(unused_variables)]
use crate::prelude::*;
pub mod prelude;
pub mod lua;
#[derive(Debug,Fail,Serialize,Deserialize)]
pub enum EvalError {
#[fail(display = "Missing strategy required data")]
MissingData,
#[fail(display = "In... | code_fim | medium | {
"lang": "rust",
"repo": "semtexzv/dp",
"path": "/code/deps/strat-eval/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn eval(ohlc : BTreeMap<i64,Ohlc>, strat : String) -> Result<TradingPosition, EvalError> {
let strat = lua::LuaStrategy::new(&strat).map_err(|e| EvalError::InvalidStrategy(e.to_string()))?;
let input = StrategyInput {
ohlc
};
strat.decide(&input)
}<|fim_prefix|>// repo: semtex... | code_fim | medium | {
"lang": "rust",
"repo": "semtexzv/dp",
"path": "/code/deps/strat-eval/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yehuohan/ln-misc path: /rust/lnrust/src/book/autotests.rs
//! 自动化单元测试
fn func_add(a: i32, b: i32) -> i32 {
a + b
}
fn func_max(a: i32, b: i32) -> i32 {
if a >= b { a } else { b }
}
pub fn run() -> bool{
println!("add(1, 2) = {}", func_add(1, 2));
println!("max(1, 2) = {}", fu... | code_fim | hard | {
"lang": "rust",
"repo": "yehuohan/ln-misc",
"path": "/rust/lnrust/src/book/autotests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
//#[should_panic] // 要求测试发生painc
#[should_panic(expected="my panic")] // 要求expected是panic的信息的子串
//#[should_panic(expected="not my panic")]
fn it_painc() {
panic!("this is my panic");
}
}<|fim_prefix|>// repo: yehuohan/ln-misc path: /rust/lnrust/src/book/autotests.r... | code_fim | hard | {
"lang": "rust",
"repo": "yehuohan/ln-misc",
"path": "/rust/lnrust/src/book/autotests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let ids = [
"8863", "18987885", "18986544", "18987102", "18972892", "18973008",
];
for id in ids.iter() {
let _ = gorun(id).await?;
}
Ok(())
}<|fim_prefix|>// repo: stormasm/rust-hackernews path: /hn00/exa... | code_fim | hard | {
"lang": "rust",
"repo": "stormasm/rust-hackernews",
"path": "/hn00/examples/ex02.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
async fn gorun(id: &str) -> Result<(), reqwest::Error> {
let url = build_url(id);
println!("{}", url);
let body = get_body(url).await?;
let _ = write_redis(body, id);
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let ids = [
"8863", ... | code_fim | medium | {
"lang": "rust",
"repo": "stormasm/rust-hackernews",
"path": "/hn00/examples/ex02.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stormasm/rust-hackernews path: /hn00/examples/ex02.rs
fn build_url(favid: &str) -> String {
let mut s = String::from("https://hacker-news.firebaseio.com/v0/item/");
s.push_str(favid);
s.push_str(".json");
s
}
<|fim_suffix|> let client = redis::Client::open("redis://127.0.0.1/... | code_fim | hard | {
"lang": "rust",
"repo": "stormasm/rust-hackernews",
"path": "/hn00/examples/ex02.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbschlosser/resin path: /src/environment.rs
use datum::Datum;
use error::RuntimeError;
use std::collections::HashMap;
use std::rc::Rc;
use std::cell::RefCell;
#[derive(Debug)]
pub struct Environment {
parent: Option<Rc<RefCell<Environment>>>,
bindings: HashMap<String, Datum>
}
impl Env... | code_fim | hard | {
"lang": "rust",
"repo": "jbschlosser/resin",
"path": "/src/environment.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.bindings.contains_key(name) {
self.bindings.insert(name.to_string(), datum);
Ok(())
} else {
match self.parent {
Some(ref p) => p.borrow_mut().set(name, datum),
None => runtime_error!(
"Attempted to... | code_fim | hard | {
"lang": "rust",
"repo": "jbschlosser/resin",
"path": "/src/environment.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Debug)]
pub struct Session {
pub session_id: String,
pub message_id: i64,
pub user_id: String,
}<|fim_prefix|>// repo: Leonqn/dialogs-to-dialogflow path: /alice_to_dialogflow/src/dialogs/web_hook_response.rs
use serde::Serialize;
#[derive(Serialize, Debug)]
pub struct Res... | code_fim | medium | {
"lang": "rust",
"repo": "Leonqn/dialogs-to-dialogflow",
"path": "/alice_to_dialogflow/src/dialogs/web_hook_response.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Leonqn/dialogs-to-dialogflow path: /alice_to_dialogflow/src/dialogs/web_hook_response.rs
use serde::Serialize;
#[derive(Serialize, Debug)]
pub struct Response {
pub text: String,
pub tts: String,
pub end_session: bool,
}
<|fim_suffix|>#[derive(Serialize, Debug)]
pub struct Session ... | code_fim | medium | {
"lang": "rust",
"repo": "Leonqn/dialogs-to-dialogflow",
"path": "/alice_to_dialogflow/src/dialogs/web_hook_response.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("xbox = {0}", xbox); // Uncomment and get an error
println!("ybox = {0}", ybox);
let zbox = &ybox; /* zbox borrows the resource form y */
println!("ybox = {0} and zbox = {1}", ybox, zbox);
let mut a = Box::new(20);
println!("a = {0}", a);
a = Box::new(30);
... | code_fim | hard | {
"lang": "rust",
"repo": "ty01khan/PoPL-Lab",
"path": "/29-10-2019-Starting-with-Rust/features.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ty01khan/PoPL-Lab path: /29-10-2019-Starting-with-Rust/features.rs
fn main()
{
/* This is a short program demonstrating some of the features of
** rust type system. There are some commented, syntactically valid
** lines that you can uncomment. These will lead to errors but those
... | code_fim | medium | {
"lang": "rust",
"repo": "ty01khan/PoPL-Lab",
"path": "/29-10-2019-Starting-with-Rust/features.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("ybox = {0}", ybox);
let zbox = &ybox; /* zbox borrows the resource form y */
println!("ybox = {0} and zbox = {1}", ybox, zbox);
let mut a = Box::new(20);
println!("a = {0}", a);
a = Box::new(30);
println!("a = {0}", a);
let c = &a;
println!("c = {0}... | code_fim | medium | {
"lang": "rust",
"repo": "ty01khan/PoPL-Lab",
"path": "/29-10-2019-Starting-with-Rust/features.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> todo!()
}
fn encode(&self, writer: &mut impl Writer) -> Result<(), MCPEPacketDataError> {
UnsignedVarInt(self.len() as u32).encode(writer)?;
writer.write_slice(self.as_bytes())
}
}<|fim_prefix|>// repo: AnvilMC/anvil_bedrock path: /mcpe_protocol/src/objects/traits/str... | code_fim | hard | {
"lang": "rust",
"repo": "AnvilMC/anvil_bedrock",
"path": "/mcpe_protocol/src/objects/traits/string.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AnvilMC/anvil_bedrock path: /mcpe_protocol/src/objects/traits/string.rs
use crate::prelude::{MCPEPacketData, MCPEPacketDataError, Reader, UnsignedVarInt, Writer};
// TODO: Check for encoding / decoding issue
impl MCPEPacketData for String {
fn decode(reader: &mut impl Reader) -> Result<Self... | code_fim | hard | {
"lang": "rust",
"repo": "AnvilMC/anvil_bedrock",
"path": "/mcpe_protocol/src/objects/traits/string.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn encode(&self, writer: &mut impl Writer) -> Result<(), MCPEPacketDataError> {
UnsignedVarInt(self.len() as u32).encode(writer)?;
writer.write_slice(self.as_bytes())
}
}<|fim_prefix|>// repo: AnvilMC/anvil_bedrock path: /mcpe_protocol/src/objects/traits/string.rs
use crate::prelu... | code_fim | hard | {
"lang": "rust",
"repo": "AnvilMC/anvil_bedrock",
"path": "/mcpe_protocol/src/objects/traits/string.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PtaxLaine/enum-bits-rs path: /tests/u8.rs
use enum_bits::EnumBits;
#[repr(u8)]
#[derive(Debug, EnumBits, PartialEq)]
#[allow(non_camel_case_types)]
enum TestEnum {
Foo_77 = 77,
Bar_141 = 141,
Bar_142,
Baz_255 = 255,
Biz_44 = 88 / 2,
Zero = 0,
}
<|fim_suffix|> assert_... | code_fim | medium | {
"lang": "rust",
"repo": "PtaxLaine/enum-bits-rs",
"path": "/tests/u8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(None, TestEnum::read_i8(0));
assert_eq!(None, TestEnum::read_i16(0));
assert_eq!(None, TestEnum::read_i32(0));
assert_eq!(None, TestEnum::read_i64(0));
assert_eq!(None, TestEnum::read_i128(0));
}
#[test]
fn failed_write() {
assert_eq!(Some(0), (TestEnum::Zero).write_u8(... | code_fim | hard | {
"lang": "rust",
"repo": "PtaxLaine/enum-bits-rs",
"path": "/tests/u8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Some(0), (TestEnum::Zero).write_u8());
assert_eq!(None, (TestEnum::Zero).write_u16());
assert_eq!(None, (TestEnum::Zero).write_u32());
assert_eq!(None, (TestEnum::Zero).write_u64());
assert_eq!(None, (TestEnum::Zero).write_u128());
assert_eq!(None, (TestEnum::Zero).writ... | code_fim | hard | {
"lang": "rust",
"repo": "PtaxLaine/enum-bits-rs",
"path": "/tests/u8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn name(&'a self, id: Self::FileId) -> Result<Self::Name, codespan_reporting::files::Error> {
Ok(self.files[id.0].name())
}
fn source(
&'a self,
id: Self::FileId,
) -> Result<Self::Source, codespan_reporting::files::Error> {
Ok(self.files[id.0].source().as_... | code_fim | hard | {
"lang": "rust",
"repo": "sria91-rlox/rlox-41",
"path": "/crates/interpreter/src/source_file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sria91-rlox/rlox-41 path: /crates/interpreter/src/source_file.rs
// Basically a minor modification to codespan_reportings SimpleFiles because I wanted
// a more strongly-typed file ID.
use codespan_reporting::files::{Files, SimpleFile};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, O... | code_fim | hard | {
"lang": "rust",
"repo": "sria91-rlox/rlox-41",
"path": "/crates/interpreter/src/source_file.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hayatoito/icfp2006 path: /src/um.rs
// use std::fs::File;
// use crate::prelude::Result;
use std::io::{Read, Write};
use std::time::Instant;
use log::*;
#[derive(Debug, PartialEq, Eq)]
pub enum UmStatus {
NoInput,
Halt,
}
type Array = Vec<u32>;
#[derive(Clone)]
pub struct Um {
... | code_fim | hard | {
"lang": "rust",
"repo": "hayatoito/icfp2006",
"path": "/src/um.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::prelude::Result;
use std::path::PathBuf;
#[test]
#[ignore]
fn um_sandmark_benchmark() -> Result<()> {
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut f = std::fs::File::open(dir.join("task/01_implement_... | code_fim | hard | {
"lang": "rust",
"repo": "hayatoito/icfp2006",
"path": "/src/um.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //let words: String = String::from("words are fun!");
//println!("{:?}", slices::first_word(&words));
}
/*
0 - Generate random customers w/ random names
1 - Simulate bar based on number of patrons
2 - Make simulation more interesting
3 - Add GUI
*/<|fim_prefix|>// repo: celialewis3/pokeru... | code_fim | hard | {
"lang": "rust",
"repo": "celialewis3/pokerust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: celialewis3/pokerust path: /src/main.rs
//mod bar;
//mod talk;
//mod generics;
mod pokemon;
//mod slices;
fn main() {
//bar::simulate_bar(2);
//let room = talk::Room::new(10);
//room.talk();
pokemon::simulate();
<|fim_suffix|> //let words: String = String::from("words are fun!");
... | code_fim | medium | {
"lang": "rust",
"repo": "celialewis3/pokerust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// println!("{:?}", generics::perry());
// println!("{:?}", generics::animal_computer());
// generics::computer_data();
//let words: String = String::from("words are fun!");
//println!("{:?}", slices::first_word(&words));
}
/*
0 - Generate random customers w/ random names
1 - Simulate ... | code_fim | medium | {
"lang": "rust",
"repo": "celialewis3/pokerust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aergonaut/i18n-rs path: /src/errors.rs
//! Result and error types
use std::result::Result as StdResult;
use std::error;
use std::fmt;
use std::io;
use yaml_rust;
/// Result type used by this crate's functions
pub type Result<T> = StdResult<T, Error>;
/// `Error` enum describing possible error... | code_fim | hard | {
"lang": "rust",
"repo": "aergonaut/i18n-rs",
"path": "/src/errors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Error::Io(ref err) => write!(f, "IO error: {}", err),
Error::Yaml(ref err) => write!(f, "YAML error: {}", err),
Error::Other(ref msg) => write!(f, "Other error: {}", msg)
}
}
}
impl error::Error for Error {
fn description(&self) ->... | code_fim | medium | {
"lang": "rust",
"repo": "aergonaut/i18n-rs",
"path": "/src/errors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jrwalk/rusttext path: /bindings/python/src/lib.rs
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
fn foo() -> PyResult<String> {
return Ok(String::from("foo"));
}
<|fim_suffix|> m.add_function(wrap_pyfunction!(foo, m)?)?;
Ok(())
}<|fim_middle|>#[pymodule]
fn rusttext... | code_fim | medium | {
"lang": "rust",
"repo": "jrwalk/rusttext",
"path": "/bindings/python/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> m.add_function(wrap_pyfunction!(foo, m)?)?;
Ok(())
}<|fim_prefix|>// repo: jrwalk/rusttext path: /bindings/python/src/lib.rs
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyfunction]
fn foo() -> PyResult<String> {
<|fim_middle|> return Ok(String::from("foo"));
}
#[pymodule]
fn rusttext... | code_fim | medium | {
"lang": "rust",
"repo": "jrwalk/rusttext",
"path": "/bindings/python/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dropbox/ruba path: /src/engine/vector_op/vector_operator.rs
<'a> {
Box::new(BitUnpackOperator::new(inner, output, shift, width))
}
pub fn type_conversion(inner: BufferRef, output: BufferRef, initial_type: EncodingType, target_type: EncodingType) -> BoxedOperator<'a> {
us... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/engine/vector_op/vector_operator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dropbox/ruba path: /src/engine/vector_op/vector_operator.rs
scratchpad.set(self.output, self.val.clone());
}
}
impl<'a> fmt::Debug for VectorConstant<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} <- VectorConstant(...)", self.output.0)
}
}
im... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/engine/vector_op/vector_operator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> VecOperator<'a> for IndexEncoded<'a> {
fn execute(&mut self, scratchpad: &mut Scratchpad<'a>) {
let result = {
let indices = scratchpad.get(self.filter);
self.col.index_encoded(indices.cast_ref_usize())
};
scratchpad.set(self.output, result);
... | code_fim | hard | {
"lang": "rust",
"repo": "dropbox/ruba",
"path": "/src/engine/vector_op/vector_operator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spirali/dera path: /src/mpi/core.rs
use mpi::environment::Universe;
use mpi::topology::Communicator;
use mpi::topology::{Rank, SystemCommunicator};
pub(crate) struct Core {
universe: Universe
}
impl Core {
pub fn new(universe: Universe) -> Self {
Core { universe }
}
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "spirali/dera",
"path": "/src/mpi/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn rank(&self) -> Rank {
self.universe.world().rank()
}
}<|fim_prefix|>// repo: spirali/dera path: /src/mpi/core.rs
use mpi::environment::Universe;
use mpi::topology::Communicator;
use mpi::topology::{Rank, SystemCommunicator};
pub(crate) struct Core {
universe: Universe
}
impl ... | code_fim | medium | {
"lang": "rust",
"repo": "spirali/dera",
"path": "/src/mpi/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xray-tech/xorc-gateway path: /src/events/input/sdk_environment.rs
use events::output;
#[derive(Deserialize, Debug, Clone)]
pub struct SDKEnvironment {
pub sdk_version: Option<String>,
pub app_version: Option<String>,
pub app_store_id: Option<String>,
#[serde(default)] pub app_id... | code_fim | medium | {
"lang": "rust",
"repo": "xray-tech/xorc-gateway",
"path": "/src/events/input/sdk_environment.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> output::events::SdkEnvironment {
app_id: Some(self.app_id),
sdk_version: self.sdk_version,
app_version: self.app_version,
app_store_id: self.app_store_id,
app_instance_id: self.app_instance_id,
}
}
}<|fim_prefix|>// repo: xray... | code_fim | medium | {
"lang": "rust",
"repo": "xray-tech/xorc-gateway",
"path": "/src/events/input/sdk_environment.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tari-project/tari path: /base_layer/core/src/chain_storage/block_add_result.rs
// Copyright 2021. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of s... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/core/src/chain_storage/block_add_result.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::blocks::ChainBlock;
#[derive(Clone, Debug, PartialEq)]
pub enum BlockAddResult {
Ok(Arc<ChainBlock>),
BlockExists,
OrphanBlock,
/// Indicates the new block caused a chain reorg.
/// This contains added blocks ordered from lowest to highest block height, and
/// the remo... | code_fim | hard | {
"lang": "rust",
"repo": "tari-project/tari",
"path": "/base_layer/core/src/chain_storage/block_add_result.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Box::new(self.clone());
}
fn get_kotae(&self, chara: &Hitogata) -> Result {
return Result::Message((chara.kaeshi.tawainai.douitashimashite)());
}
}<|fim_prefix|>// repo: alivelime/motenas path: /omoinas/src/omomuki/tawainai/douitashimashite.rs
use crate::model::hitogata... | code_fim | hard | {
"lang": "rust",
"repo": "alivelime/motenas",
"path": "/omoinas/src/omomuki/tawainai/douitashimashite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alivelime/motenas path: /omoinas/src/omomuki/tawainai/douitashimashite.rs
use crate::model::hitogata::Hitogata;
use crate::omomuki::{Omomuki, Result};
use crate::Tumori;
<|fim_suffix|>impl Tumori for Douitashimashite {
fn kotafu(&self, _: &Hitogata) -> Box<dyn Tumori> {
return Box::... | code_fim | hard | {
"lang": "rust",
"repo": "alivelime/motenas",
"path": "/omoinas/src/omomuki/tawainai/douitashimashite.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bool
(
)
.
map_or
(
false
|
b
|
b
=
=
*
other
)
}
}
macro_rules
!
partialeq_numeric
{
(
(
[
(
ty
:
ty
)
*
]
conversion
:
ident
base
:
ty
)
*
)
=
>
{
(
(
impl
PartialEq
<
ty
>
for
Value
{
fn
eq
(
&
self
other
:
&
ty
)
-
>
bool
{
self
.
conversion
(
)
.
map_or
(
false
|
i
|
i
=
=
(
*
other
as
base
)
)
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_yaml/src/value/partial_eq.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/serde_yaml/src/value/partial_eq.rs
use
crate
:
:
Value
;
impl
PartialEq
for
Value
{
fn
eq
(
&
self
other
:
&
Value
)
-
>
bool
{
match
(
self
other
)
{
(
Value
:
:
Null
Value
:
:
Null
)
=
>
true
(
Value
:
:
Bool
(
a
)
Value
:
:
Bool
(
b
)
)
=
>
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/serde_yaml/src/value/partial_eq.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/agents_and_teams/set_cheer_at_no_enemy.rs
use language::operations::{make_param_doc, Operation, ParamInfo};
pub struct SetCheerAtNoEnemyOp;
const DOC : &str = "Version 1.153+. Determines whether the agents will cheer when no enemy remain on... | code_fim | medium | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/agents_and_teams/set_cheer_at_no_enemy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Operation for SetCheerAtNoEnemyOp {
fn op_code(&self) -> u32 {
OP_CODE
}
fn documentation(&self) -> &'static str {
DOC
}
fn identifier(&self) -> &'static str {
IDENT
}
fn param_info(&self) -> ParamInfo {
ParamInfo {
num_requir... | code_fim | medium | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/agents_and_teams/set_cheer_at_no_enemy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sybila/biodivine-aeon-server path: /src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs
use crate::scc::algo_interleaved_transition_guided_reduction::{Process, Scheduler};
use crate::GraphTaskContext;
use biodivine_lib_param_bn::biodivine_std::traits::Set;
use biodivine_lib_p... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Second, put the best process in the last place
self.processes.sort_by_key(|(w, _)| usize::MAX - (*w));
// Perform one step in a process
if let Some((_, mut process)) = self.processes.pop() {
let is_done = process.step(self, graph);
if !is_done {
... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // First, apply to_discard in all processes:
if let Some(to_discard) = self.to_discard.as_ref() {
for (w, process) in self.processes.iter_mut() {
process.discard_states(to_discard);
*w = process.weight();
}
self.to_discard... | code_fim | hard | {
"lang": "rust",
"repo": "sybila/biodivine-aeon-server",
"path": "/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ykszk/tablify path: /tests/cli.rs
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
<|fim_suffix|> cmd.arg("foo").arg("bar");
cmd.assert()
.failure()
.stderr(predicate::str::contains("No such file or directory"));
Ok(())
}<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "ykszk/tablify",
"path": "/tests/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmd.arg("foo").arg("bar");
cmd.assert()
.failure()
.stderr(predicate::str::contains("No such file or directory"));
Ok(())
}<|fim_prefix|>// repo: ykszk/tablify path: /tests/cli.rs
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
#[test]
fn f... | code_fim | easy | {
"lang": "rust",
"repo": "ykszk/tablify",
"path": "/tests/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cmd = Command::cargo_bin("tablify")?;
cmd.arg("foo").arg("bar");
cmd.assert()
.failure()
.stderr(predicate::str::contains("No such file or directory"));
Ok(())
}<|fim_prefix|>// repo: ykszk/tablify path: /tests/cli.rs
use assert_cmd::prelude::*;
use predicates::p... | code_fim | medium | {
"lang": "rust",
"repo": "ykszk/tablify",
"path": "/tests/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kerryeon/smartx-whitedog path: /zeus/manager/src/main.rs
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate serde_json;
mod api;
mod routes;
#[tokio::main]
async fn main() {
match try_main().await {
Ok(()) => {}
Err(e) => error!("Aborted: {}\n{:#?}", &e, &e),
}... | code_fim | medium | {
"lang": "rust",
"repo": "kerryeon/smartx-whitedog",
"path": "/zeus/manager/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.