text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fn GoalWrapper_SetMaxGoalScorerAttachRadius(obj: usize, new_val: f32); fn Goal_TA_Get_GoalScoredDotDirection(obj: usize, result: *mut Vector); fn GoalWrapper_SetGoalScoredDotDirection(obj: usize, new_val: *mut Vector); fn Goal_TA_Get_MinAttachGoalToScorerDot(obj: usize) -> f32; fn Goal...
code_fim
hard
{ "lang": "rust", "repo": "mtimkovich/bakkesmod-rust", "path": "/src/wrappers/unreal/goal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtimkovich/bakkesmod-rust path: /src/wrappers/unreal/goal.rs use crate::wrappers::{*, structs::*, unreal::*}; use super::*; pub struct GoalWrapper(pub usize); impl_object!(GoalWrapper); impl Goal for GoalWrapper {} pub trait Goal : Object { fn get_goal_orientation(&self) -> Option<ActorWr...
code_fim
hard
{ "lang": "rust", "repo": "mtimkovich/bakkesmod-rust", "path": "/src/wrappers/unreal/goal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn Goal_TA_Get_GoalDirection(obj: usize) -> usize; fn GoalWrapper_SetGoalDirection(obj: usize, new_val: usize); fn Goal_TA_Get_PointsToAward(obj: usize) -> i32; fn GoalWrapper_SetPointsToAward(obj: usize, new_val: i32); fn Goal_TA_Get_AutoCamFocusExtent(obj: usize, result: *mut Vector)...
code_fim
hard
{ "lang": "rust", "repo": "mtimkovich/bakkesmod-rust", "path": "/src/wrappers/unreal/goal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod token; mod number; mod separator; mod symbol; mod text; mod whitespace; mod word;<|fim_prefix|>// repo: nabor/azurita path: /src/azurita/tokens/mod.rs pub use self::token::Tokenizer; pub use self::token::State; <|fim_middle|>pub use self::number::Number; pub use self::separator::Separator; pub u...
code_fim
medium
{ "lang": "rust", "repo": "nabor/azurita", "path": "/src/azurita/tokens/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nabor/azurita path: /src/azurita/tokens/mod.rs pub use self::token::Tokenizer; pub use self::token::State; <|fim_suffix|>pub mod token; mod number; mod separator; mod symbol; mod text; mod whitespace; mod word;<|fim_middle|>pub use self::number::Number; pub use self::separator::Separator; pub u...
code_fim
medium
{ "lang": "rust", "repo": "nabor/azurita", "path": "/src/azurita/tokens/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johanlindblad/advent-of-code-2018 path: /src/day17.rs #[derive(Clone, Debug)] pub enum Tile { Sand, Clay, Water, Dried } #[aoc_generator(day17)] pub fn input_generator(input: &str) -> Vec<Vec<Tile>> { let mut ranges: Vec<(usize, usize, usize, usize)> = input.lines().map(|l| { let pa...
code_fim
hard
{ "lang": "rust", "repo": "johanlindblad/advent-of-code-2018", "path": "/src/day17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum = 0; board[0][500] = Tile::Sand; let mut has_something = false; for i in 0..board.len() { let row = &board[i]; for tile in row { match tile { Tile::Clay => has_something = true, _ => () } } ...
code_fim
hard
{ "lang": "rust", "repo": "johanlindblad/advent-of-code-2018", "path": "/src/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndyCoder/Advent2020 path: /day-13-shuttle-search copy 2/src/main.rs use std::fs; fn main() { let input: Vec<String> = fs::read_to_string("input") .expect("unable to read input file") .split_whitespace() .map(|s| String::from(s)) .collect(); let busses: V...
code_fim
hard
{ "lang": "rust", "repo": "AndyCoder/Advent2020", "path": "/day-13-shuttle-search copy 2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sieve = Sieve::new(10_000_000); let mut prime: usize = 0; let mut bus: usize = 0; 'outer: for t in ts.. { let factors: Vec<usize> = sieve.factor(t).unwrap().iter() .map(|x| x.0).collect(); for b in busses.iter() { if factors.contains(b) { ...
code_fim
hard
{ "lang": "rust", "repo": "AndyCoder/Advent2020", "path": "/day-13-shuttle-search copy 2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HoOngEe/codechain-dashboard path: /server/src/daily_reporter.rs use std::sync::Arc; use std::thread; use chrono; use super::agent::ServiceSender as AgentServiceSender; use super::agent::State as AgentState; use super::db::ServiceSender as DBServiceSender; use super::noti::Noti; pub fn start( ...
code_fim
hard
{ "lang": "rust", "repo": "HoOngEe/codechain-dashboard", "path": "/server/src/daily_reporter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn send_daily_report( network_id: &str, noti: Arc<Noti>, db_service: DBServiceSender, agent_service: AgentServiceSender, ) { let result = db_service.check_connection(); let db_status = match result { Ok(_) => "DB is connected".to_string(), Err(err) => format!("D...
code_fim
hard
{ "lang": "rust", "repo": "HoOngEe/codechain-dashboard", "path": "/server/src/daily_reporter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/glacier path: /ices/91985.rs #![feature(generic_associated_types)] pub trait Trait1 { type Associated: Ord; } <|fim_suffix|>pub struct GatStruct; impl GatTrait for GatStruct { type Gat<T: Clone> = Box<T>; } pub struct OuterStruct<T1: Trait1, T2: Trait2> { inner: InnerS...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/ices/91985.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct InnerStruct<T: Trait2, G: GatTrait> { pub gat: G::Gat<T::Associated>, } impl<T1, T2> OuterStruct<T1, T2> where T1: Trait1, T2: Trait2<Associated = T1::Associated>, { pub fn new() -> Self { todo!() } } pub fn main() {}<|fim_prefix|>// repo: rust-lang/glacier path: ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/ices/91985.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonngw/leetcode path: /rust/0448-find-all-numbers-disappeared-in-an-array.rs impl Solution { pub fn find_disappeared_numbers(nums: Vec<i32>) -> Vec<i32> { let mut nums = nums; for i in 0..nums.len() { let j = nums[i].abs() - 1; nums[j as usize] = -1 * ...
code_fim
easy
{ "lang": "rust", "repo": "tonngw/leetcode", "path": "/rust/0448-find-all-numbers-disappeared-in-an-array.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (index, number) in nums.iter().enumerate() { if *number > 0 { result.push((index + 1) as i32); } } result } }<|fim_prefix|>// repo: tonngw/leetcode path: /rust/0448-find-all-numbers-disappeared-in-an-array.rs impl Solution { pub ...
code_fim
easy
{ "lang": "rust", "repo": "tonngw/leetcode", "path": "/rust/0448-find-all-numbers-disappeared-in-an-array.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miquels/mp4 path: /mp4lib/src/boxes/trun.rs // // ISO/IEC 14496-12:2015(E) // 8.8.8 Track Fragment Run Box // use std::io; use crate::boxes::prelude::*; // aligned(8) class TrackRunBox // extends FullBox(‘trun’, version, tr_flags) { // unsigned int(32) sample_count; // // the follo...
code_fim
hard
{ "lang": "rust", "repo": "miquels/mp4", "path": "/mp4lib/src/boxes/trun.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for e in &self.entries { e.to_bytes(stream)?; } stream.finalize() } } impl FullBox for TrackRunBox { fn version(&self) -> Option<u8> { for e in &self.entries { if let Some(cto) = e.sample_composition_time_offset { if cto < 0...
code_fim
hard
{ "lang": "rust", "repo": "miquels/mp4", "path": "/mp4lib/src/boxes/trun.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edkins/waproof path: /theory/src/process.rs use crate::boxing::{self, Boxes, TheoremBox}; use crate::eq::TheoremEq; use crate::equalizer::MultiTheoremEqualizer; use crate::script::{Script, ScriptEl}; use crate::util::TheoryError; use kernel::pa_axiom::Theorem; pub fn prove_script(script: &str, ...
code_fim
hard
{ "lang": "rust", "repo": "edkins/waproof", "path": "/theory/src/process.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut refs = TheoremSet::from_references(references); let mut boxes = Boxes::default(); let mut current = None; for el in &self.0 { match el { ScriptEl::Pop => { boxes.pop()?; refs.decr_depth(); ...
code_fim
hard
{ "lang": "rust", "repo": "edkins/waproof", "path": "/theory/src/process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for &prec in &[1, 3, 6, 16, 30] { println!("testing with {} digits", prec); for &f in &[0.1_f64, 1e-100, 0.1111111111111111] { println!(" testing {}", f); shortest_with_prec(f, prec); } } } #[cfg(test)] fn shortest_with_prec(f: f64, prec: usize) { ...
code_fim
hard
{ "lang": "rust", "repo": "droundy/sad-monte-carlo", "path": "/src/prettyfloat.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: droundy/sad-monte-carlo path: /src/prettyfloat.rs //! This module attempts to provide a %g formatter. use std::fmt::{Alignment, Display, Formatter, Result}; /// Wrap this type around an `f64` in order to print it nicely. pub struct PrettyFloat(pub f64); fn n_decimals(value: f64, digits: usize...
code_fim
hard
{ "lang": "rust", "repo": "droundy/sad-monte-carlo", "path": "/src/prettyfloat.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn short_representation_with_prec() { for &prec in &[1, 3, 6, 16, 30] { println!("testing with {} digits", prec); for &f in &[0.1_f64, 1e-100, 0.1111111111111111] { println!(" testing {}", f); shortest_with_prec(f, prec); } } } #[cfg(test)]...
code_fim
hard
{ "lang": "rust", "repo": "droundy/sad-monte-carlo", "path": "/src/prettyfloat.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Hash for SourceChunk { fn hash<H: Hasher>(&self, state: &mut H) { self.start_vpos.hash(state); } } impl Debug for SourceChunk { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { let mut d = f.debug_struct("SourceChunk"); d.field("start_vpos", &...
code_fim
hard
{ "lang": "rust", "repo": "zachjs/vfront", "path": "/vfront_basics/src/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns index of the most recent line number override entry applying /// to a given position, if any. fn find_line_override(&self, pos: usize) -> Option<usize> { let mut size = self.line_overrides.len(); let mut left = 0; let mut right = size; while left < r...
code_fim
hard
{ "lang": "rust", "repo": "zachjs/vfront", "path": "/vfront_basics/src/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zachjs/vfront path: /vfront_basics/src/source.rs aracter. /// /// This maintains three pointers into a chunk: /// /// - The cursor: points at the next character to be read. /// - The end: points at a "stop point" past which the cursor cannot advance. /// - The bookmark: points at an arbitrary "s...
code_fim
hard
{ "lang": "rust", "repo": "zachjs/vfront", "path": "/vfront_basics/src/source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: likr-sandbox/complex-network path: /crates/wasm/src/lib.rs #[macro_use] extern crate serde_derive; pub mod algorithm; pub mod centrality; pub mod graph_generation; pub mod simulation; use js_sys::{Array, Function, Object, Reflect}; use petgraph::graph::{edge_index, node_index}; use petgraph::p...
code_fim
hard
{ "lang": "rust", "repo": "likr-sandbox/complex-network", "path": "/crates/wasm/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn pagerank(graph: &JsGraph, d: f64, iter: usize) -> JsValue { JsValue::from_serde(&self::centrality::pagerank(&graph.graph, d, iter)).unwrap() } #[derive(Serialize)] pub struct HistogramItem { pub x0: f64, pub x1: f64, pub y: usize, } #[wasm_bindgen] pub fn histogram...
code_fim
hard
{ "lang": "rust", "repo": "likr-sandbox/complex-network", "path": "/crates/wasm/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svenstaro/miniserve path: /tests/upload_files.rs mod fixtures; use assert_fs::fixture::TempDir; use fixtures::{server, server_no_stderr, tmpdir, Error, TestServer}; use reqwest::blocking::{multipart, Client}; use rstest::rstest; use select::document::Document; use select::predicate::{Attr, Text...
code_fim
hard
{ "lang": "rust", "repo": "svenstaro/miniserve", "path": "/tests/upload_files.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let status = Client::new() .post(server.url().join(&format!("/upload?path={dir}"))?) .multipart(form) .send()? .error_for_status(); // Make sure upload behave as expected assert_eq!(status.is_ok(), ok); assert_eq!(full_path.exists(), ok); Ok(()) } ///...
code_fim
hard
{ "lang": "rust", "repo": "svenstaro/miniserve", "path": "/tests/upload_files.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukeMathWalker/kube-rs path: /examples/crd_reflector.rs #[macro_use] extern crate log; use futures::{StreamExt, TryStreamExt}; use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition; use kube::{ api::{Api, ListParams, Patch, PatchParams, ResourceExt...
code_fim
hard
{ "lang": "rust", "repo": "LukeMathWalker/kube-rs", "path": "/examples/crd_reflector.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // 0. Ensure the CRD is installed (you probably just want to do this on CI) // (crd file can be created by piping `Foo::crd`'s yaml ser to kubectl apply) let crds: Api<CustomResourceDefinition> = Api::all(client.clone()); info!("Creating crd: {}", serde_yaml::to_string(&Foo::crd())?); ...
code_fim
hard
{ "lang": "rust", "repo": "LukeMathWalker/kube-rs", "path": "/examples/crd_reflector.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomhoule/gql-something-different-prototype path: /src/coercion.rs ///! This module contains the traits that are auto-implemented on the derived tree to extract it from a parsed request. use graphql_parser::query::*; use graphql_parser::schema::Value; use query_validation::ValidationContext; #[d...
code_fim
hard
{ "lang": "rust", "repo": "tomhoule/gql-something-different-prototype", "path": "/src/coercion.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(T::coerce(value).ok()) } } impl<T> CoerceScalar for Vec<T> where T: CoerceScalar, { fn coerce(value: &Value) -> Result<Vec<T>, CoercionError> { match value { Value::List(elems) => elems.iter().map(T::coerce).collect(), _ => Err(CoercionError), ...
code_fim
hard
{ "lang": "rust", "repo": "tomhoule/gql-something-different-prototype", "path": "/src/coercion.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MessageFull for Ask { fn header(&self) -> &MessageHeader { &self.header } fn header_mut(&mut self) -> &mut MessageHeader { &mut self.header } }<|fim_prefix|>// repo: NestedWorld/NestedWorld-Server-RealTime path: /server/src/net/msg/combat/ask.rs use net::msg::{Messag...
code_fim
hard
{ "lang": "rust", "repo": "NestedWorld/NestedWorld-Server-RealTime", "path": "/server/src/net/msg/combat/ask.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NestedWorld/NestedWorld-Server-RealTime path: /server/src/net/msg/combat/ask.rs use net::msg::{MessagePart, MessageFull, MessageHeader}; use net::msg::error::{Result}; use net::msg::utils::fields; use net::msg::utils::rmp::ValueExt; use rmp::Value; pub use super::data::user::User; #[derive(Debu...
code_fim
medium
{ "lang": "rust", "repo": "NestedWorld/NestedWorld-Server-RealTime", "path": "/server/src/net/msg/combat/ask.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.header } fn header_mut(&mut self) -> &mut MessageHeader { &mut self.header } }<|fim_prefix|>// repo: NestedWorld/NestedWorld-Server-RealTime path: /server/src/net/msg/combat/ask.rs use net::msg::{MessagePart, MessageFull, MessageHeader}; use net::msg::error::{Result}; u...
code_fim
medium
{ "lang": "rust", "repo": "NestedWorld/NestedWorld-Server-RealTime", "path": "/server/src/net/msg/combat/ask.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wattyyy/LeetCode path: /submissions/subarray-sum-equals-k/solution.rs use std::collections::HashMap; impl Solution { pub fn subarray_sum(nums: Vec<i32>, k: i32) -> i32 { let mut cum_sum = vec![0; nums.len()]; for i in 0..cum_sum.len() <|fim_suffix|>r: HashMap<i32, i32> = Has...
code_fim
hard
{ "lang": "rust", "repo": "Wattyyy/LeetCode", "path": "/submissions/subarray-sum-equals-k/solution.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>nter.contains_key(&key) { ans += counter.get(&key).unwrap(); } *counter.entry(cum_sum[i]).or_insert(0) += 1; } return ans; } }<|fim_prefix|>// repo: Wattyyy/LeetCode path: /submissions/subarray-sum-equals-k/solution.rs use std::collections::Has...
code_fim
hard
{ "lang": "rust", "repo": "Wattyyy/LeetCode", "path": "/submissions/subarray-sum-equals-k/solution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>r: HashMap<i32, i32> = HashMap::new(); counter.insert(0, 1); let mut ans = 0; for i in 0..cum_sum.len() { let key = cum_sum[i] - k; if counter.contains_key(&key) { ans += counter.get(&key).unwrap(); } *counter.entry(cu...
code_fim
hard
{ "lang": "rust", "repo": "Wattyyy/LeetCode", "path": "/submissions/subarray-sum-equals-k/solution.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..t { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let s = s.split_whitespace().collect::<Vec<_>>(); let mut ret = s[0].parse::<f64>().unwrap(); for i in 1..s.len() { match s[i] { "@" => ret *= 3.0, ...
code_fim
medium
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/5355 - Math.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/5355 - Math.rs use io::Write; use std::io; fn main() { let stdout = io::stdout(); let mut out = io::BufWriter::new(stdout.lock()); let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let t = s.trim().parse::<i64>().unwrap(); <|fim...
code_fim
hard
{ "lang": "rust", "repo": "utilForever/BOJ", "path": "/Rust/5355 - Math.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>const TESTS: &[(&'static str, &'static str)] = &[ ("cat", "tac"), ("alphabet", "tebahpla"), ("日本語", "語本日"), ];<|fim_prefix|>// repo: sadjow/polyglot path: /rust/tests/reverse_test.rs use polyglot::{reverse::iterate, reverse::std}; #[test] fn test_iterate_reverse_string() { for (word, wan...
code_fim
medium
{ "lang": "rust", "repo": "sadjow/polyglot", "path": "/rust/tests/reverse_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sadjow/polyglot path: /rust/tests/reverse_test.rs use polyglot::{reverse::iterate, reverse::std}; #[test] fn test_iterate_reverse_string() { <|fim_suffix|>const TESTS: &[(&'static str, &'static str)] = &[ ("cat", "tac"), ("alphabet", "tebahpla"), ("日本語", "語本日"), ];<|fim_middle|> ...
code_fim
hard
{ "lang": "rust", "repo": "sadjow/polyglot", "path": "/rust/tests/reverse_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fairjm/feel_boring path: /talent-plan/kvs/src/lib.rs pub struct KvStore; impl KvStore { pub fn new() -> KvStore { KvStore } <|fim_suffix|> pub fn get(&self, k : String) -> Option<String> { panic!() } pub fn remove(&mut self, k : String) { panic!() ...
code_fim
medium
{ "lang": "rust", "repo": "fairjm/feel_boring", "path": "/talent-plan/kvs/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remove(&mut self, k : String) { panic!() } }<|fim_prefix|>// repo: fairjm/feel_boring path: /talent-plan/kvs/src/lib.rs pub struct KvStore; impl KvStore { pub fn new() -> KvStore { KvStore } <|fim_middle|> pub fn set(&mut self, k : String, v : String) { ...
code_fim
medium
{ "lang": "rust", "repo": "fairjm/feel_boring", "path": "/talent-plan/kvs/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn with_ssh(func: ||) { ssh_init(); let finalizer = SSHFinalizer; func(); drop(finalizer); }<|fim_prefix|>// repo: manuels/libssh.rs path: /src/lib.rs #![feature(globs)] #![feature(phase)] #[phase(plugin, link)] extern crate log; <|fim_middle|>use std::sync::{Once, ONCE_INIT}; pub mod libssh_s...
code_fim
hard
{ "lang": "rust", "repo": "manuels/libssh.rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manuels/libssh.rs path: /src/lib.rs #![feature(globs)] #![feature(phase)] #[phase(plugin, link)] extern crate log; use std::sync::{Once, ONCE_INIT}; <|fim_suffix|>pub struct SSHFinalizer; impl Drop for SSHFinalizer { fn drop(&mut self) { ssh_finalize(); } } pub fn with_ssh(func: ||) { ss...
code_fim
hard
{ "lang": "rust", "repo": "manuels/libssh.rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jweir136/gpio-rust path: /src/lib.rs use inline_python::{ python, Context }; /// Returns a boolean value to indicate if the correct Raspberry PI GPIO libraries have been installed. /// This crate will not work is the libraries are not installed. The libraries do not come with this crate /// and...
code_fim
medium
{ "lang": "rust", "repo": "jweir136/gpio-rust", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[cfg(target_os="linux")] fn cleanup_test() { match gpio::cleanup() { Ok(_) => { // holy crap is this stupid...def need to refactor this later on assert_eq!(true, true); }, Err(msg) => { assert_...
code_fim
hard
{ "lang": "rust", "repo": "jweir136/gpio-rust", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(is_installed(), true); } #[test] #[cfg(target_os="linux")] fn basic_on_off_test() { gpio::turn_on(18); thread::sleep(Duration::from_secs(30)); gpio::turn_off(18); } #[test] #[cfg(target_os="linux")] fn cleanup_test() { ma...
code_fim
medium
{ "lang": "rust", "repo": "jweir136/gpio-rust", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use core::mem::swap; match color { ColorMode::Red => {} ColorMode::BlueGreen => { let tmp = val.red; val.red = val.blue; val.blue = val.green; val.green = tmp; ...
code_fim
hard
{ "lang": "rust", "repo": "smmalis37/wasm-playground", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smmalis37/wasm-playground path: /src/lib.rs #![no_std] use rand::prelude::*; use wasm_bindgen::prelude::*; mod color_scale; use color_scale::*; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; const WIDTH: usize = 256; const HEIGHT: usize = 112; const LEN: u...
code_fim
hard
{ "lang": "rust", "repo": "smmalis37/wasm-playground", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused)] pub struct ChaserCellStatusFactory {} impl EnemyStatusFactory for ChaserCellStatusFactory { fn create_unique_staus(&self) -> UniqueStatus { UniqueStatus { background_color: Black.value(), enemy_type: EnemyType::Chaser } } }<|fim_prefix|>// repo: rchaser53/rust-pack...
code_fim
hard
{ "lang": "rust", "repo": "rchaser53/rust-pack-man", "path": "/src/enemy/enemy_status.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> UniqueStatus { background_color: Red.value(), enemy_type: EnemyType::Normal } } } pub struct NormalEnemyStatusFactory {} impl EnemyStatusFactory for NormalEnemyStatusFactory {} #[allow(unused)] pub struct ChaserCellStatusFactory {} impl EnemyStatusFactory for ChaserCellStatusFactor...
code_fim
hard
{ "lang": "rust", "repo": "rchaser53/rust-pack-man", "path": "/src/enemy/enemy_status.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rchaser53/rust-pack-man path: /src/enemy/enemy_status.rs use sdl2::pixels::Color; use constants::{Direction, CELL_WIDTH, CELL_HEIGHT}; use constants::Direction::{East}; use constants::BackgroundColor::{ Black, Red }; use hitbox::Hitbox; const MOVE_SPEED: i16 = 1; const ENEMY_WIDTH: i16 = 15; ...
code_fim
hard
{ "lang": "rust", "repo": "rchaser53/rust-pack-man", "path": "/src/enemy/enemy_status.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if query_weight < WEIGHT_NORMAL { // If query_weight < 400, then typefaces with weights <= query_weight are // preferred. if b.typeface.weight <= query_weight { return b; } else { ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/typeface/matcher.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(query_style) = &query.style { // Select based on width, see CSS3 Section 5.2, Item 4.a. if let Some(query_width) = query_style.width { if a.typeface.width != b.typeface.width { // Reorder a and b, so a has lower width. let (a, b) ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/typeface/matcher.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /src/fonts/src/font_service/typeface/matcher.rs // Copyright 2019 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 { super::typeface::TypefaceAndLangScore, fidl...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/src/fonts/src/font_service/typeface/matcher.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dendisuhubdy/degen-wallet path: /degen-wallet-rs/src/tui/old/naive.rs use crate::eth::wallet::generate_and_save_mnemonic; use crate::tui::util::event::{Event, Events}; use crate::tui::util::{StatefulList, TabsState}; use bip39::Mnemonic; use std::io::Stdout; use std::{error::Error, io}; use term...
code_fim
hard
{ "lang": "rust", "repo": "dendisuhubdy/degen-wallet", "path": "/degen-wallet-rs/src/tui/old/naive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn draw_standard_grid(f: &mut Frame<TermBck>) -> Rect { let size = f.size(); let chunks = Layout::default() .direction(Direction::Vertical) // .margin(20) .constraints([ Constraint::Length(3), Constraint::Min(0), Constraint::Length(3), ...
code_fim
hard
{ "lang": "rust", "repo": "dendisuhubdy/degen-wallet", "path": "/degen-wallet-rs/src/tui/old/naive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kornelski/rust-lcms2 path: /examples/tags.rs use lcms2::{InfoType, Locale, Profile, Tag}; use std::env; fn main() { let profile = if let Some(path) = env::args().nth(1) { Profile::new_file(path).unwrap() } else { Profile::new_srgb() }; <|fim_suffix|> for sig in ...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/rust-lcms2", "path": "/examples/tags.rs", "mode": "psm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_suffix|> for sig in profile.tag_signatures() { let tag = profile.read_tag(sig); println!("{sig:?} = {tag:?}"); match tag { Tag::Pipeline(pipeline) => { for stage in pipeline.stages() { println!(" └─ {stage:?}"); } ...
code_fim
hard
{ "lang": "rust", "repo": "kornelski/rust-lcms2", "path": "/examples/tags.rs", "mode": "spm", "license": "MIT-0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orkunkl/loterra-dao path: /src/tests.rs rst proposal".to_string(), proposal, amount: Option::from(Uint128::new(250)), recipient: None, prizes_per_ranks: None, migration: None, contract_address: "lotte...
code_fim
hard
{ "lang": "rust", "repo": "orkunkl/loterra-dao", "path": "/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let before_all = before_all(); let mut deps = mock_dependencies_custom(&[Coin { denom: "ust".to_string(), amount: Uint128::new(9_000_000), }]); deps.querier.with_holder( before_all.default_sender.clone(), ...
code_fim
hard
{ "lang": "rust", "repo": "orkunkl/loterra-dao", "path": "/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: orkunkl/loterra-dao path: /src/tests.rs create_poll(deps.as_mut()); let env = mock_env(); let info = mock_info( before_all.default_sender.as_str().clone(), &[Coin { denom: "ust".to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "orkunkl/loterra-dao", "path": "/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (q, mut r) = sum.div_rem(&n); // We can unwrap because 0 < sum <= 9 * n < 10 * n v.push(Digit::try_from_u64(q).unwrap()); while (v.len() as u64) <= n { println!("before before: q: {}, r: {}, n: {}", q, r, n); r *= 10; println!("befor...
code_fim
hard
{ "lang": "rust", "repo": "SCappella/riddler", "path": "/misc/fin_dec.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SCappella/riddler path: /misc/fin_dec.rs extern crate num_integer; use self::num_integer::Integer; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum Digit { Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, } impl Digit { pub fn try_fro...
code_fim
hard
{ "lang": "rust", "repo": "SCappella/riddler", "path": "/misc/fin_dec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bieganski/distributed path: /dslab05/solution.rs use std::rc::Rc; pub struct List<T> { first : Option<Rc<ListValue<T>>>, } pub struct ListValue<T> { data : Rc<T>, next : Option<Rc<ListValue<T>>>, } impl<T> Clone for List<T> { fn clone(&self) -> Self { let res : Li...
code_fim
medium
{ "lang": "rust", "repo": "bieganski/distributed", "path": "/dslab05/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Length of the list, 0 for empty list. pub fn length(&self) -> usize { let mut tmp : Option<&Rc<ListValue<T>>> = self.first.as_ref(); let mut res : usize = 0; while let Some(rc) = tmp { res += 1; tmp = (*rc).next.as_ref(); } res ...
code_fim
hard
{ "lang": "rust", "repo": "bieganski/distributed", "path": "/dslab05/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: weblfe/ext-php-rs path: /src/class.rs //! Types and traits used for registering classes with PHP. use std::{ collections::HashMap, marker::PhantomData, mem::MaybeUninit, sync::atomic::{AtomicBool, AtomicPtr, Ordering}, }; use crate::{ builders::FunctionBuilder, exceptio...
code_fim
hard
{ "lang": "rust", "repo": "weblfe/ext-php-rs", "path": "/src/class.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Retrieves a reference to the stored class entry. /// /// # Panics /// /// Panics if there is no class entry stored inside the class metadata. pub fn ce(&self) -> &'static ClassEntry { // SAFETY: There are only two values that can be stored in the atomic ptr: null ...
code_fim
hard
{ "lang": "rust", "repo": "weblfe/ext-php-rs", "path": "/src/class.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let s = "BFFFBBFRRR"; let seat : Seat = s.split_at(7).into(); assert_eq!(seat.row, 70); assert_eq!(seat.col, 7); assert_eq!(seat.get_id(), 567); } #[test] fn test2() { let s = "FFFBBBFRRR"; let seat : Seat = s.split_at(7).into(); ...
code_fim
hard
{ "lang": "rust", "repo": "BrettWitty/adventofcode2020", "path": "/src/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test2() { let s = "FFFBBBFRRR"; let seat : Seat = s.split_at(7).into(); assert_eq!(seat.row, 14); assert_eq!(seat.col, 7); assert_eq!(seat.get_id(), 119); } #[test] fn test3() { let s = "BBFFBBFRLL"; let seat : S...
code_fim
hard
{ "lang": "rust", "repo": "BrettWitty/adventofcode2020", "path": "/src/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BrettWitty/adventofcode2020 path: /src/day5.rs use std::collections::HashSet; pub struct Seat { row: usize, col: usize } impl Seat { fn get_id(&self) -> usize { self.row*8 + self.col } } fn decode(text: &str, one: char, _zero: char ) -> usize { // Big-endian usize...
code_fim
hard
{ "lang": "rust", "repo": "BrettWitty/adventofcode2020", "path": "/src/day5.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/parser/lowerer_modifier.rs // Copyright (c) 2019, Facebook, Inc. // All rights reserved. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use oxidized::aast::Visibility; use oxidi...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/parser/lowerer_modifier.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const VISIBILITIES: KindSet = KindSet(PRIVATE.0 | PUBLIC.0 | PROTECTED.0); impl KindSet { pub fn new() -> Self { KindSet(0) } pub fn add(&mut self, kind: Kind) { self.0 = self.0 | kind.0 } pub fn has(&self, kind: Kind) -> bool { self.0 & kind.0 > 0 } ...
code_fim
hard
{ "lang": "rust", "repo": "ecreeth/hhvm", "path": "/hphp/hack/src/parser/lowerer_modifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paolobarbolini/grass path: /tests/imports.rs use std::io::Write; #[macro_use] mod macros; #[test] fn imports_variable() { let input = "@import \"imports_variable\";\na {\n color: $a;\n}"; tempfile!("imports_variable", "$a: red;"); assert_eq!( "a {\n color: red;\n}\n", ...
code_fim
hard
{ "lang": "rust", "repo": "paolobarbolini/grass", "path": "/tests/imports.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input = "@import \"chained_imports_in_directory__a\";\na {\n color: $a;\n}"; tempfile!( "chained_imports_in_directory__a.scss", "@import \"chained_imports_in_directory__b\";" ); tempfile!( "index.scss", "@import \"../chained_imports_in_directory__c\";", ...
code_fim
hard
{ "lang": "rust", "repo": "paolobarbolini/grass", "path": "/tests/imports.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/commands/osu/medals/list.rs use std::{ cmp::{Ordering, Reverse}, sync::Arc, }; use bathbot_model::{rkyv_util::time::DateTimeRkyv, OsekaiMedal, Rarity}; use bathbot_util::{ constants::{GENERAL_ISSUE, OSEKAI_ISSUE, OSU_API_ISSUE}, IntHasher, }; us...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/commands/osu/medals/list.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let mut medals = Vec::with_capacity(acquired.0); medals.extend(medals_iter); (acquired, medals) } RedisData::Archive(ref user) => { let acquired = (user.medals.len(), osekai_medals.len()); let medals_iter = user.medals.iter().fi...
code_fim
hard
{ "lang": "rust", "repo": "MaxOhn/Bathbot", "path": "/bathbot/src/commands/osu/medals/list.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> /// Indicates an error with an XCB request. This is usually not because of parameters /// specified, but because there was an issue with the X.Org connection. XError(description: String) { description("Unable to send XCB request"), display("Unable to send XC...
code_fim
hard
{ "lang": "rust", "repo": "Txuritan/leechbar", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Different types of bar creation errors. /// /// These are all the different errors that can occur during the creation of the bar. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum BarErrorKind { /// Unable to connect to the X.Org server. Please make sure you are running ...
code_fim
hard
{ "lang": "rust", "repo": "Txuritan/leechbar", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Txuritan/leechbar path: /src/error.rs //! Error Types. use std::fmt; error_chain! { foreign_links { XcbConnectionError(::xcb::ConnError); } errors { /// Unable to find a screen. /// /// This error occurs when the connection was possible, but no scre...
code_fim
hard
{ "lang": "rust", "repo": "Txuritan/leechbar", "path": "/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CNrocke/rpfm path: /rpfm_ui/src/packedfile_views/anim_fragment/slots.rs //---------------------------------------------------------------------------// // Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved. // // This file is part of the Rusted PackFile Manager (RPFM) project...
code_fim
hard
{ "lang": "rust", "repo": "CNrocke/rpfm", "path": "/rpfm_ui/src/packedfile_views/anim_fragment/slots.rs", "mode": "psm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|> let delayed_updates = SlotNoArgs::new(&view.table_view_2.get_mut_ptr_table_view_primary(), clone!( app_ui, pack_file_contents_ui, diagnostics_ui, view => move || { // Only save to the backend if both, the save and undo locks are disa...
code_fim
hard
{ "lang": "rust", "repo": "CNrocke/rpfm", "path": "/rpfm_ui/src/packedfile_views/anim_fragment/slots.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|>/// This struct contains the slots of the view of a AnimFragmentPackedFile. pub struct PackedFileAnimFragmentViewSlots { pub delayed_updates: QBox<SlotNoArgs>, } //-------------------------------------------------------------------------------// // Implementations //------...
code_fim
hard
{ "lang": "rust", "repo": "CNrocke/rpfm", "path": "/rpfm_ui/src/packedfile_views/anim_fragment/slots.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_suffix|> r = i; break; } } nums.swap(l, r); nums[l+1..n].sort(); } }<|fim_prefix|>// repo: satylogin/leetcode path: /medium/31. Next Permutation.rs impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { let n = nums.len(); le...
code_fim
hard
{ "lang": "rust", "repo": "satylogin/leetcode", "path": "/medium/31. Next Permutation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: satylogin/leetcode path: /medium/31. Next Permutation.rs impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { let n = nums.len(); let (mut l, mut <|fim_suffix|> break; } } for i in (l+1..n).rev() { if nums[i] > nums[l] ...
code_fim
hard
{ "lang": "rust", "repo": "satylogin/leetcode", "path": "/medium/31. Next Permutation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_class_or_typedef(&self, name: TypeName) -> Option<TypeDecl<R>>; } pub enum TypeDecl<R: Reason> { Class(Arc<dyn Class<R>>), Typedef(Arc<TypedefDecl<R>>), } /// Represents the complete folded declaration of a class. pub trait Class<R: Reason> { fn get_prop(&self, name: PropName) -> ...
code_fim
hard
{ "lang": "rust", "repo": "Wilfred/hhvm", "path": "/hphp/hack/src/rupro/lib/typing_decl_provider/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wilfred/hhvm path: /hphp/hack/src/rupro/lib/typing_decl_provider/mod.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use crate::decl_defs::shallow::TypedefDe...
code_fim
hard
{ "lang": "rust", "repo": "Wilfred/hhvm", "path": "/hphp/hack/src/rupro/lib/typing_decl_provider/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Represents the complete folded declaration of a class. pub trait Class<R: Reason> { fn get_prop(&self, name: PropName) -> Option<Arc<ClassElt<R>>>; fn get_static_prop(&self, name: PropName) -> Option<Arc<ClassElt<R>>>; fn get_method(&self, name: MethodName) -> Option<Arc<ClassElt<R>>>; ...
code_fim
medium
{ "lang": "rust", "repo": "Wilfred/hhvm", "path": "/hphp/hack/src/rupro/lib/typing_decl_provider/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ttps://www.googleapis.com/discovery/v1/apis/compute/v1/rest", "/tmp", &std::env::args().nth(1).unwrap(), )?; Ok(()) }<|fim_prefix|>// repo: ggriffiniii/google-apis path: /generator/examples/compute.rs use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { <|fim_midd...
code_fim
medium
{ "lang": "rust", "repo": "ggriffiniii/google-apis", "path": "/generator/examples/compute.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>"/tmp", &std::env::args().nth(1).unwrap(), )?; Ok(()) }<|fim_prefix|>// repo: ggriffiniii/google-apis path: /generator/examples/compute.rs use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { ::pretty_env_logger::init_timed(); generator::generate( "h<|fim_midd...
code_fim
medium
{ "lang": "rust", "repo": "ggriffiniii/google-apis", "path": "/generator/examples/compute.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ggriffiniii/google-apis path: /generator/examples/compute.rs use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { <|fim_suffix|>ttps://www.googleapis.com/discovery/v1/apis/compute/v1/rest", "/tmp", &std::env::args().nth(1).unwrap(), )?; Ok(()) }<|fim_midd...
code_fim
medium
{ "lang": "rust", "repo": "ggriffiniii/google-apis", "path": "/generator/examples/compute.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: segfo/qrcode path: /src/main.rs extern crate qrcodegen; extern crate clap; use clap::*; use qrcodegen::QrCode; use qrcodegen::QrCodeEcc; use std::fs::OpenOptions; use std::io::Write; use std::io::Read; mod data_type; use data_type::*; #[cfg(test)] mod test; fn init<'a>()->ArgMatches<'a>{ a...
code_fim
hard
{ "lang": "rust", "repo": "segfo/qrcode", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let svg = match data2qr(&data,data_type) { Ok(svg)=>svg, Err(e)=>{ eprintln!("{}",e); return; } }; out_file.write_all(svg.as_bytes()).unwrap(); } fn to_svg_string(qr: &QrCode, border: i32) -> String { assert!(border >= 0, "Border must be n...
code_fim
hard
{ "lang": "rust", "repo": "segfo/qrcode", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let secret_key = SecretKey::random_for_test(rng); PublicKey::from_secret_key(&secret_key) } }<|fim_prefix|>// repo: mluluz/lighthouse path: /eth2/types/src/test_utils/test_random/public_key.rs use super::TestRandom; use bls::{PublicKey, SecretKey}; use rand::RngCore; <|fim_middle|>im...
code_fim
medium
{ "lang": "rust", "repo": "mluluz/lighthouse", "path": "/eth2/types/src/test_utils/test_random/public_key.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mluluz/lighthouse path: /eth2/types/src/test_utils/test_random/public_key.rs use super::TestRandom; use bls::{PublicKey, SecretKey}; use rand::RngCore; <|fim_suffix|> let secret_key = SecretKey::random_for_test(rng); PublicKey::from_secret_key(&secret_key) } }<|fim_middle|>im...
code_fim
medium
{ "lang": "rust", "repo": "mluluz/lighthouse", "path": "/eth2/types/src/test_utils/test_random/public_key.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/gam/src/bitmap/img.rs /* * Img is a minimal structure to hold an RGB raster image * * author: nworbnhoj */ use std::ops::Deref; #[derive(Debug, Clone, Copy)] pub enum PixelType { U0, // Error U8, U8x2, U8x3, U8x4, U16, U16x...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/gam/src/bitmap/img.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Img { pub fn new(pixels: Vec<u8>, width: usize, px_type: PixelType) -> Self { Self { pixels, width, px_type, } } pub fn width(&self) -> usize { self.width } pub fn height(&self) -> usize { match self.px_type { ...
code_fim
medium
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/services/gam/src/bitmap/img.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }