text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> #[test]
fn works() {
assert_eq!("42 -9", high_and_low("8 3 -5 42 -1 0 0 -9 4 7 4 -4"));
}
}<|fim_prefix|>// repo: mkt-Do/codewars path: /rust/src/high_and_low.rs
#[allow(dead_code)]
fn high_and_low(numbers: &str) -> String {
let mut nums: Vec<i32> = numbers.split_whitespace().map(... | code_fim | easy | {
"lang": "rust",
"repo": "mkt-Do/codewars",
"path": "/rust/src/high_and_low.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkt-Do/codewars path: /rust/src/high_and_low.rs
#[allow(dead_code)]
fn high_and_low(numbers: &str) -> String {
<|fim_suffix|> assert_eq!("42 -9", high_and_low("8 3 -5 42 -1 0 0 -9 4 7 4 -4"));
}
}<|fim_middle|> let mut nums: Vec<i32> = numbers.split_whitespace().map(|c| c.parse().u... | code_fim | hard | {
"lang": "rust",
"repo": "mkt-Do/codewars",
"path": "/rust/src/high_and_low.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ports = ports.collect::<Vec<_>>().join(" ");
println!("{}", ports);
}<|fim_prefix|>// repo: timothyandrew/sp path: /src/main.rs
use std::{process, env};
fn main() {
let ports = env::args().skip(1);
if ports.len() < 1 {
eprintln!("Need at least one argument!");
proce... | code_fim | medium | {
"lang": "rust",
"repo": "timothyandrew/sp",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ports = ports.map(|port| {
format!("-L {}:localhost:{}", port, port)
});
let ports = ports.collect::<Vec<_>>().join(" ");
println!("{}", ports);
}<|fim_prefix|>// repo: timothyandrew/sp path: /src/main.rs
use std::{process, env};
fn main() {
<|fim_middle|> let ports = en... | code_fim | medium | {
"lang": "rust",
"repo": "timothyandrew/sp",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: timothyandrew/sp path: /src/main.rs
use std::{process, env};
fn main() {
<|fim_suffix|> let ports = ports.map(|port| {
format!("-L {}:localhost:{}", port, port)
});
let ports = ports.collect::<Vec<_>>().join(" ");
println!("{}", ports);
}<|fim_middle|> let ports = en... | code_fim | medium | {
"lang": "rust",
"repo": "timothyandrew/sp",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let val = interpret(String::from("-10"));
assert_eq!(val,-10.0);
}
#[test]
fn test_simple_evaluation() {
let val = interpret(String::from("(+ 2 2)"));
assert_eq!(val, 4.0);
}
#[test]
fn test_multiple_parens() {
let val = interpret(String::from("(* (+ 7 6) (+ 2 3) (* 9 9))"));
ass... | code_fim | hard | {
"lang": "rust",
"repo": "JackBmann/scheme_interpreter",
"path": "/tests/test_interpreter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_with_multiple_variable_string() {
let env = String::from("(define (x (+ 3 2))) (define (y 6))");
let expr = String::from("(* x y)");
let val = interpret_with_environment_string(expr, env);
assert_eq!(val, 30.0);
}
#[test]
fn test_float_addition() {
let val = interpre... | code_fim | hard | {
"lang": "rust",
"repo": "JackBmann/scheme_interpreter",
"path": "/tests/test_interpreter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JackBmann/scheme_interpreter path: /tests/test_interpreter.rs
#[cfg(test)]
extern crate updated_scheme;
pub use updated_scheme::interpreter::*;
pub use updated_scheme::environment::*;
// use std::collections::HashMap;
#[test]
fn test_single_number() {
let val = interpret(String::from("88")... | code_fim | hard | {
"lang": "rust",
"repo": "JackBmann/scheme_interpreter",
"path": "/tests/test_interpreter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{:?}", self);
}
}
impl Button {
pub fn new(width: u32, height: u32, label: &str) -> Box<Button> {
Box::new(Button { width, height, label: String::from(label)})
}
}<|fim_prefix|>// repo: ztporter/playground path: /rust-lang/gui/src/lib.rs
pub trait Draw {
fn draw... | code_fim | medium | {
"lang": "rust",
"repo": "ztporter/playground",
"path": "/rust-lang/gui/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ztporter/playground path: /rust-lang/gui/src/lib.rs
pub trait Draw {
fn draw(&self);
}
pub struct Screen {
pub components: Vec<Box<dyn Draw>>,
}
impl Screen {
pub fn new() -> Box<Screen> {
Box::new(Screen { components: vec![] })
}
<|fim_suffix|>impl Button {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "ztporter/playground",
"path": "/rust-lang/gui/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ActionValidator
{
pub fn validate_action(game_state: &GameState, action:&GameAction) -> bool
{
true
}
}<|fim_prefix|>// repo: sysnet-ai/dice-legions path: /Server/dl-server/src/game/systems/action_validator.rs
use crate::game::components::*;
use crate::game::resources::*;
u<|fim... | code_fim | medium | {
"lang": "rust",
"repo": "sysnet-ai/dice-legions",
"path": "/Server/dl-server/src/game/systems/action_validator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sysnet-ai/dice-legions path: /Server/dl-server/src/game/systems/action_validator.rs
use crate::game::components::*;
use crate::game::resources::*;
u<|fim_suffix|>ameState, action:&GameAction) -> bool
{
true
}
}<|fim_middle|>se crate::game::systems::GameState;
pub struct ActionV... | code_fim | medium | {
"lang": "rust",
"repo": "sysnet-ai/dice-legions",
"path": "/Server/dl-server/src/game/systems/action_validator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Computes the derivatives of interpolation functions with respect to the reference coordinates
///
/// # Output
///
/// * `deriv` -- derivatives of the interpolation function with respect to
/// the reference coordinates ksi, evaluated at ksi (nnode,geo_ndim)
///
/// #... | code_fim | hard | {
"lang": "rust",
"repo": "cpmech/gemlab",
"path": "/src/shapes/tri3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[rustfmt::skip]
pub const NODE_REFERENCE_COORDS: [[f64; Tri3::GEO_NDIM]; Tri3::NNODE] = [
[0.0, 0.0],
[1.0, 0.0],
[0.0, 1.0],
];
/// Computes the interpolation functions
///
/// # Output
///
/// * `interp` -- interpolation function evaluated at ksi... | code_fim | hard | {
"lang": "rust",
"repo": "cpmech/gemlab",
"path": "/src/shapes/tri3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpmech/gemlab path: /src/shapes/tri3.rs
use russell_lab::{Matrix, Vector};
/// Defines a triangle with 3 nodes (linear edges)
///
/// 
///
/// # Local IDs of nodes
///
/// ```text
/// s
/// |
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "cpmech/gemlab",
"path": "/src/shapes/tri3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FormatBranch {
pub fn from(br: CocoBranch) -> FormatBranch {
FormatBranch {
name: br.name,
first_commit_str: format_unix_time(br.first_commit_date),
last_commit_str: format_unix_time(br.last_commit_date),
first_commit_date: br.first_commit_d... | code_fim | hard | {
"lang": "rust",
"repo": "chalme/coco",
"path": "/src/app/analysis/git_analysis/format_branch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chalme/coco path: /src/app/analysis/git_analysis/format_branch.rs
use serde::{Deserialize, Serialize};
use crate::domain::git::CocoBranch;
use crate::infrastructure::time_format::format_unix_time;
<|fim_suffix|>impl FormatBranch {
pub fn from(br: CocoBranch) -> FormatBranch {
Forma... | code_fim | hard | {
"lang": "rust",
"repo": "chalme/coco",
"path": "/src/app/analysis/git_analysis/format_branch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: padenot/fdn-reverb path: /src/onepolelowpass.rs
use std::f32::consts::PI;
pub struct OnePoleLowPass {
a0: f32,
b1: f32,
z1: f32,
sample_rate: f32
}
impl OnePoleLowPass {
pub fn new(freq: f32, sample_rate: f32) -><|fim_suffix|> self.a0 = 1.0 - self.b1;
}
pub fn p... | code_fim | hard | {
"lang": "rust",
"repo": "padenot/fdn-reverb",
"path": "/src/onepolelowpass.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return lp;
}
pub fn set_frequency(&mut self, freq: f32) {
let normalized_freq = freq / self.sample_rate;
self.b1 = (-2.0 * PI * normalized_freq).exp();
self.a0 = 1.0 - self.b1;
}
pub fn process(&mut self, input: f32, output: &mut f32) {
self.z1 = inpu... | code_fim | medium | {
"lang": "rust",
"repo": "padenot/fdn-reverb",
"path": "/src/onepolelowpass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.a0 = 1.0 - self.b1;
}
pub fn process(&mut self, input: f32, output: &mut f32) {
self.z1 = input * self.a0 + self.z1 * self.b1;
*output = self.z1;
}
}<|fim_prefix|>// repo: padenot/fdn-reverb path: /src/onepolelowpass.rs
use std::f32::consts::PI;
pub struct OnePoleLo... | code_fim | hard | {
"lang": "rust",
"repo": "padenot/fdn-reverb",
"path": "/src/onepolelowpass.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if it is a push stream.
fn decode_new_stream(
&mut self,
conn: &mut Connection,
stream_type: u64,
stream_id: u64,
) -> Res<bool> {
match stream_type {
HTTP3_UNI_STREAM_TYPE_CONTROL => {
self.control_stream_rem... | code_fim | hard | {
"lang": "rust",
"repo": "Hanaasagi/neqo",
"path": "/neqo-http3/src/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hanaasagi/neqo path: /neqo-http3/src/connection.rs
bleOutput`.
pub fn handle_stream_readable(
&mut self,
conn: &mut Connection,
stream_id: u64,
) -> Res<HandleReadableOutput> {
qtrace!([self], "Readable stream {}.", stream_id);
let label = ::neqo_... | code_fim | hard | {
"lang": "rust",
"repo": "Hanaasagi/neqo",
"path": "/neqo-http3/src/connection.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(
clippy::vec_init_then_push,
unknown_lints,
renamed_and_removed_lints,
clippy::unknown_clippy_lints
)]
fn recv_control(&mut self, conn: &mut Connection, stream_id: u64) -> Res<HandleReadableOutput> {
assert!(self.control_stream_remote.is_recv_str... | code_fim | hard | {
"lang": "rust",
"repo": "Hanaasagi/neqo",
"path": "/neqo-http3/src/connection.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enlyze/rumqtt path: /rumqttd/src/locallink.rs
use log::{trace, warn};
use crate::mqttbytes::v4::*;
use crate::mqttbytes::*;
use crate::rumqttlog::{
Connection, ConnectionAck, Data, Event, Notification, Receiver, RecvError, RecvTimeoutError,
SendError, Sender,
};
use crate::Id;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "enlyze/rumqtt",
"path": "/rumqttd/src/locallink.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle_router_response(&mut self, message: Notification) -> Result<Option<Data>, LinkError> {
match message {
Notification::ConnectionAck(_) => Ok(None),
Notification::Message(_) => {
unreachable!("Local links are always clean");
}
... | code_fim | hard | {
"lang": "rust",
"repo": "enlyze/rumqtt",
"path": "/rumqttd/src/locallink.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn visit_dataset(
&self,
&mut T,
dataset: &'v DataSet) {}
fn visit_project(
&self,
context: &mut T,
child: &'v Operator,
exprs: &Vec<Operator>) {
walk_op(self, context, child);
}
fn visit_filter(
&self,
context:
&mu... | code_fim | hard | {
"lang": "rust",
"repo": "jihoonson/tokamak",
"path": "/src/algebra/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jihoonson/tokamak path: /src/algebra/lib.rs
//!
//! Plan
//!
extern crate rustc_serialize;
extern crate common;
use std::fmt;
use std::result::Result;
use rustc_serialize::{Encoder, Decodable};
use common::dataset::DataSet;
pub enum AlgebraError
{
EmptyStack,
MismatchedStackType,
No... | code_fim | hard | {
"lang": "rust",
"repo": "jihoonson/tokamak",
"path": "/src/algebra/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tokens = params
.iter()
.map(|&(ref param, ref value)| LenientTokenizer::tokenize(param, value))
.collect::<Result<Vec<_>, _>>()?;
let result = ethabi::encode(&tokens);
Ok(hex::encode(result))
}
}
impl fmt::Display for Contract {
f... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/jade-signer-rpc",
"path": "/src/contract/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(hex::encode(result))
}
}
impl fmt::Display for Contract {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.inner)
}
}
#[cfg(test)]
mod tests {
use super::*;
use ethabi::{Function, Param, ParamType};
#[test]
fn should_display_co... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/jade-signer-rpc",
"path": "/src/contract/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etclabscore/jade-signer-rpc path: /src/contract/mod.rs
//! # Contract
#[allow(dead_code)]
mod error;
pub use self::error::Error;
use ethabi::param_type::{ParamType, Reader};
use ethabi::token::{LenientTokenizer, Token, Tokenizer};
use ethabi::Function;
use hex;
use serde::Deserialize;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/jade-signer-rpc",
"path": "/src/contract/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shijuleon/rocker path: /src/rocker.rs
use crate::container::Container;
use crate::image::Image;
use crate::registry::Registry;
pub struct Rocker {
// replicating Docker's path structure
home_path: String,
containers_path: String,
images_path: String,
registry: Registry,
}
impl Rocker... | code_fim | medium | {
"lang": "rust",
"repo": "shijuleon/rocker",
"path": "/src/rocker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let container = Container::new(&image);
container.init().await;
}
pub fn info(&self) {}
}<|fim_prefix|>// repo: shijuleon/rocker path: /src/rocker.rs
use crate::container::Container;
use crate::image::Image;
use crate::registry::Registry;
pub struct Rocker {
// replicating Docker's path s... | code_fim | hard | {
"lang": "rust",
"repo": "shijuleon/rocker",
"path": "/src/rocker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn validate_command(command: &SlashCommandData) -> Result<(), &'static str> {
if !valid_team(&command.team_id) {
return Err("invalid team");
}
if !valid_command(&command.command) {
return Err("invalid command");
}
Ok(())
}
fn valid_team(_team: &str) -> bool {
t... | code_fim | hard | {
"lang": "rust",
"repo": "ant1441/slack-token",
"path": "/src/slack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn send_help() -> SlackResponse {
SlackResponse {
response_type: Ephemeral,
text: None,
attachments: vec![SlackAttachment {
text: "
Token manager. Use `/token get` to take hold of the token.
\
Other commands... | code_fim | hard | {
"lang": "rust",
"repo": "ant1441/slack-token",
"path": "/src/slack.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ant1441/slack-token path: /src/slack.rs
use token::User;
pub type TeamId = String;
pub type ChannelId = String;
pub type UserId = String;
pub type UserName = String;
#[derive(FromForm)]
pub struct SlashCommandData {
pub token: String,
pub team_id: TeamId,
pub team_domain: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "ant1441/slack-token",
"path": "/src/slack.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DuoSRX/gredin path: /src/creature.rs
use std::cell::RefCell;
use std::rc::Rc;
use movement::{MovementComponent, RandomMovementComponent, PlayerMovementComponent};
use point::Point;
use game::{Game, GameInfo};
<|fim_suffix|>impl Clone for Creature {
fn clone(&self) -> Creature {
Cre... | code_fim | hard | {
"lang": "rust",
"repo": "DuoSRX/gredin",
"path": "/src/creature.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn tick(&self, game: &Game) -> Creature {
let location = self.movement_component.tick(self.location, &game.world);
Creature { location: location, .. self.clone() }
}
}
impl Clone for Creature {
fn clone(&self) -> Creature {
Creature {
location: self.loc... | code_fim | hard | {
"lang": "rust",
"repo": "DuoSRX/gredin",
"path": "/src/creature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Clone for Creature {
fn clone(&self) -> Creature {
Creature {
location: self.location,
glyph: self.glyph,
is_player: self.is_player,
movement_component: self.movement_component.box_clone(),
}
}
}<|fim_prefix|>// repo: DuoSRX/gred... | code_fim | hard | {
"lang": "rust",
"repo": "DuoSRX/gredin",
"path": "/src/creature.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vtavernier/hyperion.rs path: /src/servers.rs
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use tokio::{
net::{TcpListener, TcpStream},
task::JoinHandle,
};
use crate::{global::Global, models::ServerConfig};
pub mod boblight;
pub mod flat;
pub mod json;
pub mod proto;
<|fim_suff... | code_fim | hard | {
"lang": "rust",
"repo": "vtavernier/hyperion.rs",
"path": "/src/servers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(error) = result {
error!(error = %error, "{} server terminated", name);
}
});
Ok(ServerHandle { join_handle })
}
impl Drop for ServerHandle {
fn drop(&mut self) {
self.join_handle.abort();
}
}<|fim_prefix|>// repo: vtavernier/hyperion.rs pa... | code_fim | hard | {
"lang": "rust",
"repo": "vtavernier/hyperion.rs",
"path": "/src/servers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn bind<T, E, F, H>(
name: &'static str,
options: T,
global: Global,
handle_client: H,
) -> std::io::Result<ServerHandle>
where
T: ServerConfig + Send + 'static,
F: futures::Future<Output = Result<(), E>> + Send + 'static,
E: From<std::io::Error> + std::fmt::Display +... | code_fim | hard | {
"lang": "rust",
"repo": "vtavernier/hyperion.rs",
"path": "/src/servers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[clap(short = 'c', long = "confidence", default_value = "95")]
/// Specify desired confidence level for Student's T analysis. Possible
/// values are 80, 90, 95, 98, 99 and 99.5%
pub confidence_level: Confidence,
#[clap(short = 'd', long = "delimit", default_value = " \t")]
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "mdsherry/ministat",
"path": "/src/args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdsherry/ministat path: /src/args.rs
use crate::err::*;
use crate::t_table::T_CONFIDENCES;
use clap::Parser;
use std::path::PathBuf;
use std::str::FromStr;
#[derive(Parser, Debug)]
#[clap(name = "ministat", about = "A Rust port of the ministat utility")]
pub struct Opt {
#[clap(short = 'n',... | code_fim | hard | {
"lang": "rust",
"repo": "mdsherry/ministat",
"path": "/src/args.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[clap(short = 't', long = "stack")]
/// Stack datapoints in the graph instead of overlapping them
pub stack: bool,
#[clap(short = 'C', long = "column", default_value = "1")]
/// Specify which column of data to use. By default the first column in the
/// input file(s) are used.
... | code_fim | hard | {
"lang": "rust",
"repo": "mdsherry/ministat",
"path": "/src/args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use derived_key::DerivedKey;<|fim_prefix|>// repo: gakonst/lighthouse path: /crypto/eth2_key_derivation/src/lib.rs
//! Provides path-based hierarchical BLS key derivation, as specified by
//! [EIP-2333](https://eips.ethereum.org/EIPS/eip-2333).
<|fim_middle|>mod derived_key;
mod lamport_secret_key;
... | code_fim | medium | {
"lang": "rust",
"repo": "gakonst/lighthouse",
"path": "/crypto/eth2_key_derivation/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gakonst/lighthouse path: /crypto/eth2_key_derivation/src/lib.rs
//! Provides path-based hierarchical BLS key derivation, as specified by
//! [EIP-2333](https://eips.ethereum.org/EIPS/eip-2333).
<|fim_suffix|>pub use derived_key::DerivedKey;<|fim_middle|>mod derived_key;
mod lamport_secret_key;
... | code_fim | medium | {
"lang": "rust",
"repo": "gakonst/lighthouse",
"path": "/crypto/eth2_key_derivation/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mhowto/bolt-rust path: /src/meta.rs
use bucket::_Bucket;
use types::{pgid_t, txid_t};
#[repr(C, packed)]
pu<|fim_suffix|>ze: u32,
pub flags: u32,
pub root: _Bucket,
pub freelist: pgid_t,
pub pgid: pgid_t,
pub txid: txid_t,
pub checksum: u64,
}<|fim_middle|>b struct Meta ... | code_fim | medium | {
"lang": "rust",
"repo": "mhowto/bolt-rust",
"path": "/src/meta.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>d_t,
pub pgid: pgid_t,
pub txid: txid_t,
pub checksum: u64,
}<|fim_prefix|>// repo: mhowto/bolt-rust path: /src/meta.rs
use bucket::_Bucket;
use types::{pgid_t, txid_t};
#[repr(C, packed)]
pub struct Meta {
pub magic: u32,
pub version: u32,
pub page_si<|fim_middle|>ze: u32,
p... | code_fim | medium | {
"lang": "rust",
"repo": "mhowto/bolt-rust",
"path": "/src/meta.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bjorn3/rust path: /src/tools/clippy/tests/compile-test.rs
#![feature(test)] // compiletest_rs requires this attribute
#![feature(lazy_cell)]
#![feature(is_sorted)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![warn(rust_2018_idioms, unused_lifetimes)]
use compiletest::{status_emitt... | code_fim | hard | {
"lang": "rust",
"repo": "bjorn3/rust",
"path": "/src/tools/clippy/tests/compile-test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ui_test::run_tests_generic(
config,
|path| test_filter(path) && path.extension() == Some("rs".as_ref()),
|config, path| {
let mut config = config.clone();
config
.program
.envs
.push(("CLIPPY_CONF_DIR".into... | code_fim | hard | {
"lang": "rust",
"repo": "bjorn3/rust",
"path": "/src/tools/clippy/tests/compile-test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lsmacedo/equacoes_diofantinas path: /src/equacao_diofantina.rs
use std::fmt;
use std::cmp::min;
pub struct Solucao<'a> {
pub x: i32,
pub y: i32,
eq: &'a EquacaoDiofantina
}
impl<'a> fmt::Display for Solucao<'a> {
/*
* Permitindo imprimir Solucao em formato A.x + B.y = C
... | code_fim | hard | {
"lang": "rust",
"repo": "lsmacedo/equacoes_diofantinas",
"path": "/src/equacao_diofantina.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Definindo valor inicial de x */
if !somente_solucoes_positivas {
if a > 0 {
x = min(-1 * a.abs(), -1 * b.abs());
} else {
x = 0
}
} else {
x = 1;
}
/* Iterando por todos os v... | code_fim | hard | {
"lang": "rust",
"repo": "lsmacedo/equacoes_diofantinas",
"path": "/src/equacao_diofantina.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Iterando por todos os valores possíveis de x e verificando se
algum satisfaz a equação */
while x * a <= c.abs() {
let temp = c - (a * x);
if temp % b == 0 && (temp / b > 0 || !somente_solucoes_positivas) {
let y:i32 = temp / b;
... | code_fim | hard | {
"lang": "rust",
"repo": "lsmacedo/equacoes_diofantinas",
"path": "/src/equacao_diofantina.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shages/liberty-parse path: /examples/get_area.rs
use liberty_parse::parse_lib;
fn main() {
let lib_str = r#"
library(sample) {
cell(AND2) {
area: 1;
pin(o) {
timing() {
cell_rise(delay_temp_3x3) {
index_1 ("0.5, 1.0, 1.5");... | code_fim | hard | {
"lang": "rust",
"repo": "shages/liberty-parse",
"path": "/examples/get_area.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let values = lib
.cells
.get("AND2")
.and_then(|c| c.pins.get("o"))
.and_then(|p| p.groups.iter().find(|g| g.type_ == "timing"))
.and_then(|t| t.groups.iter().find(|g| g.type_ == "cell_rise"))
.and_then(|rise| rise.complex_att... | code_fim | hard | {
"lang": "rust",
"repo": "shages/liberty-parse",
"path": "/examples/get_area.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_target/spec/wasm32_unknown_emscripten.rs
use super::wasm32_base;
use super::{LinkArgs, LinkerFlavor, Target, TargetOptions, PanicStrategy};
pub fn target() -> Result<Target, String> {
let mut post_link_args = LinkArgs::new();
post_link... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_target/spec/wasm32_unknown_emscripten.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .. wasm32_base::options()
};
Ok(Target {
llvm_target: "wasm32-unknown-emscripten".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_target/spec/wasm32_unknown_emscripten.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ly platform
// functionality, and a .wasm file.
exe_suffix: ".js".to_string(),
linker: None,
linker_is_gnu: true,
is_like_emscripten: true,
// FIXME(tlively): Emscripten supports unwinding, but we would have to pass
// -enable-emscripten-cxx-exceptio... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_target/spec/wasm32_unknown_emscripten.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn authorization_header(&self) -> Result<HeaderMap, failure::Error> {
let mut headers = HeaderMap::new();
let key_id = HeaderValue::from_str(&self.api_key_id)?;
let secret = HeaderValue::from_str(&self.api_key)?;
headers.insert("X-NCP-APIGW-API-KEY-ID", key_id);
... | code_fim | hard | {
"lang": "rust",
"repo": "rabyss/rust-naver",
"path": "/src/cred.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rabyss/rust-naver path: /src/cred.rs
use reqwest::header::{HeaderMap, HeaderValue};
#[derive(Clone)]
pub struct NaverCred {
pub api_key_id: String,
pub api_key: String
}
<|fim_suffix|> pub fn authorization_header(&self) -> Result<HeaderMap, failure::Error> {
let mut headers ... | code_fim | hard | {
"lang": "rust",
"repo": "rabyss/rust-naver",
"path": "/src/cred.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = Some(());
if x.is_some() {
x.unwrap(); // unnecessary
} else {
x.unwrap(); // will panic
}
if x.is_none() {
x.unwrap(); // will panic
} else {
x.unwrap(); // unnecessary
}
m!(x);
let mut x: Result<(), ()> = Ok(());
if x.is_ok(... | code_fim | medium | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/tests/ui/checked_unwrap/simple_conditionals.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rabisg0/rust-clippy path: /tests/ui/checked_unwrap/simple_conditionals.rs
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
#![allow(clippy::if_same_then_else)]
macro_rules! m {
($a:expr) => {
if $a.is_some() {
$a.unwrap(); // unnecessary
}
};
}
... | code_fim | medium | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/tests/ui/checked_unwrap/simple_conditionals.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rokob/aoc-2019 path: /11/advent/src/main.rs
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
enum Dir {
Up,
Left,
Right,
Down,
}
impl Dir {
fn turn(&self, val: isize) -> Dir {
use Dir::*;
match (self, val) {
(Up... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/11/advent/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut min_x = 0;
let mut min_y = 0;
let mut max_x = 0;
let mut max_y = 0;
for panel in white.iter() {
if panel.0 > max_x {
max_x = panel.0;
}
if panel.1 > max_y {
max_y = panel.1;
}
if panel.0 < min_x {
min_x... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/11/advent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
fn read(prog: &mut Vec<isize>, ip: usize, rb: isize, mode: isize, offset: usize) -> isize {
let i = index(prog, ip, rb, mode, offset);
prog[i]
}
// (new_ip, did_halt, _did_input, output, new_rb)
fn step(
prog: &mut Vec<isize>,
ip: usize,
in_: isize,
rb: isize,
) -> (usiz... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/11/advent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/jsondoclint/src/json_find.rs
use std::fmt::Write;
use serde::Serialize;
use serde_json::Value;
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub enum SelectorPart {
Field(String),
Index(usize),
}
pub type Selector = Vec<SelectorPart>;
pub fn to_jso... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/jsondoclint/src/json_find.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn find_selector(haystack: &Value, needle: &Value) -> Vec<Selector> {
let mut result = Vec::new();
let mut sel = Selector::new();
find_selector_recursive(haystack, needle, &mut result, &mut sel);
result
}
fn find_selector_recursive(
haystack: &Value,
needle: &Value,
result... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/jsondoclint/src/json_find.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Ensure the PHY is not in reset. PE2, active low.
periph.GPIOE.moder.modify(|_r, w| w.moder2().output());
periph.GPIOE.otyper.modify(|_r, w| w.ot2().push_pull());
periph.GPIOE.bsrr.write(|w| w.bs2().set());
// Hold the MAC in reset while we configure it to operate in RMII mode.
... | code_fim | hard | {
"lang": "rust",
"repo": "achan1989/f4ether",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set up the pins as required for the following RMII and SMI signals:
// ETH_RMII_REF_CLK -- PA1
// ETH_MDIO -- PA2
// ETH_RMII_CRS_DV -- PA7
// ETH_RMII_TX_EN -- PB11
// ETH_RMII_TXD[1:0] -- PB13 and PB12
// ETH_MDC -- PC1
// ETH_RMII_RXD[1:0] -- PC5 and PC4
//
//... | code_fim | hard | {
"lang": "rust",
"repo": "achan1989/f4ether",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: achan1989/f4ether path: /src/main.rs
#![no_std]
#![no_main]
// pick a panicking behavior
// extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
// extern crate panic_abort; // requires nightly
// extern crate panic_itm; // logs messages over ITM; requires... | code_fim | hard | {
"lang": "rust",
"repo": "achan1989/f4ether",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("p2: {:?}", p2);
println!("p1: {:?}", p1);
p1 = Parent(2, Child(21), Child(22));
println!("p1: {:?}", p1);
}<|fim_prefix|>// repo: koukyo1994/rust-sample path: /copy_semantics/src/main.rs
#[derive(Debug, Clone, Copy)]
struct Parent(usize, Child, Child);
#[derive(Debug, Clone, C... | code_fim | medium | {
"lang": "rust",
"repo": "koukyo1994/rust-sample",
"path": "/copy_semantics/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: koukyo1994/rust-sample path: /copy_semantics/src/main.rs
#[derive(Debug, Clone, Copy)]
struct Parent(usize, Child, Child);
<|fim_suffix|> p1 = Parent(2, Child(21), Child(22));
println!("p1: {:?}", p1);
}<|fim_middle|>#[derive(Debug, Clone, Copy)]
struct Child(usize);
fn main() {
let... | code_fim | medium | {
"lang": "rust",
"repo": "koukyo1994/rust-sample",
"path": "/copy_semantics/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MacTuitui/nannou path: /examples/offline/quadtree.rs
// Simple QuadTree
// Alexis Andre (@mactuitui)
use nannou::prelude::*;
pub struct QuadTree {
indices: [usize; 4],
num: usize,
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub children: Option<[Box<Qua... | code_fim | hard | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/examples/offline/quadtree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return true;
}
pub fn get_elements<T: WithPos>(
&self,
elements: &[T],
x: f32,
y: f32,
dist: f32,
) -> Vec<usize> {
let mut result: Vec<usize> = Vec::new();
//are we intersecting the rect
if self.intersects(x, y, dist) {... | code_fim | hard | {
"lang": "rust",
"repo": "MacTuitui/nannou",
"path": "/examples/offline/quadtree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klaxit/heroku_rs path: /examples/src/account_examples.rs
extern crate heroku_rs;
use super::print_response;
use heroku_rs::endpoints::account;
use heroku_rs::framework::apiclient::HerokuApiClient;
pub fn run<ApiClientType: HerokuApiClient>(api_client: &ApiClientType) {
get_account(api_clien... | code_fim | hard | {
"lang": "rust",
"repo": "klaxit/heroku_rs",
"path": "/examples/src/account_examples.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Get heroku account app transfer.
fn get_account_transfer<ApiClientType: HerokuApiClient>(api_client: &ApiClientType) {
let response = api_client.request(&account::AppTransferDetails::new("transfer_id"));
print_response(response);
}
// Get heroku account app transfers.
fn get_account_transfers<... | code_fim | hard | {
"lang": "rust",
"repo": "klaxit/heroku_rs",
"path": "/examples/src/account_examples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let account_id = "USER_ID_OR_EMAIL";
let account_patch = &account::UserAccountUpdate::new(account_id)
.beta(false)
.allow_tracking(true)
.name("yet-another-name")
.build();
let response = api_client.request(account_patch);
print_response(response);
}
// Get... | code_fim | hard | {
"lang": "rust",
"repo": "klaxit/heroku_rs",
"path": "/examples/src/account_examples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hem6/atcoder-rs path: /abc174/src/bin/e.rs
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
input! {
n: usize,
k: u64,
a: [u64;n],
}
<|fim_suffix|>fn ab... | code_fim | hard | {
"lang": "rust",
"repo": "hem6/atcoder-rs",
"path": "/abc174/src/bin/e.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn abs(a: u64, b: u64) -> u64 {
if a > b {
a - b
} else {
b - a
}
}<|fim_prefix|>// repo: hem6/atcoder-rs path: /abc174/src/bin/e.rs
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::... | code_fim | hard | {
"lang": "rust",
"repo": "hem6/atcoder-rs",
"path": "/abc174/src/bin/e.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yecdev/yolk path: /zebra-consensus/src/chain/tests.rs
//! Tests for chain verification
use std::{sync::Arc, time::Duration};
use color_eyre::eyre::Report;
use once_cell::sync::Lazy;
use tower::{layer::Layer, timeout::TimeoutLayer, Service, ServiceBuilder};
use zebra_chain::{
block::{self,... | code_fim | hard | {
"lang": "rust",
"repo": "yecdev/yolk",
"path": "/zebra-consensus/src/chain/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let network = Network::Mainnet;
// Test that the chain::init function works. Most of the other tests use
// init_from_verifiers.
let chain_verifier = super::init(
config.clone(),
network,
ServiceBuilder::new()
.buffer(1)
.service(zs::init(zs... | code_fim | hard | {
"lang": "rust",
"repo": "yecdev/yolk",
"path": "/zebra-consensus/src/chain/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for cert in certs.keys {
self.keys.insert(cert.kid.clone(), cert);
}
Ok(true)
}
}
impl Client {
pub fn new() -> Client {
#[cfg(feature = "with-hypertls")]
let ssl = HttpsConnector::new();
#[cfg(feature = "with-openssl")]
let ssl... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/google-signin-rs",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use jsonwebtoken::{Algorithm, DecodingKey, Validation};
for (_, cert) in cached_certs.get_range(&unverified_header.kid)? {
// Check each certificate
let mut validation = Validation::new(Algorithm::RS256);
validation.set_audience(&self.audiences);
... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/google-signin-rs",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyyerd/google-signin-rs path: /src/client.rs
use hyper::{
body::Buf,
client::{Client as HyperClient, HttpConnector},
};
#[cfg(feature = "with-openssl")]
use hyper_openssl::HttpsConnector;
#[cfg(feature = "with-hypertls")]
use hyper_tls::HttpsConnector;
use serde;
use serde_json;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/google-signin-rs",
"path": "/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.settings.analysis {
self.analysis.node_count += 1;
}
}
}
}
/// Returns `true` when estimated memory usage is exceeded, `false` otherwise.
///
/// Returns `false` when analysis is deactivated.
pub fn memory... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/max_tree",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> root.children.push((a.clone(), Node {
max: utility,
data,
children: vec![],
}));
if self.settings.analysis {
self.analysis.node_count += 1;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/max_tree",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bvssvni/max_tree path: /src/lib.rs
or final reward has special terminal semantics.
//! For more information, see "Terminal semantics" below.
//!
//! ### Discounting action depth
//!
//! By default, more steps to complete the goal is not penalized.
//!
//! Subtracting a tiny amount of utility pro... | code_fim | hard | {
"lang": "rust",
"repo": "bvssvni/max_tree",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: depp/ultrafxr path: /rust/src/signal/graph.rs
use super::program::{Function, Parameters};
use std::convert::TryFrom;
use std::error::Error;
use std::fmt::Debug;
use std::io;
/// Result of instantiating a node.
pub type NodeResult = Result<Box<dyn Function>, Box<dyn Error>>;
/// A node in the a... | code_fim | hard | {
"lang": "rust",
"repo": "depp/ultrafxr",
"path": "/rust/src/signal/graph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Description of an audio processing graph.
pub struct Graph {
nodes: Vec<Box<dyn Node>>,
}
impl Graph {
/// Create a new, empty graph.
pub fn new() -> Self {
Graph { nodes: Vec::new() }
}
/// Add a new node to the graph.
pub fn add(&mut self, node: Box<dyn Node>) -> Si... | code_fim | hard | {
"lang": "rust",
"repo": "depp/ultrafxr",
"path": "/rust/src/signal/graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
let old_population = {
let mut new_population = Vec::with_capacity(self.current_population.len());
std::mem::swap(&mut self.current_population, &mut new_population);
new_population
};
for mut person in ol... | code_fim | hard | {
"lang": "rust",
"repo": "SV-97/COVID-19",
"path": "/covid/src/sim.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct Simulation {
pub simulated_days: usize,
pub infected_people: Vec<Person>,
pub dead_people: Vec<Person>,
pub cured_people: Vec<Person>,
pub current_population: Vec<Person>,
pub running_death_tolls: Vec<usize>,
pub infections_over_time: Vec<usize>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "SV-97/COVID-19",
"path": "/covid/src/sim.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SV-97/COVID-19 path: /covid/src/sim.rs
#![allow(dead_code)]
use rand::prelude::*;
use std::collections::HashMap;
use std::sync::mpsc::channel;
static AGE_X: [f32; 11] = [
0., 0.00944196, 0.05640964, 0.13170318, 0.1596659, 0.19101804, 0.2360489, 0.42779325,
0.71710447, 0.78356131, 1.,
];... | code_fim | hard | {
"lang": "rust",
"repo": "SV-97/COVID-19",
"path": "/covid/src/sim.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Protobuf<Vec<u8>> for Signature {}
impl TryFrom<Vec<u8>> for Signature {
type Error = Error;
fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
if value.is_empty() {
return Ok(Self::default());
}
if value.len() != ED25519_SIGNATURE_SIZE {
... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanLorimer/tendermint-rs",
"path": "/tendermint/src/signature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JonathanLorimer/tendermint-rs path: /tendermint/src/signature.rs
//! Cryptographic (a.k.a. digital) signatures
pub use ed25519::{Signature as Ed25519Signature, SIGNATURE_LENGTH as ED25519_SIGNATURE_SIZE};
pub use signature::{Signer, Verifier};
#[cfg(feature = "secp256k1")]
pub use k256::ecdsa:... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanLorimer/tendermint-rs",
"path": "/tendermint/src/signature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Signature::Ed25519(sig) => sig.as_ref(),
Signature::None => &[],
}
}
}
impl From<Ed25519Signature> for Signature {
fn from(pk: Ed25519Signature) -> Signature {
Signature::Ed25519(pk)
}
}
/// Digital signature algorithms
#[derive(Co... | code_fim | hard | {
"lang": "rust",
"repo": "JonathanLorimer/tendermint-rs",
"path": "/tendermint/src/signature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn allocate(&mut self, im: &dyn BitmapImage) -> Result<Sprite<T>, OutOfTextureSpace> {
let (width, height) = im.image_dimensions();
let reserve_width = width + 2;
let reserve_height = height + 2;
if reserve_width > self.side || reserve_height > self.side {
... | code_fim | hard | {
"lang": "rust",
"repo": "tizee/provok",
"path": "/src/bitmaps/atlas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tex_coords = self.texture.to_texture_coords(rect);
self.left += reserve_width;
self.tallest = self.tallest.max(reserve_height);
Ok(Sprite { texture: Rc::clone(&self.texture), tex_coords, width, height })
}
}
pub struct Sprite<T>
where
T: Texture2d,
{
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "tizee/provok",
"path": "/src/bitmaps/atlas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tizee/provok path: /src/bitmaps/atlas.rs
use crate::bitmaps::{BitmapImage, Texture2d, TextureRect};
use crate::utils::{Point, Rect, Size};
use anyhow::{ensure, Result};
use std::rc::Rc;
use thiserror::*;
#[derive(Debug, Error)]
#[error("Texture Size exceeded, need {}", size)]
pub struct OutOfTe... | code_fim | hard | {
"lang": "rust",
"repo": "tizee/provok",
"path": "/src/bitmaps/atlas.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h573/dlybos1/cfgr.rs
#[doc = "Register `CFGR` reader"]
pub type R = crate::R<CFGR_SPEC>;
#[doc = "Register `CFGR` writer"]
pub type W = crate::W<CFGR_SPEC>;
#[doc = "Field `SEL` reader - SEL"]
pub type SEL_R = crate::FieldReader;
#[doc = "Field... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h573/dlybos1/cfgr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct CFGR_SPEC;
impl crate::RegisterSpec for CFGR_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`cfgr::R`](R) reader structure"]
impl crate::R... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32h5/src/stm32h573/dlybos1/cfgr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.