text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: niilz/Automate-the-Boring-Stuff-with-Rust path: /ch_01/src/main.rs
// This program says hello and asks for my name.
use std::io; // brings the module we need to access user input in scope
fn main() {
println!("Hello, world!");
println!("What is your name?");
let mut myName = Stri... | code_fim | hard | {
"lang": "rust",
"repo": "niilz/Automate-the-Boring-Stuff-with-Rust",
"path": "/ch_01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GregorySDTaylor/gjp path: /src/main.rs
use std::process::Command;
use ureq;
use std::fs;
use serde_json::Value;
use std::env;
fn main() {
// https://developers.google.com/drive/api/v3/reference/files/export
// https://developers.google.com/oauthplayground
// https://console.cloud.g... | code_fim | hard | {
"lang": "rust",
"repo": "GregorySDTaylor/gjp",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tringify java source");
let name_with_extension = get_value["name"].as_str()
.expect("failed to get file name");
let name = &name_with_extension[..name_with_extension.len()-5];
let source_path = format!("java_src/{}.java", &name);
fs::create_dir_all("java_src")
.expect("fai... | code_fim | hard | {
"lang": "rust",
"repo": "GregorySDTaylor/gjp",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stream = Stream {
source: StreamSource::Torrent {
info_hash: [
0xdd, 0x82, 0x55, 0xec, 0xdc, 0x7c, 0xa5, 0x5f, 0xb0, 0xbb, 0xf8, 0x13, 0x23, 0xd8,
0x70, 0x62, 0xdb, 0x1f, 0x6d, 0x1c,
],
file_idx: None,
announce... | code_fim | hard | {
"lang": "rust",
"repo": "nklhtv/stremio-core",
"path": "/src/unit_tests/deep_links/external_player_link.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stream = Stream {
source: StreamSource::PlayerFrame {
player_frame_url: Url::from_str(HTTP_STR_URL).unwrap(),
},
name: None,
description: None,
thumbnail: None,
subtitles: vec![],
behavior_hints: Default::default(),
};
let... | code_fim | hard | {
"lang": "rust",
"repo": "nklhtv/stremio-core",
"path": "/src/unit_tests/deep_links/external_player_link.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nklhtv/stremio-core path: /src/unit_tests/deep_links/external_player_link.rs
use crate::deep_links::ExternalPlayerLink;
use crate::types::resource::{Stream, StreamSource};
use std::convert::TryFrom;
use std::str::FromStr;
use url::Url;
const MAGNET_STR_URL: &str = "magnet:?xt=urn:btih:dd8255ecd... | code_fim | hard | {
"lang": "rust",
"repo": "nklhtv/stremio-core",
"path": "/src/unit_tests/deep_links/external_player_link.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Bubble sort!");
let mut myvec = create_random_vector(10);
println!("Sorting {:?}", myvec);
sort(&mut myvec);
println!("Sorted {:?}", myvec);
}<|fim_prefix|>// repo: ericho/algorithms path: /rust-algorithms/src/bubble-sort.rs
extern crate rand;
use rand::distributions::{In... | code_fim | hard | {
"lang": "rust",
"repo": "ericho/algorithms",
"path": "/rust-algorithms/src/bubble-sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericho/algorithms path: /rust-algorithms/src/bubble-sort.rs
extern crate rand;
use rand::distributions::{IndependentSample, Range};
// Create a vector of random integers of size n
fn create_random_vector(n: i32) -> Vec<i32> {
let mut myvec = Vec::new();
let range = Range::new(0, 1000);... | code_fim | medium | {
"lang": "rust",
"repo": "ericho/algorithms",
"path": "/rust-algorithms/src/bubble-sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stock: Stock = Stock::new("MonolithAi", 36.5);
println!("here is the stock name: {}", stock.name);
println!("here is the stock name: {}", stock.current_price);
}<|fim_prefix|>// repo: OZ-T/Speed-up-your-Python-with-Rust path: /chapter_two/structuring_code/src/main.rs
mod stocks;
use stoc... | code_fim | easy | {
"lang": "rust",
"repo": "OZ-T/Speed-up-your-Python-with-Rust",
"path": "/chapter_two/structuring_code/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OZ-T/Speed-up-your-Python-with-Rust path: /chapter_two/structuring_code/src/main.rs
mod stocks;
use stocks::structs::stock::Stock;
<|fim_suffix|> let stock: Stock = Stock::new("MonolithAi", 36.5);
println!("here is the stock name: {}", stock.name);
println!("here is the stock name:... | code_fim | easy | {
"lang": "rust",
"repo": "OZ-T/Speed-up-your-Python-with-Rust",
"path": "/chapter_two/structuring_code/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_lone_default_widget_count() {
btm_command()
.arg("-C")
.arg("./tests/invalid_configs/lone_default_widget_count.toml")
.assert()
.failure()
.stderr(predicate::str::contains("it must be used with"));
}
#[test]
fn test_invalid_default_widget_count(... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/tests/invalid_config_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ClementTsang/bottom path: /tests/invalid_config_tests.rs
use assert_cmd::prelude::*;
use predicates::prelude::*;
mod util;
use util::*;
// These tests are for testing some config file-specific options.
#[test]
fn test_toml_mismatch_type() {
btm_command()
.arg("-C")
.arg(".... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/tests/invalid_config_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_invalid_colour_rgb_2() {
btm_command()
.arg("-C")
.arg("./tests/invalid_configs/invalid_colour_rgb_2.toml")
.assert()
.failure()
.stderr(predicate::str::contains("invalid RGB"));
}
#[test]
fn test_invalid_colour_string() {
btm_command()
... | code_fim | hard | {
"lang": "rust",
"repo": "ClementTsang/bottom",
"path": "/tests/invalid_config_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use approx::assert_abs_diff_eq;
use hdf5::File;
use ndarray::{array, ArrayD};
use tch::nn::{ModuleT, VarStore};
use tch::{Device, Kind, Tensor};
use crate::hdf5_model::LoadFromHDF5;
use crate::models::bert::{BertConfig, BertEncoder};
use crate::models::roberta::RobertaEmbe... | code_fim | hard | {
"lang": "rust",
"repo": "stickeritis/sticker-transformers",
"path": "/src/models/roberta/mod.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "load-hdf5")]
mod hdf5_impl {
use std::borrow::Borrow;
use hdf5::Group;
use tch::nn::Path;
use crate::hdf5_model::LoadFromHDF5;
use crate::models::bert::{BertConfig, BertEmbeddings, BertError};
use crate::models::roberta::RobertaEmbeddings;
impl LoadFromHDF5 ... | code_fim | hard | {
"lang": "rust",
"repo": "stickeritis/sticker-transformers",
"path": "/src/models/roberta/mod.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stickeritis/sticker-transformers path: /src/models/roberta/mod.rs
// Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
// Copyright (c) 2020 The sticker developers.
//
// Licensed under the Apache Li... | code_fim | hard | {
"lang": "rust",
"repo": "stickeritis/sticker-transformers",
"path": "/src/models/roberta/mod.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lunatic-solutions/lunatic path: /src/mode/common.rs
use std::{path::PathBuf, sync::Arc};
use anyhow::{anyhow, Context, Result};
use clap::Args;
use lunatic_distributed::DistributedProcessState;
use lunatic_process::{
env::{Environment, LunaticEnvironment, LunaticEnvironments},
runtimes... | code_fim | hard | {
"lang": "rust",
"repo": "lunatic-solutions/lunatic",
"path": "/src/mode/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Inherit environment variables
config.set_environment_variables(std::env::vars().collect());
// Always preopen the current dir
config.preopen_dir(".");
for dir in args.dir {
if let Some(s) = dir.as_os_str().to_str() {
config.preopen_dir(s);
}
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "lunatic-solutions/lunatic",
"path": "/src/mode/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Todo {
id: id,
title: "Read rocket tutorial".into(),
description: "Read https://rocket.rs/guide/quickstart/".into(),
done: false,
}
}<|fim_prefix|>// repo: tamakiii-sandbox/hello-rust path: /project/hello/src/routes.rs
// #![feature(decl_macro)]
use rocket::respon... | code_fim | hard | {
"lang": "rust",
"repo": "tamakiii-sandbox/hello-rust",
"path": "/project/hello/src/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tamakiii-sandbox/hello-rust path: /project/hello/src/routes.rs
// #![feature(decl_macro)]
use rocket::response::status;
use rocket_contrib::json::Json;
use crate::models::Todo;
#[get("/")]
pub fn index() -> &'static str {
"Hello, world"
}
<|fim_suffix|>#[get("/todo/<id>")]
pub fn todo(id... | code_fim | hard | {
"lang": "rust",
"repo": "tamakiii-sandbox/hello-rust",
"path": "/project/hello/src/routes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rokannon/Rust-Exonum-Test path: /timestamping/src/lib.rs
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate exonum;
extern crate router;
extern crate bodyparser;
extern crate iron;
extern crate time;
use exonum::blockchain::{Blockchain... | code_fim | hard | {
"lang": "rust",
"repo": "Rokannon/Rust-Exonum-Test",
"path": "/timestamping/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct TimestampingService;
impl Service for TimestampingService {
fn service_name(&self) -> &'static str {
"timestamping"
}
fn service_id(&self) -> u16 {
SERVICE_ID
}
fn tx_from_raw(&self, raw: RawTransaction) -> Result<Box<Transaction>, encoding::Error> {
... | code_fim | hard | {
"lang": "rust",
"repo": "Rokannon/Rust-Exonum-Test",
"path": "/timestamping/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GVisconti84/wasm-game-of-life-perf-comparison path: /src/renderers/consts.rs
// TODO: Can we centralize these constants between Js and Rs?
pub const BPP: usize =<|fim_suffix|> &[255, 255, 255, 255];
pub const ALIVE_COLOR: &'static [u8] = &[ 22, 22, 22, 255];<|fim_middle|> 4;
pub const CELL_SIZ... | code_fim | medium | {
"lang": "rust",
"repo": "GVisconti84/wasm-game-of-life-perf-comparison",
"path": "/src/renderers/consts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>COLOR: &'static [u8] = &[204, 204, 204, 255];
pub const DEAD_COLOR: &'static [u8] = &[255, 255, 255, 255];
pub const ALIVE_COLOR: &'static [u8] = &[ 22, 22, 22, 255];<|fim_prefix|>// repo: GVisconti84/wasm-game-of-life-perf-comparison path: /src/renderers/consts.rs
// TODO: Can we centralize these co... | code_fim | medium | {
"lang": "rust",
"repo": "GVisconti84/wasm-game-of-life-perf-comparison",
"path": "/src/renderers/consts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &[255, 255, 255, 255];
pub const ALIVE_COLOR: &'static [u8] = &[ 22, 22, 22, 255];<|fim_prefix|>// repo: GVisconti84/wasm-game-of-life-perf-comparison path: /src/renderers/consts.rs
// TODO: Can we centralize these constants between Js and Rs?
pub const BPP: usize = 4;
pub const CELL_SIZE: usize = 5;... | code_fim | medium | {
"lang": "rust",
"repo": "GVisconti84/wasm-game-of-life-perf-comparison",
"path": "/src/renderers/consts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> &'a mut W {
self.variant(MODEW::MODE_1)
}
#[doc = r" Sets the field bit"]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r" Clears the field bit"]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r" Writes raw bits to... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/usart0/acr/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>elf {
STARTW::STOP => false,
STARTW::START => true,
}
}
}
#[doc = r" Proxy"]
pub struct _STARTW<'a> {
w: &'a mut W,
}
impl<'a> _STARTW<'a> {
#[doc = r" Writes `variant` to the field"]
#[inline]
pub fn variant(self, variant: STARTW) -> &'a mut W {
... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/usart0/acr/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/rust-lpc43xx path: /src/usart0/acr/mod.rs
pub fn is_stop(&self) -> bool {
*self == STARTR::STOP
}
#[doc = "Checks if the value of the field is `START`"]
#[inline]
pub fn is_start(&self) -> bool {
*self == STARTR::START
}
}
#[doc = "Possible values of the... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/usart0/acr/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ( num_traversed, res )
}
}
/// A fast sorting function for arrays with *at most 4 elements*.
/// The elements are sorted by their second tuple-element
fn sort_small( a : &mut [(i32, f32)], n : usize ) {
if n == 2 {
if a[ 1 ].1 < a[ 0 ].1 {
a.swap( 0, 1 );
}
} else if n == 3 {
... | code_fim | hard | {
"lang": "rust",
"repo": "sourcedennis/wasm-pathtracer",
"path": "/src/graphics/scene.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sourcedennis/wasm-pathtracer path: /src/graphics/scene.rs
// External imports
use std::f32::{INFINITY};
use std::rc::Rc;
// Local imports
use crate::graphics::{Color3, AABB};
use crate::graphics::ray::{Ray, Hit, Tracable};
use crate::graphics::lights::Light;
use crate::math::{Vec3, EPSILON};
use... | code_fim | hard | {
"lang": "rust",
"repo": "sourcedennis/wasm-pathtracer",
"path": "/src/graphics/scene.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Settings {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
f.write_fmt(format_args!("{}", "Settings:\n".green().underline()));
f.write_fmt(format_args!(
"{}:\n\t{}\n",
"basedir".green().underline(),
self.basedir
... | code_fim | hard | {
"lang": "rust",
"repo": "halhenke/git-global",
"path": "/src/models/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: halhenke/git-global path: /src/models/settings.rs
use crate::models::{
action::Action, repo::Repo, repo::Updatable, repo_tag::RepoTag,
result::GitGlobalResult, utils::new_find_repos,
};
use anyhow::Context;
// use anyhow::{Context, Result};
// use config::{Environment, File as CFile, Sou... | code_fim | hard | {
"lang": "rust",
"repo": "halhenke/git-global",
"path": "/src/models/settings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.write_fmt(format_args!("{}", "Settings:\n".green().underline()));
f.write_fmt(format_args!(
"{}:\n\t{}\n",
"basedir".green().underline(),
self.basedir
.as_ref()
.unwrap_or(&"Nothing Provided".to_owned())
... | code_fim | hard | {
"lang": "rust",
"repo": "halhenke/git-global",
"path": "/src/models/settings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wasmerio/wasmer path: /lib/vm/src/store.rs
use crate::{
VMExternObj, VMFunction, VMFunctionEnvironment, VMGlobal, VMInstance, VMMemory, VMTable,
};
use core::slice::Iter;
use std::{cell::UnsafeCell, fmt, marker::PhantomData, num::NonZeroUsize, ptr::NonNull};
use wasmer_types::StoreId;
/// T... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/lib/vm/src/store.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a mutable reference to the object that this handle points to.
pub fn get_mut<'a>(&self, ctx: &'a mut StoreObjects) -> &'a mut T {
&mut T::list_mut(ctx)[self.idx.get() - 1]
}
pub(crate) fn index(&self) -> usize {
self.idx.get()
}
pub(crate) fn from_inde... | code_fim | hard | {
"lang": "rust",
"repo": "wasmerio/wasmer",
"path": "/lib/vm/src/store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nth(0).and_then(|row| row[0].as_i64()),
//! );
//! }
//! ```
pub mod ast;
#[cfg(any(
feature = "mysql-16",
feature = "postgresql-0_16",
feature = "rusqlite-0_19"
))]
pub mod connector;
pub mod error;
#[cfg(any(
feature = "mysql-16",
feature = "postgresql-0_16",
feature = "rusql... | code_fim | hard | {
"lang": "rust",
"repo": "tomhoule/prisma-query",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomhoule/prisma-query path: /src/lib.rs
//! # prisma-query
//!
//! prisma-query is an AST and database-specific visitors for creating SQL
//! statements.
//!
//! Under construction and will go through several rounds of changes. Not meant
//! for production use in the current form.
//!
//! ### Go... | code_fim | hard | {
"lang": "rust",
"repo": "tomhoule/prisma-query",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match code {
OptionCode::Comment => {
let s = str::from_utf8(value).unwrap_or("<Invalid UTF-8>");
println!("Hardware: {}", s);
}
OptionCode::EndOfOpt => println!("End of Options"),
OptionCode(2) => {
let s = str::from_utf8(value).unwr... | code_fim | hard | {
"lang": "rust",
"repo": "zachhuang97/pcap-analyzer",
"path": "/pcap-info/src/info.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zachhuang97/pcap-analyzer path: /pcap-info/src/info.rs
reassign_with_default)]
pub(crate) fn process_file(name: &str, options: &Options) -> Result<i32, io::Error> {
println!("File name: {}", name);
if name != "-" {
let metadata = fs::metadata(name)?;
println!(" size: {}... | code_fim | hard | {
"lang": "rust",
"repo": "zachhuang97/pcap-analyzer",
"path": "/pcap-info/src/info.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zachhuang97/pcap-analyzer path: /pcap-info/src/info.rs
file))
} else {
Box::new(file)
}
};
Ok(input_reader)
}
#[allow(clippy::field_reassign_with_default)]
pub(crate) fn process_file(name: &str, options: &Options) -> Result<i32, io::Error> {
println!("Fil... | code_fim | hard | {
"lang": "rust",
"repo": "zachhuang97/pcap-analyzer",
"path": "/pcap-info/src/info.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/erc20_on_evm/eth/get_eth_output_json.rs
use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
use crate::{
chains::{
eth::{
any_sender::relay_transaction::RelayTransaction,
eth_crypto::eth_trans... | code_fim | hard | {
"lang": "rust",
"repo": "provable-things/ptokens-core",
"path": "/src/erc20_on_evm/eth/get_eth_output_json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_eth_output_json<D: DatabaseInterface>(state: EthState<D>) -> Result<String> {
info!("✔ Getting ETH output json...");
let output = serde_json::to_string(&EthOutput {
eth_latest_block_number: get_latest_eth_block_number(&state.db)?,
evm_signed_transactions: if state.erc20_... | code_fim | hard | {
"lang": "rust",
"repo": "provable-things/ptokens-core",
"path": "/src/erc20_on_evm/eth/get_eth_output_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Lombok;
pub use self::mutable::Module as Mutable;
pub use self::nullable::Module as Nullable;<|fim_prefix|>// repo: reproto/reproto path: /lib/backend-java/src/module/mod.rs
mod builder;
mod constructor_properties;
mod jackson;
mod lombok;
mod mutable;
mod nullable;
<|fim_middle|>
pub use self::builder:... | code_fim | medium | {
"lang": "rust",
"repo": "reproto/reproto",
"path": "/lib/backend-java/src/module/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reproto/reproto path: /lib/backend-java/src/module/mod.rs
mod builder;
mod constructor_properties;
mod jackson;
mod lombok;
mod mutable;
mod nullable;
pub use self::builder::Module as Builder;
pub use self::constructor_properties::Module as Con<|fim_suffix|> Lombok;
pub use self::mutable::Modul... | code_fim | medium | {
"lang": "rust",
"repo": "reproto/reproto",
"path": "/lib/backend-java/src/module/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(test)]
mod computational_test {
#[test]
fn compare() {
for _i in { 0..100 } {
let functional = super::compute_functional(5);
let functional_opt = super::compute_functional(5);
let imperative = super::compute_imperative(5);
let imperati... | code_fim | hard | {
"lang": "rust",
"repo": "MaciekTalaska/rust_performance_test",
"path": "/src/computation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaciekTalaska/rust_performance_test path: /src/computation.rs
use common::*;
pub fn compute_functional(count: u32) -> u32 {
(0..count)
.map(|_e| return_5()-1)
.fold(0, |sum, val| sum * 6 + val)
}
pub fn compute_functional_opt(count: u32) -> u32 {
(0..count)
.map... | code_fim | hard | {
"lang": "rust",
"repo": "MaciekTalaska/rust_performance_test",
"path": "/src/computation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dewaka/advent-rust path: /advent16/src/day7.rs
// https://adventofcode.com/2016/day/7
/*
--- Day 7: Internet Protocol Version 7 ---
While snooping around the local network of EBHQ, you compile a list of IP
addresses (they're IPv7, of course; IPv6 is much too limited). You'd like to
figure out w... | code_fim | hard | {
"lang": "rust",
"repo": "dewaka/advent-rust",
"path": "/advent16/src/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_string(ipstr: &str) -> Option<IP> {
let mut ants: Vec<String> = vec![];
let mut hypers: Vec<String> = vec![];
let mut current_ant = String::new();
let mut current_hyper = String::new();
let mut hyper_section = false;
for c in ipstr.chars() ... | code_fim | hard | {
"lang": "rust",
"repo": "dewaka/advent-rust",
"path": "/advent16/src/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iximeow/reifenfeuerd path: /src/linestream.rs
use std;
use futures::stream::Stream;
use futures::{Poll, Async};
pub struct LineStream<S, E> where S: Stream<Item=u8, Error=E> {
stream: S,
progress: Vec<u8>
}
<|fim_suffix|> loop {
match self.stream.poll() {
Ok(Async::Ready(S... | code_fim | hard | {
"lang": "rust",
"repo": "iximeow/reifenfeuerd",
"path": "/src/linestream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
match self.stream.poll() {
Ok(Async::Ready(Some(byte))) => {
if byte == 0x0a {
let mut new_vec = vec![];
std::mem::swap(&mut self.progress, &mut new_vec);
return Ok(Async::Ready(Some(new_vec)))
} else {
self.prog... | code_fim | hard | {
"lang": "rust",
"repo": "iximeow/reifenfeuerd",
"path": "/src/linestream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A specialized [`Result`] type for I/O operations.
///
/// This type is broadly used across [`axstd::io`] for any operation which may
/// produce an error.
///
/// This typedef is generally used to avoid writing out [`io::Error`] directly and
/// is otherwise a direct mapping to [`Result`].
///
/// Whi... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/arceos",
"path": "/ulib/axstd/src/io/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os/arceos path: /ulib/axstd/src/io/mod.rs
//! Traits, helpers, and type definitions for core I/O functionality.
mod stdio;
pub use axio::prelude;
pub use axio::{BufRead, BufReader, Error, Read, Seek, SeekFrom, Write};
<|fim_suffix|>/// A specialized [`Result`] type for I/O operations.
/... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/arceos",
"path": "/ulib/axstd/src/io/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("cargo:rustc-link-lib=dylib={}", zmq_lib_name);
}<|fim_prefix|>// repo: eddyb/zmq-rs path: /zmq-ffi/build.rs
use std::env;
fn main() {
let zmq_lib_path_var = env::var("ZMQ_LIB_PATH");
if zmq_lib_path_var.is_ok() {
let zmq_lib_path = zmq_lib_path_var.unwrap();
printl... | code_fim | medium | {
"lang": "rust",
"repo": "eddyb/zmq-rs",
"path": "/zmq-ffi/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eddyb/zmq-rs path: /zmq-ffi/build.rs
use std::env;
fn main() {
let zmq_lib_path_var = env::var("ZMQ_LIB_PATH");
if zmq_lib_path_var.is_ok() {
let zmq_lib_path = zmq_lib_path_var.unwrap();
println!("cargo:rustc-link-search=native={}", zmq_lib_path);
}
<|fim_suffix|>... | code_fim | medium | {
"lang": "rust",
"repo": "eddyb/zmq-rs",
"path": "/zmq-ffi/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[structopt(
long = "rabbitmq-host",
help = "The used host by RabbitMQ broker",
default_value = "127.0.0.1"
)]
pub rabbitmq_host: String,
#[structopt(
long = "rabbitmq-port",
help = "The listened port by RabbitMQ broker",
default_value = "56... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/pathfinder",
"path": "/pathfinder/src/cli.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/pathfinder path: /pathfinder/src/cli.rs
//! Wrappers for interaction with CLI
//!
//! For more details about using the structopt crate you can find [here](https://github.com/TeXitoi/structopt).
//!
use clap;
use structopt::StructOpt;
/// A structure that defines available arguments a... | code_fim | hard | {
"lang": "rust",
"repo": "yutiansut/pathfinder",
"path": "/pathfinder/src/cli.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>:get_image,
image_controller::create_image_from_multipart,
image_controller::create_image_from_json
)
}<|fim_prefix|>// repo: egsam98/rust-image path: /src/controllers/mod.rs
use rocket::Route;
pub mod image_controller;
pub fn init_r<|fim_middle|>outes() -> Vec<Route> {
routes!... | code_fim | medium | {
"lang": "rust",
"repo": "egsam98/rust-image",
"path": "/src/controllers/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: egsam98/rust-image path: /src/controllers/mod.rs
use rocket::Route;
pub mod image_controller;
pub fn init_r<|fim_suffix|>part,
image_controller::create_image_from_json
)
}<|fim_middle|>outes() -> Vec<Route> {
routes!(
image_controller::get_image,
image_controll... | code_fim | medium | {
"lang": "rust",
"repo": "egsam98/rust-image",
"path": "/src/controllers/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zeyonaut/idealist-rs path: /src/slice.rs
use core::{
cmp::Ordering,
fmt::{
self,
Debug,
},
hash::{
self,
Hash,
},
num::NonZeroUsize,
ops::{
Index,
IndexMut,
},
slice::{
Iter,
IterMut,
SliceIndex,
},
};
use alloc::{
borrow::{
Cow,
ToOwned
},
boxed::Box,
rc::Rc,... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/idealist-rs",
"path": "/src/slice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'b, const N: NonZeroUsize, A, B: PartialEq<A>> PartialEq<IdealArray<A, N>> for &'b IdealSlice<B> where [A; N.get()]: Sized {
#[inline]
fn eq(&self, other: &IdealArray<A, N>) -> bool {self.0 == other.0}
#[inline]
fn ne(&self, other: &IdealArray<A, N>) -> bool {self.0 != other.0}
}
impl<'b, const ... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/idealist-rs",
"path": "/src/slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn ne(&self, other: &IdealSlice<A>) -> bool {self.0 != other.0}
}
impl<A, B: PartialEq<A>> PartialEq<Vec<A>> for &IdealSlice<B> {
#[inline]
fn eq(&self, other: &Vec<A>) -> bool {&self.0 == *other}
#[inline]
fn ne(&self, other: &Vec<A>) -> bool {&self.0 != *other}
}
impl<A, B: PartialEq<A... | code_fim | hard | {
"lang": "rust",
"repo": "zeyonaut/idealist-rs",
"path": "/src/slice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Orycterope/kfs_libfs path: /libfat/src/block_iter.rs
//! Block iterator.
use super::cluster::Cluster;
use super::filesystem::FatFileSystem;
use super::table::FatClusterIter;
use super::{BlockDevice, BlockIndex};
/// Util Iterator used to simplify iteration over block index and cluster.
pub st... | code_fim | hard | {
"lang": "rust",
"repo": "Orycterope/kfs_libfs",
"path": "/libfat/src/block_iter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> BlockIndexClusterIter {
counter: blocks_per_cluster,
cluster_iter: FatClusterIter::new(fs, cluster),
block_index,
last_cluster: None,
}
}
}
impl<'a, T> Iterator for BlockIndexClusterIter<'a, T>
where
T: BlockDevice,
{
type Item =... | code_fim | hard | {
"lang": "rust",
"repo": "Orycterope/kfs_libfs",
"path": "/libfat/src/block_iter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cluster_opt =
if self.counter == self.cluster_iter.fs.boot_record.blocks_per_cluster() as usize {
self.counter = self.block_index.or(Some(BlockIndex(0)))?.0 as usize;
self.block_index = None;
self.last_cluster = self.cluster_iter.next... | code_fim | hard | {
"lang": "rust",
"repo": "Orycterope/kfs_libfs",
"path": "/libfat/src/block_iter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jvff/async-protocol path: /src/map_to_listening_server_transport_error.rs
use std::marker::PhantomData;
use futures::{Poll, Sink, Stream};
use tokio_service::Service;
use super::{listening_server_error::ListeningServerError, server_error::ServerError};
<|fim_suffix|> MapToListeningServ... | code_fim | hard | {
"lang": "rust",
"repo": "jvff/async-protocol",
"path": "/src/map_to_listening_server_transport_error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
self.transports
.poll()
.map_err(ListeningServerError::TransportError)
}
}<|fim_prefix|>// repo: jvff/async-protocol path: /src/map_to_listening_server_transport_error.rs
use std::marker::PhantomData;
u... | code_fim | hard | {
"lang": "rust",
"repo": "jvff/async-protocol",
"path": "/src/map_to_listening_server_transport_error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xarvic/ticktacktoe_ultimate path: /src/ui/field.rs
use crate::data::{Mark, FieldMeta, Slot};
use druid::{Widget, LifeCycle, EventCtx, PaintCtx, LifeCycleCtx, BoxConstraints, Size, LayoutCtx, Event, Env, UpdateCtx, RenderContext, Color, Rect};
use druid::piet::{StrokeStyle, LineCap};
use druid::k... | code_fim | hard | {
"lang": "rust",
"repo": "xarvic/ticktacktoe_ultimate",
"path": "/src/ui/field.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in 0..3_usize {
for y in 0..3_usize {
if let Some(mark) = data[(x, y)] {
self.draw_mark(ctx, (x, y), mark, false);
}
}
}
if let Some(mark) = self.won {
let shape = ctx.size()
... | code_fim | hard | {
"lang": "rust",
"repo": "xarvic/ticktacktoe_ultimate",
"path": "/src/ui/field.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use test::Bencher;
use util::KvGenerator;
#[bench]
fn _bench_check_requirement(_: &mut test::Bencher) {
if let Err(e) = tikv::util::config::check_max_open_fds(4096) {
panic!(
"To run bench, please make sure the maximum number of open file descriptors not \
less than ... | code_fim | medium | {
"lang": "rust",
"repo": "Hoverbear/tikv",
"path": "/benches/benches.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hoverbear/tikv path: /benches/benches.rs
// Copyright 2016 PingCAP, Inc.
//
// 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/L... | code_fim | medium | {
"lang": "rust",
"repo": "Hoverbear/tikv",
"path": "/benches/benches.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use util::KvGenerator;
#[bench]
fn _bench_check_requirement(_: &mut test::Bencher) {
if let Err(e) = tikv::util::config::check_max_open_fds(4096) {
panic!(
"To run bench, please make sure the maximum number of open file descriptors not \
less than 4096: {:?}",
... | code_fim | medium | {
"lang": "rust",
"repo": "Hoverbear/tikv",
"path": "/benches/benches.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_function_with_func_type() {
let target = Target::new(IntSize::I32, "");
let md = th_mod("fn foo(a: fn(int, int) -> int) -> int: 7", &target);
assert!(
*md.functions.get("test::foo").unwrap()
== Function::new(
sig(
"test::f... | code_fim | hard | {
"lang": "rust",
"repo": "GeorgeKT/menhir-lang",
"path": "/src/parser/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GeorgeKT/menhir-lang path: /src/parser/tests.rs
t) == Expression::Literal(Literal::Bool(span(1, 1, 1, 4), true)));
assert!(th_expr("false", &target) == Expression::Literal(Literal::Bool(span(1, 1, 1, 5), false)));
}
#[test]
fn test_binary_ops() {
let target = Target::new(IntSize::I32, "... | code_fim | hard | {
"lang": "rust",
"repo": "GeorgeKT/menhir-lang",
"path": "/src/parser/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GeorgeKT/menhir-lang path: /src/parser/tests.rs
pan(1, 13, 1, 13)),
span(1, 9, 1, 13)
),
span(1, 1, 1, 13),
)
);
}
#[test]
fn test_precedence_4() {
let target = Target::new(IntSize::I32, "");
let e = th_expr("a && b || c && d ", &targe... | code_fim | hard | {
"lang": "rust",
"repo": "GeorgeKT/menhir-lang",
"path": "/src/parser/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StoriqaTeam/gateway path: /src/graphql/microservice/mod.rs
use failure::Error;
use futures::Future;
<|fim_suffix|>pub type ApiFuture<T> = Box<Future<Item = T, Error = Error>>;<|fim_middle|>mod saga;
mod stores;
pub use self::saga::*;
pub use self::stores::*;
mod billing;
pub use self::billing:... | code_fim | hard | {
"lang": "rust",
"repo": "StoriqaTeam/gateway",
"path": "/src/graphql/microservice/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod requests;
pub use self::requests::*;
pub mod responses;
pub use self::responses::*;
pub type ApiFuture<T> = Box<Future<Item = T, Error = Error>>;<|fim_prefix|>// repo: StoriqaTeam/gateway path: /src/graphql/microservice/mod.rs
use failure::Error;
use futures::Future;
<|fim_middle|>mod saga;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "StoriqaTeam/gateway",
"path": "/src/graphql/microservice/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: naamancurtis/rust_data_structures_and_algorithms path: /searching/src/binary_search.rs
use std::cmp::Ordering;
/// Given a sorted array and a value, this function parses the collection and returns the
/// index where that value resides by performing a binary search.
///
/// If the value is not ... | code_fim | hard | {
"lang": "rust",
"repo": "naamancurtis/rust_data_structures_and_algorithms",
"path": "/searching/src/binary_search.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = binary_search(
&vec![
5, 6, 10, 13, 14, 18, 30, 34, 35, 37, 40, 44, 64, 79, 84, 86, 95, 96, 98, 99,
],
100,
);
assert_eq!(result, None);
}
#[test]
fn test_longer_array() {
let result = binary_sear... | code_fim | hard | {
"lang": "rust",
"repo": "naamancurtis/rust_data_structures_and_algorithms",
"path": "/searching/src/binary_search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raphaelcohn/security-keys-rust path: /workspace/usb-storm/src/class_and_protocol/MassStorageProtocol.rs
// This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.... | code_fim | hard | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/usb-storm/src/class_and_protocol/MassStorageProtocol.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Bulk-Only Transport (BBB).
BulkOnly,
/// USB Attached SCSI (UAS) Protocol (UASP) (see <https://www.t10.org/drafts.htm#SCSI3_UAS> and look for 'D2095').
UsbAttachedScsi,
#[allow(missing_docs)]
Unrecognized(u8),
}<|fim_prefix|>// repo: raphaelcohn/security-keys-rust path: /workspace/usb-storm... | code_fim | medium | {
"lang": "rust",
"repo": "raphaelcohn/security-keys-rust",
"path": "/workspace/usb-storm/src/class_and_protocol/MassStorageProtocol.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xA537FD/binance_api_async path: /src/binance_futures/market.rs
/*!
## Implemented functionality
- [x] `Order Book`
- [x] `Recent Trades List`
- [ ] `Old Trades Lookup (MARKET_DATA)`
- [x] `Compressed/Aggregate Trades List`
- [x] `Kline/Candlestick Data`
- [x] `Mark Price`
- [ ] `Get Funding Rat... | code_fim | hard | {
"lang": "rust",
"repo": "0xA537FD/binance_api_async",
"path": "/src/binance_futures/market.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> parameters.insert("symbol".into(), symbol.into());
parameters.insert("interval".into(), interval.into());
// Add three optional parameters
if let Some(lt) = limit.into() {
parameters.insert("limit".into(), format!("{}", lt));
}
if let Some(st) =... | code_fim | hard | {
"lang": "rust",
"repo": "0xA537FD/binance_api_async",
"path": "/src/binance_futures/market.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Moredread/rust-voronoi path: /src/in_circle.rs
D) -> c_double;
fn incircle(pa: *const Point2D, pb: *const Point2D, pc: *const Point2D, pd: *const Point2D) -> c_double;
fn orient3d(pa: *const Point3D, pb: *const Point3D, pc: *const Point3D, pd: *const Point3D) -> c_double;
fn insphere... | code_fim | hard | {
"lang": "rust",
"repo": "Moredread/rust-voronoi",
"path": "/src/in_circle.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t_pos = Triangle::new(p1, p2, p3);
let t_neg = Triangle::new(p2, p1, p3);
assert_eq!(t_pos.locate(&d_inside), Some(TrianglePointLocation::Inside));
assert_eq!(t_pos.locate(&d_outside), Some(TrianglePointLocation::Outside));
assert_eq!(t_pos.locate(&d_on), Some(... | code_fim | hard | {
"lang": "rust",
"repo": "Moredread/rust-voronoi",
"path": "/src/in_circle.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> det_to_orientation(orientation_det)
}
}
impl Orientable for Triangle<Point2D> {
fn orientation(&self) -> Option<Orientation> {
init_predicates();
let orientation_det = unsafe { orient2d(&self.p1, &self.p2, &self.p3) };
det_to_orientation(orientation_det)
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Moredread/rust-voronoi",
"path": "/src/in_circle.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let dy = |y: f32, t: f32| 3.0*t - y;
let step = 0.01;
let mut t = 0.0;
let mut y = y1 as f32;
for _ in 0..100
{
y += step*dy(y, t);
t += step;
}
return y;
}
... | code_fim | medium | {
"lang": "rust",
"repo": "KyussCaesar/shutils",
"path": "/rust/tonyutils/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // solve ode by euler method for example
fn difficult_computation(y1: i32) -> f32
{
let dy = |y: f32, t: f32| 3.0*t - y;
let step = 0.01;
let mut t = 0.0;
let mut y = y1 as f32;
for _ in 0..100
{
... | code_fim | medium | {
"lang": "rust",
"repo": "KyussCaesar/shutils",
"path": "/rust/tonyutils/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KyussCaesar/shutils path: /rust/tonyutils/src/lib.rs
pub mod par_map;
pub use crate::par_map::par_map;
#[cfg(test)]
mod tests
{
use super::*;
use test::Bencher;
#[test]
fn par_map()
{
use super::par_map;
// solve ode by euler method for example
fn d... | code_fim | medium | {
"lang": "rust",
"repo": "KyussCaesar/shutils",
"path": "/rust/tonyutils/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imbrem/stockburn path: /src/util.rs
/*!
Miscellaneous utilities for `stockburn`
*/
use chrono::Duration;
use num::{Float, NumCast};
/// Convert a `chrono::Duration` to a floating point containing the number of nanoseconds
pub fn to_ns<F: Float>(dur: Duration) -> F {
NumCast::from(dur.num_n... | code_fim | hard | {
"lang": "rust",
"repo": "imbrem/stockburn",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_to_s() {
assert_eq!(to_s::<f64>(Duration::minutes(1)), 60.0);
assert_eq!(to_s::<f32>(Duration::days(1)), 60.0 * 60.0 * 24.0);
}
}<|fim_prefix|>// repo: imbrem/stockburn path: /src/util.rs
/*!
Miscellaneous utilities f... | code_fim | hard | {
"lang": "rust",
"repo": "imbrem/stockburn",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // keep the deleted characters so they can be re-appended in the case of an undo command
// NOTE: these characters are in reverse order as they were appended, and will need to
// be reversed before they are re-appended to the buffer.
... | code_fim | hard | {
"lang": "rust",
"repo": "nilslice/simple-text-editor",
"path": "/src/text.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilslice/simple-text-editor path: /src/text.rs
use crate::ops::*;
/// An arbitrary constraint limiting the number of operations that can be executed on a buffer.
const MAX_OPS: usize = 1_000_000;
/// An arbitrary constraint limiting the number of characters that can be deleted from a buffer.
co... | code_fim | hard | {
"lang": "rust",
"repo": "nilslice/simple-text-editor",
"path": "/src/text.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl KeyVal for NodeK2 {
type Key = String;
fn get_key(&self) -> NodeID {
self.1.clone()
}
fn get_key_ref(&self) -> &NodeID {
&self.1
}
noattachment!();
}
impl SettableAttachment for NodeK2 { }
impl Peer for NodeK2 {
type Address = <Node as Peer>::Address;
... | code_fim | medium | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-basetest/src/kvstore.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn get_shadower_w_auth (&self) -> Self::ShadowWAuth {
self.0.get_shadower_w_auth()
}
#[inline]
fn get_shadower_w_msg (&self) -> Self::ShadowWMsg {
self.0.get_shadower_w_msg()
}
}<|fim_prefix|>// repo: cheme/mydht path: /mydht-basetest/src/kvstore.rs
//! te... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-basetest/src/kvstore.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cheme/mydht path: /mydht-basetest/src/kvstore.rs
//! test was move from base (it could not compile in base since its trait just change
//! (bidirectional dependency))
//! TODO seems pretty useless : remove??
use keyval::KeyVal;
use node::{
Node,
NodeID,
};
use peer::{Peer};
use std::cmp::Eq... | code_fim | hard | {
"lang": "rust",
"repo": "cheme/mydht",
"path": "/mydht-basetest/src/kvstore.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michihupf/Arrow path: /arrow-protocol/src/packets/version_specific/play/v453.rs
/// All clientbound `play` packets for protocol versions 453 and above.
pub mod clientbound {
use serde::{Deserialize, Serialize};
<|fim_suffix|> /// The DeclareRecipes packet.
#[derive(Serialize, Deseria... | code_fim | hard | {
"lang": "rust",
"repo": "michihupf/Arrow",
"path": "/arrow-protocol/src/packets/version_specific/play/v453.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::id(protocol_version)
}
fn data_bytes(&self) -> Result<Vec<u8>, crate::packets::error::PacketError> {
let mut ser = Serializer::new();
self.serialize(&mut ser)?;
Ok(ser.get_bytes())
}
}
}<|fim_prefix|>// repo: michihupf/Ar... | code_fim | hard | {
"lang": "rust",
"repo": "michihupf/Arrow",
"path": "/arrow-protocol/src/packets/version_specific/play/v453.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ser = Serializer::new();
self.serialize(&mut ser)?;
Ok(ser.get_bytes())
}
}
}<|fim_prefix|>// repo: michihupf/Arrow path: /arrow-protocol/src/packets/version_specific/play/v453.rs
/// All clientbound `play` packets for protocol versions 453 and ab... | code_fim | hard | {
"lang": "rust",
"repo": "michihupf/Arrow",
"path": "/arrow-protocol/src/packets/version_specific/play/v453.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><'a> Question<'a> {
pub fn new(
address: &'a str,
qtype: Qtype,
qclass: Qclass
) -> Self {
Question { address, qtype, qclass }
}
}<|fim_prefix|>// repo: Leopard2A5/dns path: /src/builder/question.rs
use ::enums::{Qclass, Qtype};
#[derive(Debug, Clone, Eq, Part... | code_fim | medium | {
"lang": "rust",
"repo": "Leopard2A5/dns",
"path": "/src/builder/question.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Leopard2A5/dns path: /src/builder/question.rs
use ::enums::{Qclass, Qtype};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Question<'a> {
pub address: &'a str,
pub qtype: Qtype,
pub qclass: Qclass
}
impl<|fim_suffix|> qclass: Qclass
) -> Self {
Question { address... | code_fim | medium | {
"lang": "rust",
"repo": "Leopard2A5/dns",
"path": "/src/builder/question.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.