text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: orbitrc/altair path: /src/transpiler.rs
use regex::Regex;
#[derive(Debug)]
enum DeriveType {
Object,
View,
PaintedView,
}
#[derive(Debug)]
struct Module {
name: String,
version: String,
}
#[derive(Debug)]
struct Class {
name: String,
derive: DeriveType,
}
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "orbitrc/altair",
"path": "/src/transpiler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ppjet6/zeerust path: /src/examples/mod.rs
/// Calculates fizzbuzz (assembly)
pub const FIZZBUZZ_ASM: &str = include_str!("fizzbuzz.asm");
/// Calculates fizzbuzz (machine code)
pub const FIZZBUZZ_BIN: &[u8] = include_bytes!("fizzbuzz.bin");
<|fim_suffix|>/// Count down from 9 to 1 (assembly)
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Ppjet6/zeerust",
"path": "/src/examples/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const EXAMPLES: &[Example] = &[
Example {
name: "fizzbuzz",
assembly: FIZZBUZZ_ASM,
binary: FIZZBUZZ_BIN,
},
Example {
name: "hello zeerust",
assembly: HELLO_ZEERUST_ASM,
binary: HELLO_ZEERUST_BIN,
},
Example {
name: "hello wo... | code_fim | hard | {
"lang": "rust",
"repo": "Ppjet6/zeerust",
"path": "/src/examples/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filecoin-project/filecoin-ffi path: /rust/src/lib.rs
#![deny(clippy::all)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::upper_case_acronyms)]
pub mod bls;
pub mod fvm;
pub mod proofs;
pub mod util;
// Generates the headers.
// Run `HEADER_DIR=<dir> cargo test --locked build_headers -... | code_fim | medium | {
"lang": "rust",
"repo": "filecoin-project/filecoin-ffi",
"path": "/rust/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let header_dir = env::var("HEADER_DIR").expect("Missing \"HEADER_DIR\"");
let out_dir = Path::new(&header_dir);
let hdr_out = out_dir.join("filcrypto.h");
safer_ffi::headers::builder()
.to_file(&hdr_out)?
.generate()?;
Ok(())
}<|fim_prefix|>// repo: filecoin-project/f... | code_fim | hard | {
"lang": "rust",
"repo": "filecoin-project/filecoin-ffi",
"path": "/rust/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod cache;
pub mod dep_graph;
mod error;
pub mod ich;
pub mod query;
mod values;
pub use error::HandleCycleError;
pub use error::LayoutOfDepth;
pub use error::QueryOverflow;
pub use values::Value;
fluent_messages! { "../messages.ftl" }<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_quer... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/compiler/rustc_query_system/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /compiler/rustc_query_system/src/lib.rs
#![feature(assert_matches)]
#![feature(core_intrinsics)]
#![feature(hash_raw_entry)]
#![feature(min_specialization)]
#![feature(extern_types)]
#![feature(let_chains)]
#![allow(rustc::potential_query_instability)]
#ing values to bounds.
///
/// `NAN` panics in debug, unspecified behavior in release.
pub trait Clamp<T = Self> {
/// The resulting type after clamping.
type Output;
/// Clamps `self` above `min`.
fn clamp_min(se... | code_fim | hard | {
"lang": "rust",
"repo": "truchi/lay",
"path": "/src/grid/num/clamp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> doc!("```\n"
"# use lay::*;\n"
"assert!(Clamp::clamp(0.0_" s!($T) ", 5_" s!($T) ", 15_" s!($T) ") == 5.0_" s!($T) ");\n"
"assert!(Clamp::clamp(10.0_" s!($T) ", 5_" s!($T) ", 15_" s!($T) ") == 10.0_" s!($T) ");\n"
"assert!(Clamp::c... | code_fim | hard | {
"lang": "rust",
"repo": "truchi/lay",
"path": "/src/grid/num/clamp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut array = [0, 1, 2, 3];
let x = array[0..].as_mut_ptr() as *mut [u32; 2];
let y = array[1..].as_mut_ptr() as *mut [u32; 2];
unsafe {
assert_eq!([0, 1], x.read());
assert_eq!([1, 2], y.read());
//tmp = x;
//x = y;
//y = x;
x.swap(y);
... | code_fim | hard | {
"lang": "rust",
"repo": "18616378431/myCode",
"path": "/rust/test13-14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 18616378431/myCode path: /rust/test13-14/src/main.rs
//replace swap
fn main() {
let mut v : Vec<i32> = vec![1, 2];
let v_ptr : *mut i32 = v.as_mut_ptr();
unsafe {
let old_v = v_ptr.replace(5);
assert_eq!(1, old_v);
assert_eq!([5, 2], &v[..]);
}
<|fim_suff... | code_fim | hard | {
"lang": "rust",
"repo": "18616378431/myCode",
"path": "/rust/test13-14/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flmmkch/puizcloud path: /src/state.rs
use super::Config;
use std::{env, path};
#[derive(Debug, Clone)]
pub struct PuizcloudState {
config: Config,
full_data_path: path::PathBuf,
}
impl PuizcloudState {
pub fn <|fim_suffix|>rrent directory")
.join(config.data_path())... | code_fim | medium | {
"lang": "rust",
"repo": "flmmkch/puizcloud",
"path": "/src/state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rrent directory")
.join(config.data_path())
} else {
config.data_path().to_owned()
};
PuizcloudState {
config,
full_data_path,
}
}
pub fn config(&self) -> &Config {
&self.config
}
pub fn full_data_p... | code_fim | medium | {
"lang": "rust",
"repo": "flmmkch/puizcloud",
"path": "/src/state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Move to the next statement
current_statement = cdr;
}
// Prepare the frame for execution
frame.allocate_for_bindings(&bindings);
let (nil_monad_value, nil_monad_type) = (NIL.clone(), wrap_nil());
// Run the setup actions
for actions in compiled_actions.iter() ... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/safas",
"path": "/src/exec/eval.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Logicalshift/safas path: /src/exec/eval.rs
use super::frame::*;
use super::frame_monad::*;
use crate::meta::*;
use crate::bind::*;
///
/// Creates a monad that wraps the 'nil' value
///
fn wrap_nil() -> MonadType {
let wrap = WrapFlatMap(NIL.clone());
let wrap_flat_map = S... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/safas",
"path": "/src/exec/eval.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Project-StarDust/old-spatial-sdk-rs path: /spatial_codegen/src/parser/schema_file.rs
use crate::ast::Component;
use crate::ast::Enum;
use crate::ast::SchemaFile;
use crate::ast::Type;
use crate::parser::component::parse_component;
use crate::parser::package_name::parse_package_name;
use crate::p... | code_fim | hard | {
"lang": "rust",
"repo": "Project-StarDust/old-spatial-sdk-rs",
"path": "/spatial_codegen/src/parser/schema_file.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(
parse_models<Vec<SchemaModel>>,
separated_list!(multispace0, parse_model)
);
named!(
pub parse_schema<SchemaFileBuilder>,
do_parse!(
package_name_parts: parse_package_name
>> models: delimited!(multispace0, parse_models, multispace0)
>> (models
... | code_fim | hard | {
"lang": "rust",
"repo": "Project-StarDust/old-spatial-sdk-rs",
"path": "/spatial_codegen/src/parser/schema_file.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//The longest function definition that specifies all the references in the signature must have the same lifetime, 'a
fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str {
if s1.len() > s2.len() {
s1
} else {
s2
}
}
//The function signature now says that for some lifetime 'a, t... | code_fim | hard | {
"lang": "rust",
"repo": "arosspope/learn-rust",
"path": "/types-traits-lifetimes/lifetimes/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arosspope/learn-rust path: /types-traits-lifetimes/lifetimes/src/main.rs
//Every reference in Rust has a `lifetime`, which is the scope for which that reference is valid
//Most of the time lifetimes are implicit and inferred, just like most of the time types are inferred
//There are cases where ... | code_fim | hard | {
"lang": "rust",
"repo": "arosspope/learn-rust",
"path": "/types-traits-lifetimes/lifetimes/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: helgoboss/wish-tree path: /tests/integration_test.rs
use globset::Glob;
use std::fs;
use std::io::{Error, Read};
use std::path::Path;
use wish_tree::*;
<|fim_suffix|> // Given
let dir = dir! {
"dist" => dir! {
"README.md" => "README.md",
"sources" => "test... | code_fim | medium | {
"lang": "rust",
"repo": "helgoboss/wish-tree",
"path": "/tests/integration_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Given
let dir = dir! {
"dist" => dir! {
"README.md" => "README.md",
"sources" => "tests/foo/b",
"doc" => dir("tests/foo").include("**/*.txt"),
"empty-dir" => dir!(),
"empty-file" => text("")
},
"notes.txt" => te... | code_fim | medium | {
"lang": "rust",
"repo": "helgoboss/wish-tree",
"path": "/tests/integration_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The annotation to request inlining.
pub const INLINE: &'static str = "inline";<|fim_prefix|>// repo: dflemstr/lalrpop path: /lalrpop-snap/src/grammar/consts.rs
/// Recognized associated type for the token location
pub const LOCATION: &'static str = "Location";
/// Recognized associated type for cust... | code_fim | medium | {
"lang": "rust",
"repo": "dflemstr/lalrpop",
"path": "/lalrpop-snap/src/grammar/consts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dflemstr/lalrpop path: /lalrpop-snap/src/grammar/consts.rs
/// Recognized associated type for the token location
pub const LOCATION: &'static str = "Location";
<|fim_suffix|>/// The lifetime parameter injected when we do not have an external token enum
pub const INPUT_LIFETIME: &'static str = "... | code_fim | medium | {
"lang": "rust",
"repo": "dflemstr/lalrpop",
"path": "/lalrpop-snap/src/grammar/consts.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The parameter injected when we do not have an external token enum
pub const INPUT_PARAMETER: &'static str = "input";
/// The annotation to request inlining.
pub const INLINE: &'static str = "inline";<|fim_prefix|>// repo: dflemstr/lalrpop path: /lalrpop-snap/src/grammar/consts.rs
/// Recognized asso... | code_fim | medium | {
"lang": "rust",
"repo": "dflemstr/lalrpop",
"path": "/lalrpop-snap/src/grammar/consts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesDeVore/PathfinderNPC path: /feat_predictor/src/feat_map.rs
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::collections::HashMap;
use std::error::Error;
<|fim_suffix|> for line in reader.lines(){
let split = line.unwrap().split(",").map(String::f... | code_fim | hard | {
"lang": "rust",
"repo": "JamesDeVore/PathfinderNPC",
"path": "/feat_predictor/src/feat_map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let reader = BufReader::new(file);
for line in reader.lines(){
// println!("{:?}",&line );
let split = line.unwrap().split(",").map(String::from).collect::<Vec<String>>();
all_feats.insert(split[1].to_string().trim().to_lowercase(),split[0].to_string());
}
// prin... | code_fim | medium | {
"lang": "rust",
"repo": "JamesDeVore/PathfinderNPC",
"path": "/feat_predictor/src/feat_map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = File::open("./src/data/feats.txt").unwrap();
let reader = BufReader::new(file);
for line in reader.lines(){
// println!("{:?}",&line );
let split = line.unwrap().split(",").map(String::from).collect::<Vec<String>>();
all_feats.insert(split[1].to_string().t... | code_fim | medium | {
"lang": "rust",
"repo": "JamesDeVore/PathfinderNPC",
"path": "/feat_predictor/src/feat_map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use actix_web::test::config;
use super::AttestationConfig;
#[test]
fn test_load() -> () {
let config = AttestationConfig::new();
println!("{:?}",config.get_table("debug"));
}
}<|fim_prefix|>// repo: quick-meduo/uAttestation path: /src/config/... | code_fim | hard | {
"lang": "rust",
"repo": "quick-meduo/uAttestation",
"path": "/src/config/Configurations.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quick-meduo/uAttestation path: /src/config/Configurations.rs
extern crate config;
use std::collections::HashMap;
use config::ConfigError;
use glob::glob;
pub use config::{Config,File,Value};
pub use serde::de::{Deserialize};
#[warn(dead_code)]
pub type ConfigResult<T> = std::result::Result<T... | code_fim | medium | {
"lang": "rust",
"repo": "quick-meduo/uAttestation",
"path": "/src/config/Configurations.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq! {
rune! { i64 =>
pub fn main() { match None { None => 1, _ => 2 } }
},
1,
};
assert_eq! {
rune! { i64 =>
pub fn main() { match None { Some("some") => 1, _ => 2 } }
},
2,
};
}<|fim_prefix|>// repo: Roba199... | code_fim | medium | {
"lang": "rust",
"repo": "Roba1993/rune",
"path": "/tests/tests/vm_option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roba1993/rune path: /tests/tests/vm_option.rs
use rune_tests::*;
#[test]
fn test_option() {
assert_eq! {
rune! { i64 =>
pub fn main() { match Some("some") { Some("some") => 1, _ => 2 } }
},
1,
};
assert_eq! {
rune! { i64 =>
p... | code_fim | medium | {
"lang": "rust",
"repo": "Roba1993/rune",
"path": "/tests/tests/vm_option.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq! {
rune! { i64 =>
pub fn main() { match None { Some("some") => 1, _ => 2 } }
},
2,
};
}<|fim_prefix|>// repo: Roba1993/rune path: /tests/tests/vm_option.rs
use rune_tests::*;
#[test]
fn test_option() {
assert_eq! {
rune! { i64 =>
... | code_fim | medium | {
"lang": "rust",
"repo": "Roba1993/rune",
"path": "/tests/tests/vm_option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: killerswan/rust-tools path: /old/str_and_vec/string_work/str_old.rs
use std;
fn char_to_byte_offset (&&ss: str, char_position: uint) -> uint {
<|fim_suffix|> let s = "ประเทศไทย中华Việt Nam";
let i = 0u;
while i < str::byte_len(s) {
let {ch, next} = str::char_range_at(s, i);
... | code_fim | hard | {
"lang": "rust",
"repo": "killerswan/rust-tools",
"path": "/old/str_and_vec/string_work/str_old.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while cursor_char < char_position {
let sz = str::utf8_char_width(ss[cursor_byte]);
assert sz > 0u;
cursor_byte += sz;
cursor_char += 1u;
}
assert cursor_char <= str::char_len(ss);
assert cursor_byte <= str::byte_len(ss);
ret cursor_byte;
}
#[test]
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "killerswan/rust-tools",
"path": "/old/str_and_vec/string_work/str_old.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: first-rust-competition/nt4-mvp path: /server/src/client.rs
use crate::entry::Topic;
use crate::net::NTSocket;
use crate::server::ServerMessage;
use async_std::sync::Sender;
use async_std::task;
use futures::prelude::*;
use futures::stream::{SplitSink, SplitStream};
use log::*;
use proto::prelude... | code_fim | hard | {
"lang": "rust",
"repo": "first-rust-competition/nt4-mvp",
"path": "/server/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ConnectedClient {
pub fn new(sock: NTSocket, server_tx: Sender<ServerMessage>, cid: u32) -> ConnectedClient {
let (net_tx, net_rx) = sock.split();
task::spawn(client_loop(net_rx, server_tx, cid));
ConnectedClient {
net_tx,
subs: HashMap::new(),
... | code_fim | hard | {
"lang": "rust",
"repo": "first-rust-competition/nt4-mvp",
"path": "/server/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>TYPECEVT1_R::new(((self.bits >> 14) & 1) != 0)
}
#[doc = "Bit 15 - TYPECEVT2"]
#[inline(always)]
pub fn typecevt2(&self) -> TYPECEVT2_R {
TYPECEVT2_R::new(((self.bits >> 15) & 1) != 0)
}
#[doc = "Bits 16:17 - TYPEC_VSTATE_CC1"]
#[inline(always)]
pub fn typec_vstate_... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/ucpd1/sr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>) -> HRSTSENT_R {
HRSTSENT_R::new(((self.bits >> 5) & 1) != 0)
}
#[doc = "Bit 6 - TXUND"]
#[inline(always)]
pub fn txund(&self) -> TXUND_R {
TXUND_R::new(((self.bits >> 6) & 1) != 0)
}
#[doc = "Bit 8 - RXNE"]
#[inline(always)]
pub fn rxne(&self) -> RXNE_R {
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/ucpd1/sr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/ucpd1/sr.rs
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Field `TXIS` reader - TXIS"]
pub type TXIS_R = crate::BitReader;
#[doc = "Field `TXMSGDISC` reader - TXMSGDISC"]
pub type TXMSGDISC_R = crate::BitReader;
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/ucpd1/sr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> worker::collect_metrics(&settings, message_sender, command_receiver);
ui::render(&settings, message_receiver, command_sender).await;
}<|fim_prefix|>// repo: felipe-fg/http-storm path: /src/main.rs
use crate::settings::Settings;
use crate::worker::{WorkerCommand, WorkerMessage};
use clap::{load_y... | code_fim | hard | {
"lang": "rust",
"repo": "felipe-fg/http-storm",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felipe-fg/http-storm path: /src/main.rs
use crate::settings::Settings;
use crate::worker::{WorkerCommand, WorkerMessage};
use clap::{load_yaml, App, AppSettings};
use tokio::sync::{mpsc, watch};
<|fim_suffix|> let matches = App::from_yaml(cli)
.setting(AppSettings::DeriveDisplayOrder... | code_fim | medium | {
"lang": "rust",
"repo": "felipe-fg/http-storm",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamesstidard/Deflection-Droids path: /src/components/token.rs
use amethyst::{
ecs::prelude::{Component, DenseVecStorage},
};
<|fim_suffix|>impl Component for Token {
type Storage = DenseVecStorage<Self>;
}<|fim_middle|>
#[derive(Debug)]
pub struct Token {
}
| code_fim | easy | {
"lang": "rust",
"repo": "jamesstidard/Deflection-Droids",
"path": "/src/components/token.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Token {
type Storage = DenseVecStorage<Self>;
}<|fim_prefix|>// repo: jamesstidard/Deflection-Droids path: /src/components/token.rs
use amethyst::{
ecs::prelude::{Component, DenseVecStorage},
};
<|fim_middle|>
#[derive(Debug)]
pub struct Token {
}
| code_fim | easy | {
"lang": "rust",
"repo": "jamesstidard/Deflection-Droids",
"path": "/src/components/token.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TechnoElf/invader path: /src/physics.rs
use serde::{Serialize, Deserialize};
use specs::*;
use specs::storage::ComponentEvent;
use nalgebra::{Isometry2, Vector2, Point};
use nphysics2d::object::*;
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::DefaultJointCon... | code_fim | hard | {
"lang": "rust",
"repo": "TechnoElf/invader",
"path": "/src/physics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> System<'a> for PhysicsSys {
type SystemData = (Write<'a, PhysicsRes>,
WriteStorage<'a, TransformCom>,
ReadStorage<'a, RigidBodyCom>,
ReadStorage<'a, ColliderCom>);
fn run(&mut self, data: Self::SystemData) {
let (mut physics, mut transforms, rigid_bodies, ... | code_fim | hard | {
"lang": "rust",
"repo": "TechnoElf/invader",
"path": "/src/physics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BroderickCarlin/embedded-graphics path: /embedded-graphics/src/style/text_style.rs
use crate::{fonts::Font, pixelcolor::PixelColor};
/// Style properties for text.
///
/// A `TextStyle` can be applied to a [`Text`] object to define how the text is drawn.
///
/// Because `TextStyle` has the [`no... | code_fim | hard | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/embedded-graphics/src/style/text_style.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets the text color.
pub fn text_color(mut self, text_color: C) -> Self {
self.style.text_color = Some(text_color);
self
}
/// Sets the background color.
pub fn background_color(mut self, background_color: C) -> Self {
self.style.background_color = Some(ba... | code_fim | hard | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/embedded-graphics/src/style/text_style.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self
}
/// Builds the text style.
pub fn build(self) -> TextStyle<C, F> {
self.style
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{fonts::Font12x16, pixelcolor::BinaryColor};
#[test]
fn builder_default() {
assert_eq!(
TextStyl... | code_fim | hard | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/embedded-graphics/src/style/text_style.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kdy1/rweb path: /macros/src/route/param.rs
use crate::route::EqStr;
use pmutil::{q, ToTokensExt};
use proc_macro2::TokenStream;
use std::collections::HashSet;
use syn::{
parse_quote::parse, punctuated::Punctuated, Attribute, Expr, FnArg, Pat, Path, Signature,
Token, Type,
};
/// Returns... | code_fim | hard | {
"lang": "rust",
"repo": "kdy1/rweb",
"path": "/macros/src/route/param.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let attr = pat.attrs.get(0).cloned().unwrap();
pat.attrs = vec![];
if attr.path.is_ident("form") {
expr = q!(Vars { expr }, { expr.and(rweb::filters::body::form()) }).parse()
} else if attr.path.is_ide... | code_fim | hard | {
"lang": "rust",
"repo": "kdy1/rweb",
"path": "/macros/src/route/param.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frostu8/macrotk path: /macrotk/src/lib.rs
#[doc(inline)]
pub use macrotk_core::*;
#[doc(inline)]
pub use<|fim_suffix|>pub fn from_meta_derive() {
let t = trybuild::TestCases::new();
t.pass("tests/from_meta_derive.rs");
}
}<|fim_middle|> macrotk_derive::*;
#[cfg(test)]
mod te... | code_fim | medium | {
"lang": "rust",
"repo": "frostu8/macrotk",
"path": "/macrotk/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn from_meta_derive() {
let t = trybuild::TestCases::new();
t.pass("tests/from_meta_derive.rs");
}
}<|fim_prefix|>// repo: frostu8/macrotk path: /macrotk/src/lib.rs
#[doc(inline)]
pub use macrotk_core::*;
#[doc(inline)]
pub use<|fim_middle|> macrotk_derive::*;
#[cfg(test)]
mod te... | code_fim | medium | {
"lang": "rust",
"repo": "frostu8/macrotk",
"path": "/macrotk/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_clients(&self) -> Receiver<ClientConnection> {
let (sen, rec): (Sender<ClientConnection>, Receiver<ClientConnection>) = mpsc::channel();
let addr = self.addr;
std::thread::spawn(move || match Self::handle_requests(addr, &sen) {
Err(e) => sen.send(Err(e)).unw... | code_fim | hard | {
"lang": "rust",
"repo": "TrueDoctor/DiscoBot",
"path": "/webhogg/game_server/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrueDoctor/DiscoBot path: /webhogg/game_server/src/server.rs
use crate::backend_connection::BackendConnection;
use crate::lobby::Lobby;
use std::net::{SocketAddr, TcpStream, ToSocketAddrs};
use std::sync::{
mpsc,
mpsc::{Receiver, Sender},
};
use websocket::{
client::sync::Client,
... | code_fim | hard | {
"lang": "rust",
"repo": "TrueDoctor/DiscoBot",
"path": "/webhogg/game_server/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcon/jackvm-rs path: /vm/tests/integration_math.rs
push local 0
add
push constant 3
push local 0
add
pop pointer 1
push that 0
push constant 0
call Math.multiply 2
pop temp 0
... | code_fim | hard | {
"lang": "rust",
"repo": "jcon/jackvm-rs",
"path": "/vm/tests/integration_math.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> push argument 1
push constant 0
eq
if-goto IF_TRUE0
goto IF_FALSE0
label IF_TRUE0
push constant 3
call Sys.error 1
pop temp 0
label IF_FALSE0
push argument 0
push... | code_fim | hard | {
"lang": "rust",
"repo": "jcon/jackvm-rs",
"path": "/vm/tests/integration_math.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcon/jackvm-rs path: /vm/tests/integration_math.rs
tant 128
push constant 32767
neg
push constant 1
sub
call Math.divide 2
pop temp 0
pop pointer 1
push temp 0
pop that 0
push ... | code_fim | hard | {
"lang": "rust",
"repo": "jcon/jackvm-rs",
"path": "/vm/tests/integration_math.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match SONNETS.lines().nth(len - tlen) {
Some(line) => append(&filename, line),
None => truncate(&filename),
}
}
fn count_lines(filename: &str) -> usize {
let file = File::open(filename).expect("failed to open file");
let reader = BufReader::new(file);
reader.lines().co... | code_fim | hard | {
"lang": "rust",
"repo": "czak/doodle",
"path": "/tools/src/bin/scribble.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = OpenOptions::new()
.append(true)
.open(filename)
.expect("failed to open file for append");
file.write(line.as_bytes()).unwrap();
file.write(b"<br>\n").unwrap();
}<|fim_prefix|>// repo: czak/doodle path: /tools/src/bin/scribble.rs
use std::fs::File;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "czak/doodle",
"path": "/tools/src/bin/scribble.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: czak/doodle path: /tools/src/bin/scribble.rs
use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::BufReader;
const SONNETS: &str = include_str!("../../data/sonnets.txt");
const TEMPLATE: &str = include_str!("../../data/template.html");
fn main() {
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "czak/doodle",
"path": "/tools/src/bin/scribble.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref user) = user {
request
.guard::<&State<RateLimiter<u64>>>()
.await
.expect("no RateLimiter in request state")
.apply_to_request(&user.id.0, request)
... | code_fim | hard | {
"lang": "rust",
"repo": "Atte/discord-bot",
"path": "/src/webui/util/session_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user
})
.await
.as_ref()
.or_forward(()));
Outcome::Success(SessionUser(user))
}
}<|fim_prefix|>// repo: Atte/discord-bot path: /src/webui/util/session_user.rs
use super::RateLimiter;
use derive_more::Deref;
use rocket::{
ou... | code_fim | hard | {
"lang": "rust",
"repo": "Atte/discord-bot",
"path": "/src/webui/util/session_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atte/discord-bot path: /src/webui/util/session_user.rs
use super::RateLimiter;
use derive_more::Deref;
use rocket::{
outcome::{try_outcome, IntoOutcome},
request::{FromRequest, Outcome, Request},
State,
};
use serenity::model::user::CurrentUser;
<|fim_suffix|> async fn from_reque... | code_fim | hard | {
"lang": "rust",
"repo": "Atte/discord-bot",
"path": "/src/webui/util/session_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antoinemadec/test path: /rust/rust-lang.org/ownership/src/main.rs
// https://doc.rust-lang.org/stable/book/ch04-01-what-is-ownership.html
fn main() {
{
let s = String::from("coucou"); // alocate memory on the heap
println!("{}", s);
}
// deallocate memory at the end ... | code_fim | hard | {
"lang": "rust",
"repo": "antoinemadec/test",
"path": "/rust/rust-lang.org/ownership/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn gives_ownership() -> String {
let some_string = String::from("coucou");
some_string
}
fn makes_copy(some_int: i32) {
println!("{}", some_int)
}
fn takes_ownership(some_string: String) {
println!("{}", some_string);
}<|fim_prefix|>// repo: antoinemadec/test path: /rust/rust-lang.org/o... | code_fim | hard | {
"lang": "rust",
"repo": "antoinemadec/test",
"path": "/rust/rust-lang.org/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn takes_and_gives_back(some_string: String) -> String {
some_string
}
fn gives_ownership() -> String {
let some_string = String::from("coucou");
some_string
}
fn makes_copy(some_int: i32) {
println!("{}", some_int)
}
fn takes_ownership(some_string: String) {
println!("{}", some_str... | code_fim | hard | {
"lang": "rust",
"repo": "antoinemadec/test",
"path": "/rust/rust-lang.org/ownership/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nonis-b/itsy-bitsy-scheme path: /src/builtins.rs
use evalitem::EvalItem;
use environment::Environment;
pub fn evaluate_builtin(name: &String, list: &Vec<EvalItem>, env: &mut Box<Environment>) -> EvalItem {
match name.as_ref() {
"+" => {
let mut sum = 0u32;
fo... | code_fim | hard | {
"lang": "rust",
"repo": "nonis-b/itsy-bitsy-scheme",
"path": "/src/builtins.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _ => panic!("Shouldn't happen!"),
}
}
}
return EvalItem::Value(sum.to_string());
},
_ => {
panic!("Unknown builtin name!");
},
}
}<|fim_prefix|>// repo: nonis-b/itsy-bitsy-scheme path: /src/builti... | code_fim | hard | {
"lang": "rust",
"repo": "nonis-b/itsy-bitsy-scheme",
"path": "/src/builtins.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: royswale/leetcode path: /src/bin/search-insert-position.rs
fn main() {
// assert_eq!(2, Solution::search_insert(vec![1, 3, 5, 6], 5));
// assert_eq!(1, Solution::search_insert(vec![1, 3, 5, 6], 2));
// assert_eq!(4, Solution::search_insert(vec![1, 3, 5, 6], 7));
// assert_eq!(0, ... | code_fim | medium | {
"lang": "rust",
"repo": "royswale/leetcode",
"path": "/src/bin/search-insert-position.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn search_insert(nums: Vec<i32>, target: i32) -> i32 {
let (mut start, mut end) = (0, nums.len() - 1);
while start < end {
let middle = (start + end) >> 1;
if nums[middle] == target {
break;
} else if nums[middle] ... | code_fim | medium | {
"lang": "rust",
"repo": "royswale/leetcode",
"path": "/src/bin/search-insert-position.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn peer_join(&self, id: Uuid, addr: SocketAddr) {
let peer = Peer::new_alive(id, addr);
let mut peers = await!(self.peers.lock());
peers.insert(peer.addr(), peer);
await!(self.add_broadcast(Broadcast::Joined(id, addr)));
}
pub async fn add_broadcast(&... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/clique-old",
"path": "/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LucioFranco/clique-old path: /src/state.rs
use {
crate::{
acks::Acks,
broadcasts::{Broadcast, Broadcasts},
peer::Peer,
},
futures::lock::Mutex,
indexmap::IndexMap,
log::{debug, info},
rand::{seq::IteratorRandom, thread_rng},
std::{net::SocketAd... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/clique-old",
"path": "/src/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn update_state(&self, state: NodeState) {
let mut current_state = await!(self.state.lock());
std::mem::replace(&mut *current_state, state);
}
pub async fn peers_sync(&self, incoming_peers: Vec<(SocketAddr, Uuid)>) {
let mut peers = await!(self.peers.lock());... | code_fim | hard | {
"lang": "rust",
"repo": "LucioFranco/clique-old",
"path": "/src/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ben-PH/AOS_public path: /projects/aos/rustlibs/allocator/src/lib.rs
#![no_std]
#![feature(alloc_error_handler)]
use core::ffi::c_void;
extern crate panic;
#[alloc_error_handler]
fn default_handler(layout: core::alloc::Layout) -> ! {
panic!("memory allocation of {} bytes failed", layout.siz... | code_fim | medium | {
"lang": "rust",
"repo": "Ben-PH/AOS_public",
"path": "/projects/aos/rustlibs/allocator/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // given that usize as isize can panic due to usize::MAX > isize::MAX
// we must ensure that we return a malloc failure, rather than panicing when
// layout.size() gives a isize > usize::MAX. We need to do this, as the
// provided libc API asks for size_t (as opposed to usi... | code_fim | hard | {
"lang": "rust",
"repo": "Ben-PH/AOS_public",
"path": "/projects/aos/rustlibs/allocator/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hpatjens/enum_text_augment path: /tests/02-override.rs
use enum_text_augment::EnumTextAugmentation;
#[derive(EnumTextAugmentation)]
enum TheEnum {
#[enum_text_augmentation("First")]
FirstEnumValue,
#[enum_text_augmentation("Second")]
SecondEnumValue,
#[enum_text_augmentation... | code_fim | medium | {
"lang": "rust",
"repo": "hpatjens/enum_text_augment",
"path": "/tests/02-override.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(TheEnum::FirstEnumValue.augmented_text(), "First");
assert_eq!(TheEnum::SecondEnumValue.augmented_text(), "Second");
assert_eq!(TheEnum::ThirdEnumValue.augmented_text(), "Third");
}<|fim_prefix|>// repo: hpatjens/enum_text_augment path: /tests/02-override.rs
use enum_text_augment::... | code_fim | medium | {
"lang": "rust",
"repo": "hpatjens/enum_text_augment",
"path": "/tests/02-override.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_function() {
assert_eq!(TheEnum::FirstEnumValue.augmented_text(), "First");
assert_eq!(TheEnum::SecondEnumValue.augmented_text(), "Second");
assert_eq!(TheEnum::ThirdEnumValue.augmented_text(), "Third");
}<|fim_prefix|>// repo: hpatjens/enum_text_augment path: /tests/02-overri... | code_fim | medium | {
"lang": "rust",
"repo": "hpatjens/enum_text_augment",
"path": "/tests/02-override.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut line = String::new();
let mut linenumber = 0;
let mut data_started = false;
while self.read_next_line(&mut linenumber, &mut line) {
println!("{}: {}", linenumber, line);
let mut chars = line.chars();
match chars.next() {
Some(c) => {
if !data_started {
match c {
... | code_fim | hard | {
"lang": "rust",
"repo": "aschoerk/tests_rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aschoerk/tests_rs path: /src/main.rs
extern crate core;
extern crate memstream;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::Lines;
use std::path::Path;
use core::iter::Enumerate;
use std::fmt::Debug;
fn print<T: Debug>(x: T) {
println!("{:?}",x);
}
str... | code_fim | hard | {
"lang": "rust",
"repo": "aschoerk/tests_rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OpenTrustGroup/fuchsia path: /src/media/sessions/src/log_error.rs
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use std::fmt::Debug;
#[macro_export]
macro_rules! trylog {
(... | code_fim | hard | {
"lang": "rust",
"repo": "OpenTrustGroup/fuchsia",
"path": "/src/media/sessions/src/log_error.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn log_error_discard_result<T, E: Debug>(r: Result<T, E>) {
r.map(|_| ()).unwrap_or_else(|e| eprintln!("{:?}", e))
}<|fim_prefix|>// repo: OpenTrustGroup/fuchsia path: /src/media/sessions/src/log_error.rs
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is go... | code_fim | hard | {
"lang": "rust",
"repo": "OpenTrustGroup/fuchsia",
"path": "/src/media/sessions/src/log_error.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! trylogbreak {
($elem:expr) => {
match $elem {
Ok(v) => v,
Err(e) => {
eprintln!("{:?}", e);
break;
}
}
};
}
pub fn log_error_discard_result<T, E: Debug>(r: Result<T, E>) {
r.map(|_... | code_fim | hard | {
"lang": "rust",
"repo": "OpenTrustGroup/fuchsia",
"path": "/src/media/sessions/src/log_error.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Switch L and R.
let switched: u64 = (r << 32) | l;
// Last step is running the inverse initial permutation.
return permute(switched, 64, &data::IIP);
}
pub fn encrypt_block(block: u64, keys: [u64; 16]) -> u64 {
// Encryption is simply running the network.
return run_network(bl... | code_fim | hard | {
"lang": "rust",
"repo": "JialuGong/secret_chat.rs",
"path": "/encrypt/src/des/des.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JialuGong/secret_chat.rs path: /encrypt/src/des/des.rs
use crate::des::data;
#[derive(Clone, Copy, PartialEq)]
pub enum Action {
Encrypt,
Decrypt,
}
fn permute(block: u64, block_size: u8, permutation: &[u8]) -> u64 {
let mut result: u64 = 0;
for &pos in permutation.iter() {
... | code_fim | hard | {
"lang": "rust",
"repo": "JialuGong/secret_chat.rs",
"path": "/encrypt/src/des/des.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod error;
pub use error::{CryptoError, CryptoResult};
mod buffer;
pub use buffer::{Buffer, ProtectState, ReadLocker, WriteLocker};
mod crypto_system;
pub use crypto_system::{crypto_system_test, CryptoSystem};<|fim_prefix|>// repo: holochain/lib3h path: /crates/crypto_api/src/lib.rs
//! lib3h abstract ... | code_fim | medium | {
"lang": "rust",
"repo": "holochain/lib3h",
"path": "/crates/crypto_api/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod buffer;
pub use buffer::{Buffer, ProtectState, ReadLocker, WriteLocker};
mod crypto_system;
pub use crypto_system::{crypto_system_test, CryptoSystem};<|fim_prefix|>// repo: holochain/lib3h path: /crates/crypto_api/src/lib.rs
//! lib3h abstract cryptography traits and data types
//!
//! # Examples
//... | code_fim | easy | {
"lang": "rust",
"repo": "holochain/lib3h",
"path": "/crates/crypto_api/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: holochain/lib3h path: /crates/crypto_api/src/lib.rs
//! lib3h abstract cryptography traits and data types
//!
//! # Examples
//!
//! ```
//! extern crate lib3h_crypto_api;
//!
//! fn main() {
//! }
//! ```
<|fim_suffix|>mod buffer;
pub use buffer::{Buffer, ProtectState, ReadLocker, WriteLocker}... | code_fim | medium | {
"lang": "rust",
"repo": "holochain/lib3h",
"path": "/crates/crypto_api/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pair_info: PairInfoRaw = from_binary(&res)?;
deps.api.human_address(&pair_info.liquidity_token)
}<|fim_prefix|>// repo: rosty-git/terraswap path: /contracts/terraswap_factory/src/querier.rs
use cosmwasm_std::{
from_binary, Api, Binary, Extern, HumanAddr, Querier, QueryRequest, StdResult, ... | code_fim | hard | {
"lang": "rust",
"repo": "rosty-git/terraswap",
"path": "/contracts/terraswap_factory/src/querier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rosty-git/terraswap path: /contracts/terraswap_factory/src/querier.rs
use cosmwasm_std::{
from_binary, Api, Binary, Extern, HumanAddr, Querier, QueryRequest, StdResult, Storage,
WasmQuery,
};
use cosmwasm_storage::to_length_prefixed;
use terraswap::PairInfoRaw;
<|fim_suffix|> let pai... | code_fim | hard | {
"lang": "rust",
"repo": "rosty-git/terraswap",
"path": "/contracts/terraswap_factory/src/querier.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let groups: Vec<Group> = input_reader::get_inputs_split("\n\n");
let positive_answers: u32 = groups.iter().map(|g| g.answers.len() as u32).sum();
println!("Part 1: {}", positive_answers);
let common_answers: u32 = groups.iter().map(|g| g.get_common_answers()).sum();
printl... | code_fim | hard | {
"lang": "rust",
"repo": "LiquidityC/aoc",
"path": "/2020/day_06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LiquidityC/aoc path: /2020/day_06/src/main.rs
use std::collections::HashMap;
struct Group {
size: u32,
answers: HashMap<char, u32>,
}
impl Group {
fn get_common_answers(&self) -> u32 {
self.answers.values().filter(|v| *v == &self.size).count() as u32
}
}
impl std::str:... | code_fim | hard | {
"lang": "rust",
"repo": "LiquidityC/aoc",
"path": "/2020/day_06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let groups: Vec<Group> = input_reader::get_inputs_split("\n\n");
let positive_answers: u32 = groups.iter().map(|g| g.answers.len() as u32).sum();
println!("Part 1: {}", positive_answers);
let common_answers: u32 = groups.iter().map(|g| g.get_common_answers()).sum();
println!("Part 2: ... | code_fim | hard | {
"lang": "rust",
"repo": "LiquidityC/aoc",
"path": "/2020/day_06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::arch::keystone::sbi;
pub fn edge_call(retval: usize) {
sbi::exit_enclave(retval);
}
pub fn exit_enclave(retval: usize) {
sbi::exit_enclave(retval);
}<|fim_prefix|>// repo: yyshen/new-tee-os path: /hal/src/sys/keystone/rt/mod.rs
mod edge;
pub mod mem;
<|fim_middle|>pub use edge::GLOB... | code_fim | easy | {
"lang": "rust",
"repo": "yyshen/new-tee-os",
"path": "/hal/src/sys/keystone/rt/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yyshen/new-tee-os path: /hal/src/sys/keystone/rt/mod.rs
mod edge;
pub mod mem;
<|fim_suffix|>pub fn edge_call(retval: usize) {
sbi::exit_enclave(retval);
}
pub fn exit_enclave(retval: usize) {
sbi::exit_enclave(retval);
}<|fim_middle|>pub use edge::GLOBAL_EDGE_CALLER;
use crate::arch:... | code_fim | medium | {
"lang": "rust",
"repo": "yyshen/new-tee-os",
"path": "/hal/src/sys/keystone/rt/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Herbstein/aoc2020 path: /src/day03.rs
use std::{
iter::FromIterator,
ops::{Add, AddAssign, Index},
};
#[derive(Copy, Clone)]
struct Pos {
x: u32,
y: u32,
}
impl Add for Pos {
type Output = Pos;
fn add(self, rhs: Self) -> Self::Output {
Pos {
x: self... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day03.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, PartialEq)]
enum Tile {
Open,
Tree,
}
impl From<char> for Tile {
fn from(c: char) -> Self {
match c {
'.' => Tile::Open,
'#' => Tile::Tree,
_ => unreachable!(),
}
}
}
#[aoc_generator(day3)]
fn generator(input: &str... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day3, part2)]
fn second(world: &World) -> usize {
let deltas = [
Pos { x: 1, y: 1 },
Pos { x: 3, y: 1 },
Pos { x: 5, y: 1 },
Pos { x: 7, y: 1 },
Pos { x: 1, y: 2 },
];
deltas.iter().map(|d| traverse(&world, d)).product()
}<|fim_prefix|>// repo: He... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/aoc2020",
"path": "/src/day03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"curl -X {} {} \\",
presigned_req.method(),
presigned_req.uri()
);
if let Some(body) = body {
println!("-d '{}' \\", body);
}
for (name, value) in presigned_req.headers() {
// This value conversion method is naïve and will drop values... | code_fim | hard | {
"lang": "rust",
"repo": "awsdocs/aws-doc-sdk-examples",
"path": "/rust_dev_preview/examples/sending-presigned-requests/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awsdocs/aws-doc-sdk-examples path: /rust_dev_preview/examples/sending-presigned-requests/src/main.rs
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#![allow(clippy::result_large_err)]
use aws_config::meta::region::RegionProv... | code_fim | hard | {
"lang": "rust",
"repo": "awsdocs/aws-doc-sdk-examples",
"path": "/rust_dev_preview/examples/sending-presigned-requests/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.