text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: mark-lumbao/budget-calc path: /src/main.rs use std::env; mod util; fn main() { // START: Argument collection let args: Vec<String> = env::args().collect(); let bank_balance = args[1].parse::<u32>(); let wallet_balance = args[2].parse::<u32>(); let payment_balance = args[3].parse::<u32...
code_fim
medium
{ "lang": "rust", "repo": "mark-lumbao/budget-calc", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iptq/rosu-v2 path: /src/metrics.rs #![cfg(feature = "metrics")] use prometheus::{IntCounter, IntCounterVec, Opts}; pub(crate) struct Metrics { pub(crate) counters: IntCounterVec, pub(crate) beatmap: IntCounter, pub(crate) beatmap_scores: IntCounter, pub(crate) beatmap_user_sco...
code_fim
hard
{ "lang": "rust", "repo": "iptq/rosu-v2", "path": "/src/metrics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Metrics { #[cold] pub(crate) fn new() -> Self { let opts = Opts::new("osu_requests", "osu!api request count"); let counters = IntCounterVec::new(opts, &["type"]).unwrap(); Self { beatmap: counters.with_label_values(&["Beatmap"]), beatmap_scores...
code_fim
hard
{ "lang": "rust", "repo": "iptq/rosu-v2", "path": "/src/metrics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> counters, } } } #[cfg(test)] mod tests { use super::*; #[test] fn inc() { let metrics = Metrics::new(); metrics.beatmap.inc(); metrics.user.inc(); metrics.wiki.inc(); metrics.user.inc(); let beatmap = metrics.counters....
code_fim
hard
{ "lang": "rust", "repo": "iptq/rosu-v2", "path": "/src/metrics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "binary-cache")] pub mod binary_cache;<|fim_prefix|>// repo: VerteDinde/rust-skia path: /skia-bindings/build_support.rs //! Build support functions for the Rust-Skia library. <|fim_middle|>pub mod android; pub mod cargo; pub mod clang; pub mod ios; pub mod llvm; pub mod skia; pub mod vs;...
code_fim
medium
{ "lang": "rust", "repo": "VerteDinde/rust-skia", "path": "/skia-bindings/build_support.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VerteDinde/rust-skia path: /skia-bindings/build_support.rs //! Build support functions for the Rust-Skia library. <|fim_suffix|>#[cfg(feature = "binary-cache")] pub mod binary_cache;<|fim_middle|>pub mod android; pub mod cargo; pub mod clang; pub mod ios; pub mod llvm; pub mod skia; pub mod vs;...
code_fim
medium
{ "lang": "rust", "repo": "VerteDinde/rust-skia", "path": "/skia-bindings/build_support.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ArthurSonzogni/hello_triangle_wasm_rust path: /src/lib.rs use std::ffi::c_void; // This is called when the Javascript initializes #[no_mangle] pub extern "C" fn start() { unsafe { imported::setup_canvas(); // Create the vertex buffer let vertex_buffer = imported::c...
code_fim
hard
{ "lang": "rust", "repo": "ArthurSonzogni/hello_triangle_wasm_rust", "path": "/src/lib.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn bind_buffer(target: GLEnum, gl_object: Option<JSObject>) { unsafe { imported::bind_buffer(target, gl_object.unwrap_or(JSObject::null())) } } pub fn buffer_data_f32(target: GLEnum, data: &[f32], usage: GLEnum) { unsafe { imported::buffer_data_f32( target, dat...
code_fim
hard
{ "lang": "rust", "repo": "ArthurSonzogni/hello_triangle_wasm_rust", "path": "/src/lib.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ferhatgec/systemf path: /src/lib.rs // systemf - c-like syscall macro // aka an interface of ::Process // // MIT License // // Copyright (c) 2021 Ferhat Geçdoğan All Rights Reserved. // Distributed under the terms of the MIT License. // // #[macro_export] macro_rules! systemf { ($arg: expr)...
code_fim
medium
{ "lang": "rust", "repo": "ferhatgec/systemf", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mod tests { #[test] fn hello_world() { systemf!("echo hello, world!"); } } }<|fim_prefix|>// repo: ferhatgec/systemf path: /src/lib.rs // systemf - c-like syscall macro // aka an interface of ::Process // // MIT License // // Copyright (c) 2021 Ferhat Geçdoğan ...
code_fim
medium
{ "lang": "rust", "repo": "ferhatgec/systemf", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightdiscord/Shushus path: /crates/shushus-oauth2/src/config.rs use crate::Error; use shushus::http::Uri; use failure::Fallible; macro_rules! builder_fields { ($struct:ident => [$(($field:ident, $type:ty)),+]) => { impl $struct { $( pub fn $field(mut sel...
code_fim
hard
{ "lang": "rust", "repo": "lightdiscord/Shushus", "path": "/crates/shushus-oauth2/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Error type pub fn finalize(self) -> Fallible<Config> { let ConfigBuilder { client_id, client_secret, redirect_url, authorization_url, token_url, scopes } = self; let needed = ( cli...
code_fim
hard
{ "lang": "rust", "repo": "lightdiscord/Shushus", "path": "/crates/shushus-oauth2/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut v = vec![11, 8, 4, 6, 13, 1, 3]; sort(&mut v); assert_eq!(v, [1, 3, 4, 6, 8, 11, 13]); } }<|fim_prefix|>// repo: nickmurr/algorithms-data-structures path: /src/sorting/selection.rs // Сортировка выбором pub fn sort<T>(list: &mut [T]) where T: PartialOrd + std::fmt...
code_fim
medium
{ "lang": "rust", "repo": "nickmurr/algorithms-data-structures", "path": "/src/sorting/selection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_selection_sort() { let mut v = vec![11, 8, 4, 6, 13, 1, 3]; sort(&mut v); assert_eq!(v, [1, 3, 4, 6, 8, 11, 13]); } }<|fim_prefix|>// repo: nickmurr/algorithms-data-structures path: /src/sorting/selection.rs // Сортировка выбором pub fn sort<T>(list: &...
code_fim
medium
{ "lang": "rust", "repo": "nickmurr/algorithms-data-structures", "path": "/src/sorting/selection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickmurr/algorithms-data-structures path: /src/sorting/selection.rs // Сортировка выбором pub fn sort<T>(list: &mut [T]) where T: PartialOrd + std::fmt::Debug + Ord, { for i in 0..list.len() { if let Some((idx, _)) = list.iter().enumerate().skip(i).min_by_key(|x| x.1) { ...
code_fim
medium
{ "lang": "rust", "repo": "nickmurr/algorithms-data-structures", "path": "/src/sorting/selection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leogtzr/rustlearning path: /map_iter1/src/main.rs fn main() { let v1 = vec![5, 4, 1]; <|fim_suffix|> for x in v1_iter { println!("x: {}", x); } println!("{:?}", v1); }<|fim_middle|> let v1_iter = v1.iter().map(|x| x + 1);
code_fim
easy
{ "lang": "rust", "repo": "leogtzr/rustlearning", "path": "/map_iter1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", v1); }<|fim_prefix|>// repo: leogtzr/rustlearning path: /map_iter1/src/main.rs fn main() { let v1 = vec![5, 4, 1]; let v1_iter = v1.iter().map(|x| x + 1); <|fim_middle|> for x in v1_iter { println!("x: {}", x); }
code_fim
medium
{ "lang": "rust", "repo": "leogtzr/rustlearning", "path": "/map_iter1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for x in v1_iter { println!("x: {}", x); } println!("{:?}", v1); }<|fim_prefix|>// repo: leogtzr/rustlearning path: /map_iter1/src/main.rs fn main() { let v1 = vec![5, 4, 1]; <|fim_middle|> let v1_iter = v1.iter().map(|x| x + 1);
code_fim
easy
{ "lang": "rust", "repo": "leogtzr/rustlearning", "path": "/map_iter1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peku33/logicblocks path: /Controller/src/devices/gui_summary.rs use crate::util::waker_stream::mpsc; #[derive(Debug)] pub struct Waker { inner: mpsc::Signal, } impl Waker { pub fn new() -> Self { let inner = mpsc::Signal::new(); Self { inner } } pub fn wake(&se...
code_fim
medium
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/gui_summary.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub trait DeviceBase { fn waker(&self) -> &Waker; fn value(&self) -> Box<dyn erased_serde::Serialize + Send + Sync + 'static>; } impl<T: Device> DeviceBase for T { fn waker(&self) -> &Waker { self.waker() } fn value(&self) -> Box<dyn erased_serde::Serialize + Send + Sync + ...
code_fim
medium
{ "lang": "rust", "repo": "peku33/logicblocks", "path": "/Controller/src/devices/gui_summary.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); match args.len() { 1 => show_help(), 2 => { let cmd = &args[1].to_lowercase(); match &cmd[..] { "h" => show_help(), "play" | "s" => play(conn), "pause" | "p" => p...
code_fim
hard
{ "lang": "rust", "repo": "r3b311i0n/mpd-rs-interface", "path": "/src/bin/mpd-ctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_current_info(mut conn: Client) { let title = get_tag(&mut conn, "title"); let album = get_tag(&mut conn, "album"); let artist = get_tag(&mut conn, "artist"); let duration = get_tag(&mut conn, "duration"); let file = get_tag(&mut conn, "file"); let coloured_string = format!("...
code_fim
hard
{ "lang": "rust", "repo": "r3b311i0n/mpd-rs-interface", "path": "/src/bin/mpd-ctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r3b311i0n/mpd-rs-interface path: /src/bin/mpd-ctrl.rs extern crate mpd_rs_interface; extern crate colored; extern crate mpd; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate serde; extern crate xdg; use colored::*; use mpd::Client; use std::net::TcpStream; use std:...
code_fim
hard
{ "lang": "rust", "repo": "r3b311i0n/mpd-rs-interface", "path": "/src/bin/mpd-ctrl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rloic/tp-aaia-blocks-worl path: /src/algorithms/ida_star.rs use crate::NonUniformProblem; use std::io::{stdout, Write}; use crate::algorithms::{Cost, best_cost_first, WeightedAction}; use std::fmt::Debug; use std::option::Option; pub fn ida_star<State, C, Action, Predicate, Heuristic>(mut state...
code_fim
hard
{ "lang": "rust", "repo": "rloic/tp-aaia-blocks-worl", "path": "/src/algorithms/ida_star.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut actions: Vec<(WeightedAction<Action, C>, C)> = Vec::new(); for weighted_action in &state.weighted_actions() { state.apply(&weighted_action.action); if !path.contains(state) { actions.push((weighted_action.clone(), heuristic(state))); } state.rest...
code_fim
hard
{ "lang": "rust", "repo": "rloic/tp-aaia-blocks-worl", "path": "/src/algorithms/ida_star.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laopo001/raytrace-parallel path: /examples/test.rs extern crate cgmath; use wasm_math::vec3::Vec3; use cgmath::*; <|fim_suffix|> assert_eq!(vec3(1f64, 2f64, 3f64), Vector3::new(1f64, 2f64, 3f64)); let s = vec3(5f64, 2f64, 3f64).rem_element_wise(vec3(1f64, 2f64, 3f64)); let s2 = Vec3::new(5f3...
code_fim
easy
{ "lang": "rust", "repo": "laopo001/raytrace-parallel", "path": "/examples/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(vec3(1f64, 2f64, 3f64), Vector3::new(1f64, 2f64, 3f64)); let s = vec3(5f64, 2f64, 3f64).rem_element_wise(vec3(1f64, 2f64, 3f64)); let s2 = Vec3::new(5f32, 2f32, 3f32) % Vec3::new(1f32, 2f32, 3f32); println!("{:?},{:?}", s, s2); }<|fim_prefix|>// repo: laopo001/raytrace-parallel path: /exam...
code_fim
easy
{ "lang": "rust", "repo": "laopo001/raytrace-parallel", "path": "/examples/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gmadrid/fdown path: /src/serde_types.in.rs #[derive(Debug,Deserialize)] pub struct StreamsIdsResponse { continuation: Option<String>, pub ids: Vec<String>, } #[derive(Debug,Deserialize,PartialEq)] pub struct EntryDetailVisual { pub url: Option<String>, #[serde(rename="contentType")] p...
code_fim
hard
{ "lang": "rust", "repo": "gmadrid/fdown", "path": "/src/serde_types.in.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug,Serialize)] pub struct MarkerRequestBody { pub action: String, #[serde(rename="type")] pub type_field: String, #[serde(rename="entryIds")] pub entry_ids: Vec<String>, } #[derive(Debug,Serialize)] pub struct DropboxUploadAPI<'a> { pub path: &'a str, pub mode: &'a str, pub au...
code_fim
hard
{ "lang": "rust", "repo": "gmadrid/fdown", "path": "/src/serde_types.in.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimiq/albatross-simulator path: /simulator/src/node.rs use crate::environment::Environment; use crate::event::Event; <|fim_suffix|> /// Processes an input event and allows to output events to other channels. /// The return value determines whether the simulation should continue to run (`...
code_fim
medium
{ "lang": "rust", "repo": "nimiq/albatross-simulator", "path": "/simulator/src/node.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> env: Environment<Self::EventType, Self::MetricsEventType>) -> bool; }<|fim_prefix|>// repo: nimiq/albatross-simulator path: /simulator/src/node.rs use crate::environment::Environment; use crate::event::Event; pub trait Node: Send { type EventType; type MetricsEventType; <|fim_middle|...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/albatross-simulator", "path": "/simulator/src/node.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slowmistio/MaskWalletCore path: /interface/src/handler/validate.rs use crate::coins::get_coin_info; use crate::response_util::*; use chain_common::api::mw_response::Response; use chain_common::api::*; use chain_common::private_key::PrivateKey; use crypto::bip39::Mnemonic; use crypto::key_store_j...
code_fim
hard
{ "lang": "rust", "repo": "slowmistio/MaskWalletCore", "path": "/interface/src/handler/validate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>1".to_owned(), error_msg: "Invalid Coin Type".to_owned(), })), }; } }; let entry = match CoinDispatcher::get_entry(&coin) { Ok(entry) => entry, Err(error) => { ...
code_fim
hard
{ "lang": "rust", "repo": "slowmistio/MaskWalletCore", "path": "/interface/src/handler/validate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EzgiS/rust-ncc path: /src/cell/mod.rs // Copyright © 2020 Brian Merchant. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file...
code_fim
hard
{ "lang": "rust", "repo": "EzgiS/rust-ncc", "path": "/src/cell/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn simulate_rkdp5( &self, tstep: usize, interactions: &CellInteractions, contact_data: Vec<ContactData>, world_parameters: &WorldParameters, parameters: &Parameters, rng: &mut Pcg32, ) -> Result<CellState, String> { let aux_args =...
code_fim
hard
{ "lang": "rust", "repo": "EzgiS/rust-ncc", "path": "/src/cell/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn move_point_out( new_u: &V2D, mut new_v: V2D, new_w: &V2D, mut good_v: V2D, contacts: &[ContactData], num_iters: usize, ) -> V2D { let mut n = 0; while n < num_iters { let test_v = 0.5 * (good_v + new_v); if violates_volume_exclusion(&test_v, new_u, new_w,...
code_fim
hard
{ "lang": "rust", "repo": "EzgiS/rust-ncc", "path": "/src/cell/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lambdaxymox/fuchsia path: /src/recovery/lib/recovery-util/src/block.rs // Copyright 2022 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 { anyhow::{anyhow, Context, Error}, fdio, fi...
code_fim
hard
{ "lang": "rust", "repo": "lambdaxymox/fuchsia", "path": "/src/recovery/lib/recovery-util/src/block.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_block_devices() -> Result<Vec<BlockDevice>, Error> { let block_dir = Path::new("/dev/class/block"); let mut devices = Vec::new(); for entry in fs::read_dir(block_dir)? { let name = entry?.path().to_str().unwrap().to_owned(); if let Some(bd) = get_block_device(n...
code_fim
hard
{ "lang": "rust", "repo": "lambdaxymox/fuchsia", "path": "/src/recovery/lib/recovery-util/src/block.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lotabout/tuikit path: /src/attr.rs //! attr modules defines the attributes(colors, effects) of a terminal cell use bitflags::bitflags; pub use crate::color::Color; /// `Attr` is a rendering attribute that contains fg color, bg color and text effect. /// /// ``` /// use tuikit::attr::{Attr, Ef...
code_fim
hard
{ "lang": "rust", "repo": "lotabout/tuikit", "path": "/src/attr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Attr { fg: Color::default(), bg: Color::default(), effect: Effect::empty(), } } } impl Attr { /// extend the properties with the new attr's if the properties in new attr is not default. /// ``` /// use tuikit::attr::{Attr, Color, Effect}...
code_fim
hard
{ "lang": "rust", "repo": "lotabout/tuikit", "path": "/src/attr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait SerializeBinary: Sized { /// Parse a struct of type Self from a binary buffer. fn parse_binary(i: &[u8]) -> IResult<&[u8], Self, NomCustomError<&[u8]>>; /// Writes a struct to a writable buffer. fn write_binary<WB: Write>(&self, writer: &mut WB) -> Result<()>; }<|fim_prefix|>// r...
code_fim
medium
{ "lang": "rust", "repo": "Garvys/rustfst", "path": "/rustfst/src/parsers/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Writes a struct to a writable buffer. fn write_binary<WB: Write>(&self, writer: &mut WB) -> Result<()>; }<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst/src/parsers/mod.rs pub(crate) mod bin_fst; pub(crate) mod bin_symt; pub mod nom_utils; pub mod text_fst; pub(crate) mod text_symt; pub ...
code_fim
hard
{ "lang": "rust", "repo": "Garvys/rustfst", "path": "/rustfst/src/parsers/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Garvys/rustfst path: /rustfst/src/parsers/mod.rs pub(crate) mod bin_fst; pub(crate) mod bin_symt; pub mod nom_utils; pub mod text_fst; pub(crate) mod text_symt; pub mod utils_parsing; pub mod utils_serialization; <|fim_suffix|> /// Writes a struct to a writable buffer. fn write_binary<WB...
code_fim
hard
{ "lang": "rust", "repo": "Garvys/rustfst", "path": "/rustfst/src/parsers/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> BigUint { data: digits } } } impl<'a, 'b> Add<&'b BigUint> for &'a BigUint { type Output = BigUint; fn add(self, rhs: &'b BigUint) -> BigUint { self.clone() + rhs } } impl PartialEq for BigUint { fn eq(&self, other: &BigUint) -> bool { itertools::equal(self.d...
code_fim
hard
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/bigint.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harababurel/homework path: /sem5/pdp/bigsum/src/bigint.rs use num::FromPrimitive; use std::cmp::PartialEq; use std::ops::Add; use std::cmp; use std::convert::From; use itertools; #[derive(Clone, Debug)] pub struct BigUint { data: Vec<u32>, } impl BigUint { pub fn new(digits: Vec<u32>) ...
code_fim
hard
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/bigint.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, 'b> Add<&'b BigUint> for BigUint { type Output = BigUint; fn add(self, rhs: &'b BigUint) -> BigUint { let mut digits: Vec<u32> = Vec::new(); let mut carry = 0 as u32; for i in 0..cmp::max(self.digits().len(), rhs.digits().len()) { let a: u32 = match s...
code_fim
hard
{ "lang": "rust", "repo": "harababurel/homework", "path": "/sem5/pdp/bigsum/src/bigint.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ment_for_command_c!(globals, c, save_scanner_status); // old_setting:=selector; selector:=new_string; b:=pool_ptr; old_setting = globals.selector; globals.selector = new_string.into(); b = globals.pool_ptr; // @<Print the result of command |c|@>; crate::section_0472::Print_the_resu...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0470.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0470.rs //! @ The procedure |conv_toks| uses |str_toks| to insert the token list //! for |convert| functions into the scanner; `\.{\\outer}' control sequences //! are allowed to follow `\.{\\string}' and `\.{\\meaning}'. // // @p procedure conv...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0470.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ge) = str_toks(globals, b); ins_list!(globals, link!(globals, temp_head)); // end; crate::ok_nojump!() } use crate::section_0004::TeXGlobals; use crate::section_0038::pool_pointer; use crate::section_0054::new_string; use crate::section_0081::TeXResult; use crate::section_0118::link; use crat...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0470.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: natane07/esgi_2021_4a_IABD_drl_sample_project path: /drl_sample_project/src/to_do/deep_reinforcement_learning.rs use crate::do_not_touch::secret_deep_single_agent_env_with_discrete_actions_wrapper::Env5; /// Contains the weights, structure of the q_network /// todo /// #[derive(Debug)] struct D...
code_fim
hard
{ "lang": "rust", "repo": "natane07/esgi_2021_4a_IABD_drl_sample_project", "path": "/drl_sample_project/src/to_do/deep_reinforcement_learning.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn demo() { dbg!(episodic_semi_gradient_sarsa_on_tic_tac_toe_solo()); dbg!(deep_q_learning_on_tic_tac_toe_solo()); dbg!(episodic_semi_gradient_sarsa_on_pac_man()); dbg!(deep_q_learning_on_pac_man()); dbg!(episodic_semi_gradient_sarsa_on_secret_env5()); dbg!(deep_q_learning_o...
code_fim
hard
{ "lang": "rust", "repo": "natane07/esgi_2021_4a_IABD_drl_sample_project", "path": "/drl_sample_project/src/to_do/deep_reinforcement_learning.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> todo!() } /// Creates a PacMan environment /// Launches a deep q Learning (DQN) algorithm in order to find the optimal action_value function /// Returns the optimal action_value function (Q(w)(s,a)) /// Experiment with different values of hyper parameters and choose the most appropriate combination f...
code_fim
hard
{ "lang": "rust", "repo": "natane07/esgi_2021_4a_IABD_drl_sample_project", "path": "/drl_sample_project/src/to_do/deep_reinforcement_learning.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pythonspeed/filprofiler path: /memapi/src/flamegraph.rs use std::{borrow::Cow, fs, io::Write, path::Path}; use inferno::flamegraph; use itertools::Itertools; use crate::{ linecache::LineCacher, memorytracking::{Callstack, ReadFunctionLocations}, }; /// Filter down to top 99% of sample...
code_fim
hard
{ "lang": "rust", "repo": "pythonspeed/filprofiler", "path": "/memapi/src/flamegraph.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> proptest! { #[test] fn filtering_of_callstacks( // Allocated bytes. Will use index as the memory address. allocated_sizes in prop::collection::vec(0..1000usize, 5..15000), ) { let total_size : usize = allocated_sizes.iter().sum(); ...
code_fim
hard
{ "lang": "rust", "repo": "pythonspeed/filprofiler", "path": "/memapi/src/flamegraph.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[test] fn displays_sector_size_in_prompt() -> Result<(), FailureError> { let to_create = vec!["v1-aaa.vk", "v1-aaa.params", "v1-xxx.vk", "v1-xxx.params"]; let (mut session, _) = ParamPublishSessionBuilder::new() .with_session_timeout_ms(1000) .with_files(&to_create)...
code_fim
hard
{ "lang": "rust", "repo": "filecoin-project/rust-fil-proofs", "path": "/fil-proofs-param/tests/parampublish/prompts_to_publish.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: filecoin-project/rust-fil-proofs path: /fil-proofs-param/tests/parampublish/prompts_to_publish.rs use failure::Error as FailureError; use storage_proofs_core::parameter_cache::CacheEntryMetadata; use crate::parampublish::support::session::ParamPublishSessionBuilder; #[test] fn ignores_files_un...
code_fim
hard
{ "lang": "rust", "repo": "filecoin-project/rust-fil-proofs", "path": "/fil-proofs-param/tests/parampublish/prompts_to_publish.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avidal/fastlike path: /specs/testdata/rust/src/main.rs use fastly::{Request, Response, Body, Error}; use fastly::http::{Method, StatusCode}; use fastly::experimental::uap_parse; use fastly::geo::geo_lookup; use serde_json; const BACKEND: &str = "backend"; #[fastly::main] fn main(mut req: Reque...
code_fim
hard
{ "lang": "rust", "repo": "avidal/fastlike", "path": "/specs/testdata/rust/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (&Method::GET, path) if path.starts_with("/dictionary") => { // open the dictionary and get the key specified in the path let parts: Vec<&str> = path[1..].split("/").collect(); let (name, key) = (parts[1], parts[2]); use fastly::Dictionary; ...
code_fim
hard
{ "lang": "rust", "repo": "avidal/fastlike", "path": "/specs/testdata/rust/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mxryan/minefinder2 path: /src/board.rs use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use super::cell::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(s: &str); } #[derive(Debug)] pub struct Board { pub mines: i32, pub rows: usize, pu...
code_fim
hard
{ "lang": "rust", "repo": "mxryan/minefinder2", "path": "/src/board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> s } } fn get_random_buf() -> Result<[u8; 4], getrandom::Error> { let mut buf = [0u8; 4]; getrandom::getrandom(&mut buf)?; Ok(buf) } fn get_random_f64() -> f64 { let four_random_bytes = get_random_buf().unwrap(); let mut bytes_as_u32 = four_random_bytes[0] as u32; by...
code_fim
hard
{ "lang": "rust", "repo": "mxryan/minefinder2", "path": "/src/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a function to serve `drone gdb` command. pub fn gdb(probe: Probe) -> GdbFn { match probe { Probe::Bmp => bmp::gdb, Probe::Jlink => jlink::gdb, Probe::Openocd => openocd::gdb, } } /// Returns a function to serve `drone log` command. pub fn log(probe: Probe, log:...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/drone-cli", "path": "/src/probe/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/drone-cli path: /src/probe/mod.rs //! Debug probe interface. pub mod bmp; pub mod jlink; pub mod openocd; use crate::{ cli::{FlashCmd, GdbCmd, LogCmd, ResetCmd}, color::Color, templates::Registry, utils::{block_with_signals, detach_pgid, finally, run_command, spawn_c...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/drone-cli", "path": "/src/probe/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a function to serve `drone reset` command. pub fn reset(probe: Probe) -> ResetFn { match probe { Probe::Bmp => bmp::reset, Probe::Jlink => jlink::reset, Probe::Openocd => openocd::reset, } } /// Returns a function to serve `drone flash` command. pub fn flash(pr...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/drone-cli", "path": "/src/probe/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonathanmorley/nexus-rs path: /src/models/content.rs use error; use client::{Client, parse_response}; use models::repository::Repository; use std::iter; use std::path::PathBuf; use time::{self, Tm, Timespec}; #[derive(Debug, Deserialize, Clone, PartialEq)] #[serde(deny_unknown_fields)] pub str...
code_fim
hard
{ "lang": "rust", "repo": "jonathanmorley/nexus-rs", "path": "/src/models/content.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(iter::once(content_metadata) .chain(children? .into_iter() .flat_map(|child| self.with_descendants(child).unwrap())) .collect::<Vec<ContentMetadata>>()) } }<|fim_prefix|>// repo: jonathanmorley/nexus-rs path: /src/models/conte...
code_fim
hard
{ "lang": "rust", "repo": "jonathanmorley/nexus-rs", "path": "/src/models/content.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let test_tuples = vec![ (vec![3, 5, 2, 6], 2, vec![2, 6]), (vec![2, 4, 3, 3, 5, 4, 9, 6], 4, vec![2, 3, 3, 4]), (vec![2, 4, 3, 3, 5, 4, 1, 9], 4, vec![2, 3, 1, 9]), ]; for (nums, k, expected) in test_tuples { assert_eq!(most_competiti...
code_fim
hard
{ "lang": "rust", "repo": "JamesShoaf/AlgorithmPractice", "path": "/contests/LeetCode/2020/2020-11-28LeetCode/most_competitive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JamesShoaf/AlgorithmPractice path: /contests/LeetCode/2020/2020-11-28LeetCode/most_competitive/src/lib.rs /* Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k. An array's subsequence is a resulting sequence obtained by erasing some (...
code_fim
medium
{ "lang": "rust", "repo": "JamesShoaf/AlgorithmPractice", "path": "/contests/LeetCode/2020/2020-11-28LeetCode/most_competitive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>32, ) -> crate::ctypes::c_int; } extern "C" { pub fn ksceGpuMmuUnmapMemory( mmuContext: *mut crate::ctypes::c_void, vaddr: u32, size: u32, ) -> crate::ctypes::c_int; }<|fim_prefix|>// repo: pheki/vitasdk-sys path: /src/psp2kern/gpu_es4.rs /* automatically generated by ...
code_fim
hard
{ "lang": "rust", "repo": "pheki/vitasdk-sys", "path": "/src/psp2kern/gpu_es4.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pheki/vitasdk-sys path: /src/psp2kern/gpu_es4.rs /* automatically generated by rust-bindgen 0.65.1 */ #[allow(unused_imports)] use crate::psp2common::types::*; #[allow(unused_imports)] use crate::psp2kern::types::*; extern "C" { pub fn PVRSRVGetM<|fim_suffix|>32, ) -> crate::ctypes::c_...
code_fim
hard
{ "lang": "rust", "repo": "pheki/vitasdk-sys", "path": "/src/psp2kern/gpu_es4.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>es::c_int; } extern "C" { pub fn ksceGpuMmuMapMemory( mmuContext: *mut crate::ctypes::c_void, vaddr: u32, base: *mut crate::ctypes::c_void, size: u32, flags: u32, ) -> crate::ctypes::c_int; } extern "C" { pub fn ksceGpuMmuUnmapMemory( mmuContext:...
code_fim
hard
{ "lang": "rust", "repo": "pheki/vitasdk-sys", "path": "/src/psp2kern/gpu_es4.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let row1 = m1.len(); //let row2 = m2.len(); let col1 = m1[0].len(); let col2 = m2[0].len(); let mut res:Vec<Vec<i32>> = Vec::with_capacity(row1); for i in 0..row1 { let mut tmp:Vec<i32> = Vec::with_capacity(col2); //初始化,也可以使用...
code_fim
hard
{ "lang": "rust", "repo": "ydsh/BrushNotes", "path": "/leetcode/509.斐波那契数.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ydsh/BrushNotes path: /leetcode/509.斐波那契数.rs /* * @lc app=leetcode.cn id=509 lang=rust * * [509] 斐波那契数 */ // @lc code=start impl Solution { ///``` /// 快速幂矩阵: /// F0 = 0, F1 = 1, /// |1 1||F1| |F1+F0| 即 |F2| /// |1 0||F0| |F1 | |F1| /// /// 所以, ...
code_fim
hard
{ "lang": "rust", "repo": "ydsh/BrushNotes", "path": "/leetcode/509.斐波那契数.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32wb/src/stm32wb55/usb/addr3_rx.rs #[doc = "Register `ADDR3_RX` reader"] pub type R = crate::R<ADDR3_RX_SPEC>; #[doc = "Register `ADDR3_RX` writer"] pub type W = crate::W<ADDR3_RX_SPEC>; #[doc = "Field `ADDR3_RX` reader - Reception buffer address"] pub type ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wb/src/stm32wb55/usb/addr3_rx.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> type Ux = u16; } #[doc = "`read()` method returns [`addr3_rx::R`](R) reader structure"] impl crate::Readable for ADDR3_RX_SPEC {} #[doc = "`write(|w| ..)` method takes [`addr3_rx::W`](W) writer structure"] impl crate::Writable for ADDR3_RX_SPEC { const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wb/src/stm32wb55/usb/addr3_rx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pyjcode/Peace path: /src/objects/players/status.rs use chrono::{DateTime, Utc}; use peace_database::{set_with_db, Database}; use tokio_pg_mapper_derive::PostgresMapper; set_with_db! { table="user"; schema="status"; #[derive(Clone, Debug, PostgresMapper)] #[pg_mapper(table = "use...
code_fim
hard
{ "lang": "rust", "repo": "pyjcode/Peace", "path": "/src/objects/players/status.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline(always)] /// Update player info from database pub async fn update(&mut self, database: &Database) -> bool { let start = std::time::Instant::now(); let new = PlayerStatus::from_database(self.id, database).await; if new.is_none() { error!("PlayerStatu...
code_fim
hard
{ "lang": "rust", "repo": "pyjcode/Peace", "path": "/src/objects/players/status.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smartdev0218/atomicDEX-API path: /mm2src/mm2_bitcoin/chain/src/lib.rs extern crate bitcrypto as crypto; extern crate primitives; extern crate rustc_hex as hex; extern crate serialization as ser; #[macro_use] extern crate serialization_derive; pub mod constants; mod block; mod block_header; mod...
code_fim
hard
{ "lang": "rust", "repo": "smartdev0218/atomicDEX-API", "path": "/mm2src/mm2_bitcoin/chain/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use read_and_hash::{HashedData, ReadAndHash}; pub type ShortTransactionId = hash::H48;<|fim_prefix|>// repo: smartdev0218/atomicDEX-API path: /mm2src/mm2_bitcoin/chain/src/lib.rs extern crate bitcrypto as crypto; extern crate primitives; extern crate rustc_hex as hex; extern crate serialization as s...
code_fim
hard
{ "lang": "rust", "repo": "smartdev0218/atomicDEX-API", "path": "/mm2src/mm2_bitcoin/chain/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use block::Block; pub use block_header::BlockHeader; pub use merkle_root::{merkle_node_hash, merkle_root}; pub use transaction::{JoinSplit, OutPoint, ShieldedOutput, ShieldedSpend, Transaction, TransactionInput, TransactionOutput, TxHashAlgo}; pub use read_and_hash::{HashedData,...
code_fim
hard
{ "lang": "rust", "repo": "smartdev0218/atomicDEX-API", "path": "/mm2src/mm2_bitcoin/chain/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Apanatshka/dnfa path: /examples/dot.rs use std::env; use dnfa::nfa::*; //use dnfa::dfa::*; <|fim_suffix|> let dict: Vec<String> = env::args().skip(1).collect(); let mut nfa = NFA::from_dictionary(dict); nfa.ignore_prefixes(); let nfa = nfa.powerset_construction(); let option...
code_fim
easy
{ "lang": "rust", "repo": "Apanatshka/dnfa", "path": "/examples/dot.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let dict: Vec<String> = env::args().skip(1).collect(); let mut nfa = NFA::from_dictionary(dict); nfa.ignore_prefixes(); let nfa = nfa.powerset_construction(); let options = DotOptions { bold_dict_edges: true, suppress_stuck_state: true, }; println!("{}", nfa.dot...
code_fim
easy
{ "lang": "rust", "repo": "Apanatshka/dnfa", "path": "/examples/dot.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/dns/name/src/lib.rs #![deny(rust_2018_idioms, clippy::disallowed_methods, clippy::disallowed_types)] #![forbid(unsafe_code)] <|fim_suffix|>pub use self::name::{InvalidName, Name, NameRef}; pub use self::suffix::Suffix;<|fim_middle|>mod name; mod suffix;
code_fim
easy
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/dns/name/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::name::{InvalidName, Name, NameRef}; pub use self::suffix::Suffix;<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/dns/name/src/lib.rs #![deny(rust_2018_idioms, clippy::disallowed_methods, clippy::disallowed_types)] #![forbid(unsafe_code)] <|fim_middle|>mod name; mod suffix;
code_fim
easy
{ "lang": "rust", "repo": "linkerd/linkerd2-proxy", "path": "/linkerd/dns/name/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Read to graph let mut bag_graph = FxHashMap::<u32, Node>::with_capacity_and_hasher(CAPACITY, Default::default()); buffer .lines() .for_each(|line| add_to_graph(line, &mut bag_graph)); let time_setup = start_setup.elapsed(); // -------------------------------...
code_fim
hard
{ "lang": "rust", "repo": "jeremylt/advent2020", "path": "/src/day07.rs", "mode": "spm", "license": "BSD-2-Clause-Views", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeremylt/advent2020 path: /src/day07.rs //! Day 7: //! A particularly slow day, the performance is dominated by adding each bag to a graph. //! Once the input has been parsed, traversing the graph to find the contained/containing //! bags is straightforward and fast. Switching to the rustc hashe...
code_fim
hard
{ "lang": "rust", "repo": "jeremylt/advent2020", "path": "/src/day07.rs", "mode": "psm", "license": "BSD-2-Clause-Views", "source": "the-stack-v2" }
<|fim_suffix|> // ------------------------------------------------------------------------- // Part 2 // ------------------------------------------------------------------------- // Find number of contained bags let start_part_2 = Instant::now(); let count_2 = part_2(str_to_key("shiny gold").unwr...
code_fim
hard
{ "lang": "rust", "repo": "jeremylt/advent2020", "path": "/src/day07.rs", "mode": "spm", "license": "BSD-2-Clause-Views", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/compiler-builtins path: /src/float/pow.rs use crate::float::Float; use crate::int::Int; /// Returns `a` raised to the power `b` fn pow<F: Float>(a: F, b: i32) -> F { let mut a = a; let recip = b < 0; let mut pow = Int::abs_diff(b, 0); let mut mul = F::ONE; loop { ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/compiler-builtins", "path": "/src/float/pow.rs", "mode": "psm", "license": "NCSA", "source": "the-stack-v2" }
<|fim_suffix|> pub extern "C" fn __powidf2(a: f64, b: i32) -> f64 { pow(a, b) } }<|fim_prefix|>// repo: rust-lang/compiler-builtins path: /src/float/pow.rs use crate::float::Float; use crate::int::Int; /// Returns `a` raised to the power `b` fn pow<F: Float>(a: F, b: i32) -> F { let mut a = a; ...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/compiler-builtins", "path": "/src/float/pow.rs", "mode": "spm", "license": "NCSA", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timmyjose-study/programming-rust-2nd-edition path: /Chapter15/chapter/src/bin/basic.rs use rand::random; use std::fmt::Debug; use std::iter::{from_fn, successors, IntoIterator}; fn dump<T, U>(t: T) where T: IntoIterator<Item = U>, U: Debug, { for u in t { println!("{:?}", u)...
code_fim
hard
{ "lang": "rust", "repo": "timmyjose-study/programming-rust-2nd-edition", "path": "/Chapter15/chapter/src/bin/basic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { assert_eq!(triangle(10), 55); assert_eq!(triangle_again(10), 55); assert_eq!(triangle_yet_again(10), 55); dump(vec![1, 2, 3, 4, 5]); let lengths = from_fn(|| Some((random::<f64>() - random::<f64>()).abs())) .take(10) .collect::<Vec<_>>(); println!("{:#...
code_fim
hard
{ "lang": "rust", "repo": "timmyjose-study/programming-rust-2nd-edition", "path": "/Chapter15/chapter/src/bin/basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> from_fn_demo(); assert_eq!( fibonacci().take(8).collect::<Vec<_>>(), vec![1, 1, 2, 3, 5, 8, 13, 21] ); let mut randomizer = random_number_generator(); for _ in 0..10 { println!("{:.5}", randomizer.next().unwrap()); } let mut pow_iter = powers_of_10(); ...
code_fim
hard
{ "lang": "rust", "repo": "timmyjose-study/programming-rust-2nd-edition", "path": "/Chapter15/chapter/src/bin/basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CGMossa/learn-rust path: /src/full_qualifier.rs // This file is part of https://github.com/alexsednz/learn-rust. // // learn-rust is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, eithe...
code_fim
hard
{ "lang": "rust", "repo": "CGMossa/learn-rust", "path": "/src/full_qualifier.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> t.tik_tok(); assert_eq!(t.b, true); t.tik_tok(); assert_eq!(t.b, false); <FlipFlop as TikTok>::tik_tok(&mut t); // default trait impl does nothing assert_eq!(t.b, false); } #[test] fn up_counter_method() { let mut s = UpCounter { c: 0 ...
code_fim
hard
{ "lang": "rust", "repo": "CGMossa/learn-rust", "path": "/src/full_qualifier.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> t } Bool::Equal(a, b) => { let mut t = a.get_variables(); t.extend(b.get_variables()); t } Bool::GreaterEqual(a, b) => { let mut t = a.get_variables(); t.extend(...
code_fim
hard
{ "lang": "rust", "repo": "dezeroku/rustp", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dezeroku/rustp path: /src/ast.rs a.extend(t); } } for i in el { let t = i.get_variables(); a.extend(t); } a } Block::ForRange(var, first, las...
code_fim
hard
{ "lang": "rust", "repo": "dezeroku/rustp", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> a } Value::FunctionCall(_, vals) => { let mut a = HashSet::new(); for i in vals { let t = i.get_variables(); a.extend(t); } a } Value::De...
code_fim
hard
{ "lang": "rust", "repo": "dezeroku/rustp", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ishanjain28/raytracing-in-a-weekend path: /src/demos/linear_gradient_rectangle.rs pub struct LinearGradientRectangle; use crate::{ types::{HitableList, Ray, Vec3}, Camera, {demos::Chunk, Demo}, }; impl Demo for LinearGradientRectangle { fn name(&self) -> &'static str { ...
code_fim
hard
{ "lang": "rust", "repo": "ishanjain28/raytracing-in-a-weekend", "path": "/src/demos/linear_gradient_rectangle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let unit_direction = ray.direction().unit_vector(); let t = 0.5 * unit_direction.y() + 1.0; Vec3::new(1.0, 1.0, 1.0) * (1.0 - t) + Vec3::new(0.5, 0.7, 1.0) * t }<|fim_prefix|>// repo: ishanjain28/raytracing-in-a-weekend path: /src/demos/linear_gradient_rectangle.rs pub struct LinearGradientRe...
code_fim
hard
{ "lang": "rust", "repo": "ishanjain28/raytracing-in-a-weekend", "path": "/src/demos/linear_gradient_rectangle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kohbis/leetcode path: /algorithms/1941.check-if-all-characters-have-equal-number-of-occurrences/soluiton.rs use std::collections::{HashMap, HashSet}; <|fim_suffix|> count .into_iter() .map(|(_, n)| n) .collect::<HashSet<i32>>() .len() ...
code_fim
hard
{ "lang": "rust", "repo": "kohbis/leetcode", "path": "/algorithms/1941.check-if-all-characters-have-equal-number-of-occurrences/soluiton.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> count .into_iter() .map(|(_, n)| n) .collect::<HashSet<i32>>() .len() == 1 } }<|fim_prefix|>// repo: kohbis/leetcode path: /algorithms/1941.check-if-all-characters-have-equal-number-of-occurrences/soluiton.rs use std::collections::{H...
code_fim
hard
{ "lang": "rust", "repo": "kohbis/leetcode", "path": "/algorithms/1941.check-if-all-characters-have-equal-number-of-occurrences/soluiton.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }