text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut s = String::new(); File::open(filename)?.read_to_string(&mut s)?; Ok(s) }<|fim_prefix|>// repo: c0ldch0c0l8/learning_rust path: /src/read_username.rs use std::fs::File; use std::io::Read; <|fim_middle|>fn read_username(filename: &str) -> Result<String, std::io::Error> {
code_fim
medium
{ "lang": "rust", "repo": "c0ldch0c0l8/learning_rust", "path": "/src/read_username.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c0ldch0c0l8/learning_rust path: /src/read_username.rs use std::fs::File; use std::io::Read; <|fim_suffix|> File::open(filename)?.read_to_string(&mut s)?; Ok(s) }<|fim_middle|>fn read_username(filename: &str) -> Result<String, std::io::Error> { let mut s = String::new();
code_fim
medium
{ "lang": "rust", "repo": "c0ldch0c0l8/learning_rust", "path": "/src/read_username.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> File::open(filename)?.read_to_string(&mut s)?; Ok(s) }<|fim_prefix|>// repo: c0ldch0c0l8/learning_rust path: /src/read_username.rs use std::fs::File; use std::io::Read; fn read_username(filename: &str) -> Result<String, std::io::Error> { <|fim_middle|> let mut s = String::new();
code_fim
easy
{ "lang": "rust", "repo": "c0ldch0c0l8/learning_rust", "path": "/src/read_username.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Malefaro/taskery path: /graphql_server/src/models/experience.rs use async_graphql::SimpleObject; use diesel::{Associations, Identifiable, Queryable}; use serde::{Deserialize, Serialize}; <|fim_suffix|>#[derive( SimpleObject, Queryable, Associations, Identifiable, Serialize, Deserialize, Deb...
code_fim
easy
{ "lang": "rust", "repo": "Malefaro/taskery", "path": "/graphql_server/src/models/experience.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive( SimpleObject, Queryable, Associations, Identifiable, Serialize, Deserialize, Debug, Clone, )] #[belongs_to(Company)] #[belongs_to(User)] pub struct Experience { pub id: i32, pub total_exp: i32, pub user_id: i32, pub company_id: i32, }<|fim_prefix|>// repo: Malefaro/taskery p...
code_fim
easy
{ "lang": "rust", "repo": "Malefaro/taskery", "path": "/graphql_server/src/models/experience.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/futures/src/stream/impls.rs use {Task, Poll}; use stream::Stream; <|fim_suffix|> (**self).poll(task) } fn schedule(&mut self, task: &mut Task) { (**self).schedule(task) } }<|fim_middle|>impl<S: ?Sized + Stream>...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/stream/impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn schedule(&mut self, task: &mut Task) { (**self).schedule(task) } }<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/futures/src/stream/impls.rs use {Task, Poll}; use stream::Stream; <|fim_middle|>impl<S: ?Sized + Stream> Stream for Box<S> { type Item ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/stream/impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 171230839/MyUE path: /build.rs use std::env; pub fn main(){ let key = "RUST_LOG"; let mut env_log = String::new(); match env::var_os(key){ Some(val) => env_log.push_str(val.into_string().as_ref().unwrap()), None => {} } if env_log.is_empty(){ env_log...
code_fim
easy
{ "lang": "rust", "repo": "171230839/MyUE", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // println!("cargo:rustc-env=RUST_LOG={}", env_log); // println!("cargo:rustc-cfg=WITH_EDITOR"); // println!("cargo:rustc-cfg=WITH_TEST"); }<|fim_prefix|>// repo: 171230839/MyUE path: /build.rs use std::env; pub fn main(){ let key = "RUST_LOG"; let mut env_log = String::new(); matc...
code_fim
easy
{ "lang": "rust", "repo": "171230839/MyUE", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ireina7/leetcode.note path: /Rust/sqrtx.rs //Version 1: naive O(n) impl Solution { pub fn my_sqrt(x: i32) -> i32 { (1..).find(|&i| i > x / i).unwrap() - 1 } } <|fim_suffix|>//Version 3: Newton's method (finding fixed point) impl Solution { pub fn my_sqrt(x: i32) -> i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "ireina7/leetcode.note", "path": "/Rust/sqrtx.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//Version 3: Newton's method (finding fixed point) impl Solution { pub fn my_sqrt(x: i32) -> i32 { if x == 0 { return 0; } let x = x as usize; let mut n = x; while n > x / n { n = (n + x / n) / 2; } n as i32 } }<|fim_p...
code_fim
hard
{ "lang": "rust", "repo": "ireina7/leetcode.note", "path": "/Rust/sqrtx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kurble/ggnet path: /src/rpc.rs use super::*; use std::io::Cursor; /// Implemented by the `rpc!` macro. This trait performs a remote procedure call (RPC) that is /// encoded in the supplied message. /// Do not manually implement this trait, use `rpc!`. pub trait CallRPC { /// Process rpc c...
code_fim
hard
{ "lang": "rust", "repo": "Kurble/ggnet", "path": "/src/rpc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rpc_id = String::default(); rpc_id.reflect(&mut msg).unwrap(); $(if rpc_id == stringify!($fn_name) { // decode function arguments $(let mut $arg: $arg_ty = ::std::default::Default::default(); $arg.reflect(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "Kurble/ggnet", "path": "/src/rpc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // impl the trait to do requests impl<$($bound : $bound_ty),*> $trait_name for Node<$self, TagClient> where Self: NodeBase<TagClient> { $(fn $fn_name(&mut self $(, mut $arg : $arg_ty)*) { let mut ser = Serializer::new(vec![]); ...
code_fim
hard
{ "lang": "rust", "repo": "Kurble/ggnet", "path": "/src/rpc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let testvec : Vec<Frame> = vec![ Frame { score_1:10, score_2:None }, Frame { score_1: 5, score_2:None } ]; let game = Game{ frames: testvec, }; assert_eq!(15, calculate_score(&game)); assert_eq!(true, game.frames.iter().all(|x| frame_points(&x) <= 10 )); } }<|fi...
code_fim
medium
{ "lang": "rust", "repo": "crlsktr/bowling", "path": "/src/bowling/bowling.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_calculate_score() { let testvec : Vec<Frame> = vec![ Frame { score_1:10, score_2:None }, Frame { score_1: 5, score_2:None } ]; let game = Game{ frames: testvec, }; assert_eq!(15, calculate_score(&game)); assert_eq!(true, game.frames.iter().all(|...
code_fim
medium
{ "lang": "rust", "repo": "crlsktr/bowling", "path": "/src/bowling/bowling.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crlsktr/bowling path: /src/bowling/bowling.rs pub struct Frame { pub score_1:i32, pub score_2:Option<i32> } pub struct Game { pub frames : Vec<Frame>, } pub fn calculate_score(game:&Game) -> i32{ game.frames.iter().fold(0, |sum, val| sum + val.score_1) } <|fim_suffix|>#[cfg(test)] mod te...
code_fim
medium
{ "lang": "rust", "repo": "crlsktr/bowling", "path": "/src/bowling/bowling.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexpana/gliumvg path: /src/math.rs pub fn clamp<T: PartialOrd>(value: T, min: T, max: T) -> T { if value < min { return min; } if value > max { return max; } return value; } pub fn max<T: PartialOrd>(a: T, b: T) -> T { if a < b { b } else {...
code_fim
hard
{ "lang": "rust", "repo": "alexpana/gliumvg", "path": "/src/math.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn cross(x1: f32, y1: f32, x2: f32, y2: f32) -> f32 { x1 * y2 - x2 * y1 } /// /// The floating-point remainder of the division operation `x/y` calculated by this function /// is exactly the value `x - n*y`, where `n` is `x/y` with its fractional part truncated. /// /// See http://en.cppreference....
code_fim
hard
{ "lang": "rust", "repo": "alexpana/gliumvg", "path": "/src/math.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn tree_depth(root: Option<Rc<RefCell<TreeNode>>>, current_depth: i32, min_depth: &mut i32) -> i32 { match root { None => { *min_depth = std::cmp::min(*min_depth, current_depth); current_depth }, Some(root) => { ...
code_fim
hard
{ "lang": "rust", "repo": "chenhengqi/learn-rust-the-hard-way", "path": "/leetcode/lc-0111/solution.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenhengqi/learn-rust-the-hard-way path: /leetcode/lc-0111/solution.rs // Definition for a binary tree node. // #[derive(Debug, PartialEq, Eq)] // pub struct TreeNode { // pub val: i32, // pub left: Option<Rc<RefCell<TreeNode>>>, // pub right: Option<Rc<RefCell<TreeNode>>>, // } // // impl...
code_fim
medium
{ "lang": "rust", "repo": "chenhengqi/learn-rust-the-hard-way", "path": "/leetcode/lc-0111/solution.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezracelli/google-api-rust-client path: /crates/workflows/v1/src/lib.rs lder::default() } } } } } pub mod workflows { ...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/workflows/v1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ezracelli/google-api-rust-client path: /crates/workflows/v1/src/lib.rs serde :: Deserialize, )] pub struct QueryParameters { #[builder( ...
code_fim
hard
{ "lang": "rust", "repo": "ezracelli/google-api-rust-client", "path": "/crates/workflows/v1/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanElbert/pi-b-q-rust path: /src/bluetherm/packet/message_type.rs use std::fmt; bitflags! { pub flags MessageType: u8 { const NOTHING = 0u8, const RETRIEVE_INFO = 1u8, const SET_INFO = 2u8, const BUTTON_PRESS = 3u8, const RESERVED = 4u8, const...
code_fim
medium
{ "lang": "rust", "repo": "DanElbert/pi-b-q-rust", "path": "/src/bluetherm/packet/message_type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for MessageType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.bits) } }<|fim_prefix|>// repo: DanElbert/pi-b-q-rust path: /src/bluetherm/packet/message_type.rs use std::fmt; bitflags! { pub flags MessageType: u8 { const NOTHIN...
code_fim
medium
{ "lang": "rust", "repo": "DanElbert/pi-b-q-rust", "path": "/src/bluetherm/packet/message_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timofonic-comms/ruma path: /src/models/presence_list.rs //! Storage and querying of presence lists. use std::cmp; use diesel::{ delete, insert, Connection, ExpressionMethods, ExecuteDsl, FilterDsl, LoadDsl, SelectDsl, }; use diesel::expression::dsl::any; use die...
code_fim
hard
{ "lang": "rust", "repo": "timofonic-comms/ruma", "path": "/src/models/presence_list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut events = Vec::new(); for status in users_status { let last_update = status.updated_at.0; presence_key = cmp::max(last_update, presence_key); let presence_state: PresenceState = status.presence.parse().unwrap(); let last_active_ago =...
code_fim
hard
{ "lang": "rust", "repo": "timofonic-comms/ruma", "path": "/src/models/presence_list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: camshaft/wasp-demo path: /src/lib.rs use wasp::http::{HttpMapBody, HttpMessage, HttpRequest, HttpResponse}; <|fim_suffix|> HttpResponse::builder() .status(200) .body(format!( "Hello, {}!", request.uri().query().unwrap_or_else(|| "World") )) ...
code_fim
medium
{ "lang": "rust", "repo": "camshaft/wasp-demo", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let request: HttpRequest<String> = wasp::http::read_request() .expect("Could not read request") .map_body(); HttpResponse::builder() .status(200) .body(format!( "Hello, {}!", request.uri().query().unwrap_or_else(|| "World") )) ...
code_fim
medium
{ "lang": "rust", "repo": "camshaft/wasp-demo", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> HttpResponse::builder() .status(200) .body(format!( "Hello, {}!", request.uri().query().unwrap_or_else(|| "World") )) .expect("Could not build response") .send() .expect("Could not send response"); }<|fim_prefix|>// repo: camshaft...
code_fim
medium
{ "lang": "rust", "repo": "camshaft/wasp-demo", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zacfpearson/rust-sandbox path: /rust-by-example-tutorial/error-handling/iterating-over-results/src/main.rs fn main() { let strings = vec!["tofu", "93", "18"]; //ignore failed items let numbers_ignore: Vec<_> = strings .iter() .map(|s| s.parse::<i32>()) .filte...
code_fim
hard
{ "lang": "rust", "repo": "zacfpearson/rust-sandbox", "path": "/rust-by-example-tutorial/error-handling/iterating-over-results/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (numbers_partition_clean, errors_partition_clean): (Vec<_>, Vec<_>) = strings .into_iter() .map(|s| s.parse::<i32>()) .partition(Result::is_ok); let numbers_partition_clean: Vec<_> = numbers_partition_clean.into_iter().map(Result::unwrap).collect(); let errors_parti...
code_fim
hard
{ "lang": "rust", "repo": "zacfpearson/rust-sandbox", "path": "/rust-by-example-tutorial/error-handling/iterating-over-results/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //collect all valid values and failures with partition let (numbers_partition, errors_partition): (Vec<_>, Vec<_>) = strings .iter() .map(|s| s.parse::<i32>()) .partition(Result::is_ok); println!("Numbers: {:?}", numbers_partition); println!("Errors: {:?}", errors_p...
code_fim
medium
{ "lang": "rust", "repo": "zacfpearson/rust-sandbox", "path": "/rust-by-example-tutorial/error-handling/iterating-over-results/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn realm_path() { let realm_path = RealmPath::from(vec!["a".to_string(), "b".to_string(), "c".to_string()]); assert_eq!("a/b/c".to_string(), realm_path.as_string()); let realm_path = RealmPath::from(vec!["a".to_string()]); assert_eq!("a".to_string(), realm_p...
code_fim
hard
{ "lang": "rust", "repo": "OpenTrustGroup/fuchsia", "path": "/garnet/bin/archivist/src/collection/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(parent) = path.parent() { path_to_event_data(&parent).ok() } else { None } } /// Starts watching the hub. /// /// This method consumes the HubCollector. /// /// Returns a future that must be polled. pub async fn start...
code_fim
hard
{ "lang": "rust", "repo": "OpenTrustGroup/fuchsia", "path": "/garnet/bin/archivist/src/collection/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OpenTrustGroup/fuchsia path: /garnet/bin/archivist/src/collection/mod.rs red in extra files in the archive). pub extra_data: Option<ExtraDataMap>, } pub type ExtraDataMap = HashMap<String, ExtraData>; /// Extra data associated with a component event. /// /// This extra data is stored in th...
code_fim
hard
{ "lang": "rust", "repo": "OpenTrustGroup/fuchsia", "path": "/garnet/bin/archivist/src/collection/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> producer.events().for_each(move |event| { match event { ProducerEvent::Data(value) => { println!("{}", value); producer.request(1); }, _ => { } } }); }); }<|f...
code_fim
hard
{ "lang": "rust", "repo": "omnistreams/omnistreams-rs", "path": "/examples/range_producer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: omnistreams/omnistreams-rs path: /examples/range_producer.rs use omnistreams::{Producer, RangeProducerBuilder, ProducerEvent}; <|fim_suffix|> producer.request(1); producer.events().for_each(move |event| { match event { ProducerEvent::Data(value) => {...
code_fim
hard
{ "lang": "rust", "repo": "omnistreams/omnistreams-rs", "path": "/examples/range_producer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> producer.request(1); producer.events().for_each(move |event| { match event { ProducerEvent::Data(value) => { println!("{}", value); producer.request(1); }, _ => { } ...
code_fim
hard
{ "lang": "rust", "repo": "omnistreams/omnistreams-rs", "path": "/examples/range_producer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>&self) -> WRP_R { WRP_R::new((self.bits & 0xffff_ffff) as u32) } }<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32f3/src/stm32f303/flash/wrpr.rs #[doc = "Reader of register WRPR"] pub type R = crate::R<u32, super::WRPR>; #<|fim_middle|>[doc = "Reader of field `WRP`"] pub t...
code_fim
medium
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f303/flash/wrpr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32f3/src/stm32f303/flash/wrpr.rs #[doc = "Reader of register WRPR"] pub type R = crate::R<u32, super::WRPR>; #<|fim_suffix|> #[doc = "Bits 0:31 - Write protect"] #[inline(always)] pub fn wrp(&self) -> WRP_R { WRP_R::new((self.bits & 0...
code_fim
medium
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32f3/src/stm32f303/flash/wrpr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> record_updates(&prog, upds, n); let mut upds_vec = Vec::with_capacity(n as usize); for i in 0..n { let upd = match updcmd2upd(Box::from_raw(*upds.offset(i as isize)).as_ref()) { Ok(upd) => upd, Err(e) => { prog.eprintln(&format!("ddlog_apply_upd...
code_fim
hard
{ "lang": "rust", "repo": "gfour/differential-datalog", "path": "/rust/template/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub unsafe extern "C" fn ddlog_dump_table( prog: *const HDDlog, table: libc::size_t, cb: extern "C" fn(arg: *mut raw::c_void, rec: *const record::Record) -> bool, cb_arg: *mut raw::c_void) -> raw::c_int { if prog.is_null() { return -1; }; let pro...
code_fim
hard
{ "lang": "rust", "repo": "gfour/differential-datalog", "path": "/rust/template/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gfour/differential-datalog path: /rust/template/lib.rs fferential_datalog::record; use differential_datalog::record::{FromRecord, IntoRecord, Mutator}; use abomonation::Abomonation; use fnv::{FnvHashSet, FnvHashMap}; use std::fmt::Display; use std::fmt; use std::sync; use std::hash::Hash; use s...
code_fim
hard
{ "lang": "rust", "repo": "gfour/differential-datalog", "path": "/rust/template/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: procyon-rs/vega_lite_4.rs path: /examples/line_with_interval.rs use vega_lite_4::*; fn main() -> Result<(), Box<dyn std::error::Error>> { // The chart let chart = VegaliteBuilder::default() .title("Line Chart with Confidence Interval Band") .height(200.) .width(3...
code_fim
hard
{ "lang": "rust", "repo": "procyon-rs/vega_lite_4.rs", "path": "/examples/line_with_interval.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>() .y(YClassBuilder::default() .title("Mean of Miles per Gallon (95% CIs)") .field("Miles_per_Gallon") .position_def_type(Type::Quantitative) .build()?) ...
code_fim
hard
{ "lang": "rust", "repo": "procyon-rs/vega_lite_4.rs", "path": "/examples/line_with_interval.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use inle_math::rect::Rect; use inle_resources::gfx::tex_path; use inle_test::test_common; use serial_test::serial; #[test] #[serial] fn animation_system() { let (_win, _glfw) = test_common::load_gl_pointers(); let (mut...
code_fim
hard
{ "lang": "rust", "repo": "silverweed/ecsde", "path": "/inle/inle_app/src/animation_system.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: silverweed/ecsde path: /inle/inle_app/src/animation_system.rs use inle_ecs::ecs_world::Ecs_World; use inle_gfx::components::{C_Animated_Sprite, C_Renderable}; use std::time::Duration; pub fn update(dt: &Duration, ecs_world: &mut Ecs_World) { let dt_secs = dt.as_secs_f32(); foreach_enti...
code_fim
hard
{ "lang": "rust", "repo": "silverweed/ecsde", "path": "/inle/inle_app/src/animation_system.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (_win, _glfw) = test_common::load_gl_pointers(); let (mut gres, _, env) = test_common::create_test_resources_and_env(); let mut ecs_world = Ecs_World::new(); let e = ecs_world.new_entity(); { let mut r = C_Renderable::default(); r.materi...
code_fim
hard
{ "lang": "rust", "repo": "silverweed/ecsde", "path": "/inle/inle_app/src/animation_system.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use my_strategy::examples::{GameType, example_world, example_rng}; use my_strategy::my_strategy::simulator::Simulator; use my_strategy::my_strategy::my_strategy_impl::MyStrategyImpl; let world = example_world(GameType::ThreeRobotsWithNitro); let mut rng = example_rng(&world.rules); ...
code_fim
hard
{ "lang": "rust", "repo": "elsid/CodeBall", "path": "/tests/my_strategy_impl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elsid/CodeBall path: /tests/my_strategy_impl.rs use my_strategy::my_strategy::simulator::Simulator; use my_strategy::my_strategy::my_strategy_impl::MyStrategyImpl; use my_strategy::my_strategy::random::XorShiftRng; #[test] fn test_two_robots_first_action_to_go_to_goalkeeper_position() { use...
code_fim
hard
{ "lang": "rust", "repo": "elsid/CodeBall", "path": "/tests/my_strategy_impl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run_server(address: &str, set_size: usize, id_size: usize, max_payload: u64, payload_size: usize){ let address = format!("{}{}", address,":3000"); let listener = TcpListener::bind(address).unwrap(); // accept connections and process them, spawning a new thread for each one println!...
code_fim
hard
{ "lang": "rust", "repo": "Ra1issa/match-compute", "path": "/src/bin/simple-server/utils/run_server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run_server(address: &str, set_size: usize, id_size: usize, max_payload: u64, payload_size: usize){ let address = format!("{}{}", address,":3000"); let listener = TcpListener::bind(address).unwrap(); // accept connections and process them, spawning a new thread for each one println!(...
code_fim
medium
{ "lang": "rust", "repo": "Ra1issa/match-compute", "path": "/src/bin/simple-server/utils/run_server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ra1issa/match-compute path: /src/bin/simple-server/utils/run_server.rs // A simple single threaded example of PSI with match and compute use match_compute::util; use popsicle::psty_payload::{Sender}; use scuttlebutt::{AesRng, TrackChannel, SymChannel}; use std::{ net::{TcpListener, TcpStre...
code_fim
hard
{ "lang": "rust", "repo": "Ra1issa/match-compute", "path": "/src/bin/simple-server/utils/run_server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1748_sum_of_unique_elements/iterative_3.rs pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn sum_of_unique(nums: Vec<i32>) -> i32 { ...
code_fim
medium
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_1748_sum_of_unique_elements/iterative_3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::sum_of_unique(nums) } } #[cfg(test)] mod tests { #[test] fn test_solution() { super::super::tests::run::<super::Solution>(); } }<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1748_sum_of_unique_elements/iterative_3.rs pub struct Solution; // ------------...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_1748_sum_of_unique_elements/iterative_3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/flake8_boolean_trap/rules/check_positional_boolean_in_def.rs use ruff_python_ast::{ self as ast, Constant, Decorator, Expr, ParameterWithDefault, Parameters, Ranged, }; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_ma...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/flake8_boolean_trap/rules/check_positional_boolean_in_def.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // check for both bool (python class) and 'bool' (string annotation) let hint = match expr.as_ref() { Expr::Name(name) => &name.id == "bool", Expr::Constant(ast::ExprConstant { value: Constant::Str(value), .. }) => value =...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/flake8_boolean_trap/rules/check_positional_boolean_in_def.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut hanoi = Hanoi::new(11); hanoi.snapshot(20); println!("{}", hanoi); let mut hanoi2 = Hanoi::new(11); hanoi2.snapshot_v2(20); println!("{}", hanoi2); }<|fim_prefix|>// repo: wtnbass/rustproj path: /hanoi/src/main.rs mod hanoi; use hanoi::Hanoi; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "wtnbass/rustproj", "path": "/hanoi/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wtnbass/rustproj path: /hanoi/src/main.rs mod hanoi; use hanoi::Hanoi; <|fim_suffix|> let mut hanoi = Hanoi::new(11); hanoi.snapshot(20); println!("{}", hanoi); let mut hanoi2 = Hanoi::new(11); hanoi2.snapshot_v2(20); println!("{}", hanoi2); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "wtnbass/rustproj", "path": "/hanoi/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut hanoi2 = Hanoi::new(11); hanoi2.snapshot_v2(20); println!("{}", hanoi2); }<|fim_prefix|>// repo: wtnbass/rustproj path: /hanoi/src/main.rs mod hanoi; use hanoi::Hanoi; <|fim_middle|>fn main() { let mut hanoi = Hanoi::new(11); hanoi.snapshot(20); println!("{}", hanoi);
code_fim
medium
{ "lang": "rust", "repo": "wtnbass/rustproj", "path": "/hanoi/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AntonZelenin/rust-kvs path: /examples/1000_structs_serde.rs use serde::{Serialize, Deserialize}; use std::fs::OpenOptions; use std::io::prelude::*; use std::io::SeekFrom; use rand::Rng; use num_derive::FromPrimitive; use num_traits::FromPrimitive; use bson; <|fim_suffix|> while let Ok(de...
code_fim
hard
{ "lang": "rust", "repo": "AntonZelenin/rust-kvs", "path": "/examples/1000_structs_serde.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = rand::thread_rng(); (0..num) .map(|_| { Move { axis: FromPrimitive::from_i32(rng.gen_range(0, 2)).unwrap(), value: rng.gen_range(0, 10), } }) .collect() }<|fim_prefix|>// repo: AntonZelenin/rust-kvs path...
code_fim
hard
{ "lang": "rust", "repo": "AntonZelenin/rust-kvs", "path": "/examples/1000_structs_serde.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while let Ok(decoded) = bson::decode_document(&mut f) { println!("{:?}", decoded); } } fn generate_structs(num: usize) -> Vec<Move> { let mut rng = rand::thread_rng(); (0..num) .map(|_| { Move { axis: FromPrimitive::from_i32(rng.gen_range(0, 2))...
code_fim
hard
{ "lang": "rust", "repo": "AntonZelenin/rust-kvs", "path": "/examples/1000_structs_serde.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1309_decrypt_string_from_alphabet_to_integer_mapping/mod.rs pub mod iterative; pub trait Solution { fn freq_alphabets(s: String) -> String; } <|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [("10#11#12", "jkab"), ("1326#", "acz"), (...
code_fim
easy
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_1309_decrypt_string_from_alphabet_to_integer_mapping/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run<S: Solution>() { let test_cases = [("10#11#12", "jkab"), ("1326#", "acz"), ("26#11#418#5", "zkdre")]; for (s, expected) in test_cases { assert_eq!(S::freq_alphabets(s.to_string()), expected); } } }<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/pr...
code_fim
easy
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_1309_decrypt_string_from_alphabet_to_integer_mapping/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ammpio/ammp-edge path: /rust/src/helpers/commands.rs use std::collections::HashSet; use std::ffi::OsString; use std::fs; use std::path::PathBuf; use std::process::Command; use once_cell::sync::Lazy; use crate::helpers::base_path; <|fim_suffix|> match Command::new(cmd_path).output() { ...
code_fim
hard
{ "lang": "rust", "repo": "ammpio/ammp-edge", "path": "/rust/src/helpers/commands.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match Command::new(cmd_path).output() { Ok(output) => { let message = format!( "Command: {}\n{}\nstdout: {}\nstderr: {}", cmd, output.status, String::from_utf8_lossy(&output.stdout), String::from_utf8_l...
code_fim
hard
{ "lang": "rust", "repo": "ammpio/ammp-edge", "path": "/rust/src/helpers/commands.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: microsoft/synthetic-data-showcase path: /packages/lib-wasm/src/processing/navigator/attributes_intersection.rs use js_sys::{Array, Object, Reflect::set}; use std::{collections::HashMap, convert::TryFrom, sync::Arc}; use wasm_bindgen::{JsCast, JsValue}; use crate::utils::js::{JsAttributesInterse...
code_fim
hard
{ "lang": "rust", "repo": "microsoft/synthetic-data-showcase", "path": "/packages/lib-wasm/src/processing/navigator/attributes_intersection.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = Object::new(); set( &result, &"value".into(), &attributes_intersection.value.as_str().into(), )?; set( &result, &"estimatedCount".into(), &attributes_intersection.estimated_count.into(), ...
code_fim
medium
{ "lang": "rust", "repo": "microsoft/synthetic-data-showcase", "path": "/packages/lib-wasm/src/processing/navigator/attributes_intersection.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunnygleason/solana path: /src/tvu.rs //! The `tvu` module implements the Transaction Validation Unit, a //! multi-stage transaction validation pipeline in software. //! //! 1. BlobFetchStage //! - Incoming blobs are picked up from the TVU sockets and repair socket. //! 2. RetransmitStage //! - ...
code_fim
hard
{ "lang": "rust", "repo": "sunnygleason/solana", "path": "/src/tvu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Test that message sent from leader to target1 and replayed to target2 #[test] fn test_replay() { solana_logger::setup(); let leader = Node::new_localhost(); let target1_keypair = Keypair::new(); let target1 = Node::new_localhost_with_pubkey(target1_keypair.p...
code_fim
hard
{ "lang": "rust", "repo": "sunnygleason/solana", "path": "/src/tvu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let tx0 = SystemTransaction::new_account( &mint_keypair, bob_keypair.pubkey(), transfer_amount, cur_hash, 0, ); let entry_tick1 = next_entry_mut(&mut cur_hash, i + 1, vec![]); le...
code_fim
hard
{ "lang": "rust", "repo": "sunnygleason/solana", "path": "/src/tvu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gamma-delta/hex-study path: /src/modes/overworld/spells/componentinators.rs //! Turn `RenderedSpell`s into entities. use std::f32::consts::TAU; use hecs::World; use macroquad::prelude::{vec2, vec3, PURPLE}; use macroquad_particles::{ColorCurve, Curve, EmissionShape, EmitterConfig, Partic...
code_fim
hard
{ "lang": "rust", "repo": "gamma-delta/hex-study", "path": "/src/modes/overworld/spells/componentinators.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> world.spawn_with_physics(physics, (particles, proj, timer), coll, Some(rb)); } } RenderedSpellKind::Light { pos } => { let config = EmitterConfig { amount: 20, initial_direction: vec2(...
code_fim
hard
{ "lang": "rust", "repo": "gamma-delta/hex-study", "path": "/src/modes/overworld/spells/componentinators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let particles = ParticleEmitter::new(config, true); let collider = ColliderBuilder::ball(0.1) .translation((pos + towards / 4.0).into()) .collision_groups(InteractionGroups::none()) .build(); ...
code_fim
hard
{ "lang": "rust", "repo": "gamma-delta/hex-study", "path": "/src/modes/overworld/spells/componentinators.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> load: wgpu::LoadOp::Clear(wgpu::Color::BLACK), store: true, }, }], depth_stencil_attachment: None, }); } }<|fim_prefix|>// repo: agausmann/global-clock path: /src/background.rs use crate::GraphicsContext; pub struct Background ...
code_fim
hard
{ "lang": "rust", "repo": "agausmann/global-clock", "path": "/src/background.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agausmann/global-clock path: /src/background.rs use crate::GraphicsContext; pub struct Background {} impl Background { pub fn new(_gfx: &GraphicsContext) -> Self { Self {} } pub fn draw(&self, encoder: &mut wgpu::CommandEncoder, frame_view: &wgpu::TextureView) { en...
code_fim
hard
{ "lang": "rust", "repo": "agausmann/global-clock", "path": "/src/background.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hawnzug/gmachine path: /src/main.rs mod ast; mod parser; mod gmachine; mod lexer; mod token; mod heap; mod compiler; use std::env; use std::path::Path; use std::process; <|fim_suffix|> let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("Usage: {} FILENA...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let prog = parse(file_path).unwrap_or_else(|err| { println!("{}", err); process::exit(1); }); compile(prog) .run() .unwrap_or_else(|e...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn run_prog<P: AsRef<Path>>(file_path: P) { let prog = parse(file_path).unwrap_or_else(|err| { println!("{}", err); process::exit(1); }); compile(pro...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bumzack/godot path: /raytracer_lib_no_std/src/basics/color.rs use core::f32::MAX; use core::ops::{Add, Div, Mul, Sub}; #[cfg(feature = "use_serde")] use serde::{Deserialize, Serialize}; use math::assert_two_float; pub const BLACK: Color = Color { r: 0.0, g: 0.0, b: 0.0 }; pub const WHITE: Col...
code_fim
hard
{ "lang": "rust", "repo": "bumzack/godot", "path": "/raytracer_lib_no_std/src/basics/color.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Mul<f32> for &'a Color { type Output = Color; fn mul(self, rhs: f32) -> Color { Color { r: self.r * rhs, g: self.g * rhs, b: self.b * rhs, } } } impl<'a, 'b> Mul<&'b Color> for &'a Color { type Output = Color; fn mul(self,...
code_fim
hard
{ "lang": "rust", "repo": "bumzack/godot", "path": "/raytracer_lib_no_std/src/basics/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Hands-On-Functional-Programming-in-Rust path: /Chapter04/src/physics.rs extern crate floating_duration; use std::time::Instant; use floating_duration::{TimeAsFloat, TimeFormat}; use std::{thread, time}; use serde; pub trait Motor { fn force_of_voltage(&self, v: f64) -> f64; ...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Hands-On-Functional-Programming-in-Rust", "path": "/Chapter04/src/physics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> est.location = est.location + est.velocity * dt; est.velocity = est.velocity + est.acceleration * dt; est.acceleration = { let F = est.motor_input.calculate_force(); let m = esp.carriage_weight; -9.8 + F/m }; //5.2. If next floor request in queue i...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Hands-On-Functional-Programming-in-Rust", "path": "/Chapter04/src/physics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl MotorVoltage for SimpleMotorInput { fn voltage(&self) -> f64 { match *self { SimpleMotorInput::Up { voltage: v } => { v } SimpleMotorInput::Down { voltage: v } => { -v } } } } pub fn simulate_elevator<MC: MotorController, DR: DataRecorder>(esp: ElevatorSpecif...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Hands-On-Functional-Programming-in-Rust", "path": "/Chapter04/src/physics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> color: &str, bag_map: &HashMap<String, HashSet<String>>, parents: &mut HashSet<String>, ) { if parents.contains(color) { return; } parents.insert(color.to_string()); if let Some(bags) = bag_map.get(color) { bags.iter().fo...
code_fim
hard
{ "lang": "rust", "repo": "triglav/advent_of_code", "path": "/2020/day07/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: triglav/advent_of_code path: /2020/day07/src/main.rs use std::{ collections::{HashMap, HashSet}, io::{self, BufRead}, }; use regex::Regex; fn main() { let stdin = io::stdin(); let lines = stdin.lock().lines().map(|l| l.unwrap()); let re = Regex::new(r"^(\d+) ((\w|\s)+) bags...
code_fim
hard
{ "lang": "rust", "repo": "triglav/advent_of_code", "path": "/2020/day07/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(bags) = bag_map.get(color) { bags.iter().for_each(|b| { find_parent(b, bag_map, parents); }); } } let mut bags = HashSet::<String>::new(); find_parent("shiny gold", &bag_map, &mut bags); println!("{:?}", bags.len() - 1); ...
code_fim
hard
{ "lang": "rust", "repo": "triglav/advent_of_code", "path": "/2020/day07/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if used { // Flip the switch texture let sidedef = linedef.sidedefs[0].as_ref().unwrap(); let linedef_dynamic = &mut map_dynamic.linedefs[linedef_ref.index]; let sidedef_dynamic = linedef_dynamic.sidedefs[0].as_mut().unwrap(); for slot in [SidedefSlot::Top, SidedefSlot::Middl...
code_fim
hard
{ "lang": "rust", "repo": "nbraud/ferret", "path": "/src/doom/door.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbraud/ferret path: /src/doom/door.rs use crate::{ assets::{AssetHandle, AssetStorage}, audio::Sound, doom::{ client::{UseAction, UseEvent}, components::Transform, map::{ textures::{TextureType, Wall}, LinedefRef, Map, MapDynamic, SectorRef, SidedefSlot, }, physics::{BoxCollid...
code_fim
hard
{ "lang": "rust", "repo": "nbraud/ferret", "path": "/src/doom/door.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut done = Vec::new(); for (entity, sector_ref, door_active) in (&entities, &sector_ref_component, &mut door_active_component).join() { let map_dynamic = map_dynamic_component .get_mut(sector_ref.map_entity) .unwrap(); let map = map_asset_storage.get(&map_dynamic.map).unwrap();...
code_fim
hard
{ "lang": "rust", "repo": "nbraud/ferret", "path": "/src/doom/door.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> test!( |c| { skip_eof_chunk!(c); c.before("<span>", ContentType::Text); c.before("<div>Hey</div>", ContentType::Html); c.before("<foo>", ContentType::Html); c.after("</foo>", Con...
code_fim
hard
{ "lang": "rust", "repo": "cloudflare/lol-html", "path": "/src/rewritable_units/tokens/text_chunk.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cloudflare/lol-html path: /src/rewritable_units/tokens/text_chunk.rs use super::{Mutations, Token}; use crate::base::Bytes; use crate::html::TextType; use encoding_rs::Encoding; use std::any::Any; use std::borrow::Cow; use std::fmt::{self, Debug}; /// An HTML text node chunk. /// /// Since the ...
code_fim
hard
{ "lang": "rust", "repo": "cloudflare/lol-html", "path": "/src/rewritable_units/tokens/text_chunk.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn removed() { test!( |c| { skip_eof_chunk!(c); assert!(!c.removed()); c.remove(); assert!(c.removed()); c.before("<before>", ContentType::Html); ...
code_fim
hard
{ "lang": "rust", "repo": "cloudflare/lol-html", "path": "/src/rewritable_units/tokens/text_chunk.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen(start)] pub fn setup() { utils::set_panic_hook(); console!("Enabled Panic Hook"); } #[wasm_bindgen] pub fn generate_uuid() -> String { let uuid = Uuid::new_v4(); return format!("{}", uuid); } #[wasm_bindgen] pub fn generate_keys() -> js_sys::Array { let pubkeys = js...
code_fim
hard
{ "lang": "rust", "repo": "fausecteam/faustctf-2021-merklechat", "path": "/wasm/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fausecteam/faustctf-2021-merklechat path: /wasm/src/lib.rs mod utils; mod log; use rand::Rng; use aes_gcm::Aes128Gcm; use aes_gcm::aead::{Aead, NewAead, generic_array::GenericArray}; use serde::{Deserialize, Serialize}; use uuid::Uuid; use wasm_bindgen::prelude::*; use std::convert::From; ...
code_fim
hard
{ "lang": "rust", "repo": "fausecteam/faustctf-2021-merklechat", "path": "/wasm/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl Div<f64> for Color { type Output = Self; fn div(self, scalar: f64) -> Self { Self { r: self.r / scalar, g: self.g / scalar, b: self.b / scalar, } } } impl PartialEq for Color { fn eq(&self, other: &Self) -> bool { is_equal(...
code_fim
hard
{ "lang": "rust", "repo": "maxmelander/raytracer", "path": "/src/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxmelander/raytracer path: /src/color.rs use std::ops::{Add, Div, Mul, Sub}; use super::utils::is_equal; #[derive(Debug, Copy, Clone)] pub struct Color { pub r: f64, pub g: f64, pub b: f64, } #[allow(dead_code)] impl Color { pub fn new(r: f64, g: f64, b: f64) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "maxmelander/raytracer", "path": "/src/color.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn mul(self, other: Self) -> Self { Self { r: self.r * other.r, g: self.g * other.g, b: self.b * other.b, } } } impl Div<f64> for Color { type Output = Self; fn div(self, scalar: f64) -> Self { Self { r: self.r / sca...
code_fim
hard
{ "lang": "rust", "repo": "maxmelander/raytracer", "path": "/src/color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }