text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[wasm_bindgen] pub fn sierpinski() -> Result<(), JsValue> { programs::sierpinski::run(get_context()?) } #[wasm_bindgen] pub fn sierpinski_3d_points() -> Result<(), JsValue> { programs::sierpinski_3d_points::run(get_context()?) } #[wasm_bindgen] pub fn sierpinski_3d() -> Result<(), JsValue> { ...
code_fim
hard
{ "lang": "rust", "repo": "shritesh/webgl.rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let iterations = matches.value_of("ITERATIONS").unwrap(); // `iterations` has already been validated by clap let iterations = usize::from_str(iterations).unwrap(); let options = if matches.is_present("smoke_test") { TesterOptions::SMOKE_TEST } else if matches.is_present("quiet"...
code_fim
hard
{ "lang": "rust", "repo": "ajungren/rdrand-test", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajungren/rdrand-test path: /src/main.rs extern crate rdrand_test; use std::process::exit; use std::str::FromStr; use std::string::ToString; use clap::{App, Arg}; use rdrand_test::{Error, Tester, TesterOptions}; const DEFAULT_ITERATIONS: &str = "500"; const SMOKE_TEST_ITERATIONS: &str = "4"; ...
code_fim
hard
{ "lang": "rust", "repo": "ajungren/rdrand-test", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ObsidianDestroyer/rwall path: /src/main.rs use std::collections::HashMap; struct Argument { pattern: String, value: String, } impl Argument { fn new(pattern: String, value: String) -> Argument { <|fim_suffix|>fn main() { use std::env; let arguments: Vec<Argument> = env::args...
code_fim
medium
{ "lang": "rust", "repo": "ObsidianDestroyer/rwall", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use std::env; let arguments: Vec<Argument> = env::args().enumerate() .filter(|&(i, _)| i != 0) .map( |(_, args)| args ) .collect::<Vec<String>>() .chunks(2) .map( |args| Argument::new( a...
code_fim
medium
{ "lang": "rust", "repo": "ObsidianDestroyer/rwall", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukesdm/bwb path: /src/render.rs use crate::text::Font; use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use sdl2::render; use std::collections::HashMap; use crate::entity::EntityKind; use crate::geometry::Vertex; use crate::text; use crate::world::{Entities, Geometries, Healths, GRID_H...
code_fim
hard
{ "lang": "rust", "repo": "lukesdm/bwb", "path": "/src/render.rs", "mode": "psm", "license": "FTL", "source": "the-stack-v2" }
<|fim_suffix|>// Calculates the x coordinate of the left edge of the centered rectangle fn h_center(width: u32) -> i32 { // Will be negative if width > screen_width. COULDDO: clamp to 0 and use u32. WIN_WIDTH as i32 / 2 - width as i32 / 2 } // Calculates the y coordinate of the top edge of the centered rectang...
code_fim
hard
{ "lang": "rust", "repo": "lukesdm/bwb", "path": "/src/render.rs", "mode": "spm", "license": "FTL", "source": "the-stack-v2" }
<|fim_suffix|>impl<'ttf_context> Renderer<'ttf_context> { pub fn new(sdl_context: &sdl2::Sdl, font: Font<'ttf_context>) -> Renderer<'ttf_context> { let video_subsystem = sdl_context.video().unwrap(); let window = video_subsystem .window("Baddies, Walls and Bullets", WIN_WIDTH, WIN_HEIGHT...
code_fim
hard
{ "lang": "rust", "repo": "lukesdm/bwb", "path": "/src/render.rs", "mode": "spm", "license": "FTL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yatekii/copper path: /src/lib/drawing/drawables/schema/mod.rs mod wire_drawable; mod component_instance_drawable; pub use self::wire_drawable::<|fim_suffix|>tance_drawable::ComponentInstanceDrawable;<|fim_middle|>WireDrawable; pub use self::component_ins
code_fim
easy
{ "lang": "rust", "repo": "Yatekii/copper", "path": "/src/lib/drawing/drawables/schema/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>WireDrawable; pub use self::component_instance_drawable::ComponentInstanceDrawable;<|fim_prefix|>// repo: Yatekii/copper path: /src/lib/drawing/drawables/schema/mod.rs mod wire_drawable; mod component_instance<|fim_middle|>_drawable; pub use self::wire_drawable::
code_fim
easy
{ "lang": "rust", "repo": "Yatekii/copper", "path": "/src/lib/drawing/drawables/schema/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/wifi-captive-rs path: /src/state_machine.rs use super::{ config::Config, http_server::WifiConnectionRequest, nm::{ credentials_from_data, ConnectionState, Connectivity, NetworkManager, NetworkManagerState, NETWORK_MANAGER_STATE_CONNECTED, wait_for_connectiv...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/wifi-captive-rs", "path": "/src/state_machine.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match r { // Ctrl+C None => Ok(Some(StateMachine::Exit(nm))), Some(_) => Ok(Some(StateMachine::TryReconnect(config, nm))), } } StateMachine::ActivatePortal(config, nm) => { n...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/wifi-captive-rs", "path": "/src/state_machine.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brmmm3/fltk-rs path: /src/table.rs use crate::image::Image; pub use crate::prelude::*; use crate::widget::Widget; use fltk_sys::table::*; use std::{ ffi::{CStr, CString}, mem, os::raw, }; /// Creates a table #[derive(WidgetExt, GroupExt, TableExt, Debug)] pub struct Table { _inn...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/fltk-rs", "path": "/src/table.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn select_row(&mut self, row: i32) -> Result<(), FltkError> { unsafe { assert!(!self.was_deleted()); match Fl_Table_Row_select_row(self._inner, row) { 1 => Ok(()), 0 => Err(FltkError::Internal(FltkErrorKind::TableError)), ...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/fltk-rs", "path": "/src/table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: memoryruins/bevy_input_map path: /example/example_action_events.rs use std::fs; use bevy::prelude::*; use bevy_app::AppExit; use bevy_app::Events; use bevy_ecs::ResMut; use bevy_prototype_input_map::{ actionevent::OnActionActive, actionevent::OnActionEnd, inputmap::InputMap, InputMapPlugin,...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/bevy_input_map", "path": "/example/example_action_events.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> mut state: Local<ActionState>, action_active_event: Res<Events<OnActionActive>>, ) { if let Some(value) = state.active_reader.latest(&action_active_event) { if value.action == "JUMP" { println!("Jumping..."); } if value.action == "SHOOT" { print...
code_fim
hard
{ "lang": "rust", "repo": "memoryruins/bevy_input_map", "path": "/example/example_action_events.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windelbouwman/letsgui path: /src/backends/gtk/controls/entry.rs use super::GtkControl; use super::MyError; use gtk::prelude::*; <|fim_suffix|> self.inner.clone().upcast::<gtk::Widget>() } }<|fim_middle|>pub struct Entry { inner: gtk::Entry, } impl Entry { pub fn n...
code_fim
hard
{ "lang": "rust", "repo": "windelbouwman/letsgui", "path": "/src/backends/gtk/controls/entry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.inner.clone().upcast::<gtk::Widget>() } }<|fim_prefix|>// repo: windelbouwman/letsgui path: /src/backends/gtk/controls/entry.rs use super::GtkControl; use super::MyError; use gtk::prelude::*; pub struct Entry { inner: gtk::Entry, } impl Entry { pub fn new() -> Result...
code_fim
medium
{ "lang": "rust", "repo": "windelbouwman/letsgui", "path": "/src/backends/gtk/controls/entry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 来源:力扣(LeetCode) 链接:https://leetcode.cn/problems/happy-number 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。" )] pub fn is_happy(n: i32) -> bool { let (mut buf, mut history) = (vec![], HashSet::new()); let mut n = n as u64; while n != 0 && !history.contains(&n) { if n == 1 { return tr...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/leetcode", "path": "/leetcode-rs/src/easy/p3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>来源:力扣(LeetCode) 链接:https://leetcode.cn/problems/contains-duplicate-ii 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。" )] pub fn contains_nearby_duplicate(nums: Vec<i32>, k: i32) -> bool { let mut x = nums .into_iter() .enumerate() .map(|(i, x)| (i, x)) .collect::<Vec<_>>(); x.s...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/leetcode", "path": "/leetcode-rs/src/easy/p3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mengsuenyan/leetcode path: /leetcode-rs/src/easy/p3.rs use crate::easy::p1::{ListNode, TreeNode}; use crate::prelude::*; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::rc::Rc; use std::sync::{Arc, RwLock}; lazy_static::lazy_static! { pub static ref PROBLEMS: Arc<...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/leetcode", "path": "/leetcode-rs/src/easy/p3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // creating and querying a ray let ray = Ray::from_tuple((1.0, 2.0, 3.0), (0.0, 1.0, 0.0)); let translation = Matrix4::translation(3.0, 4.0, 5.0); let ray2 = ray.transform(translation); assert_eq!(ray2.origin, Vector4::point(4.0, 6.0, 8.0)); assert_eq!(ray2....
code_fim
hard
{ "lang": "rust", "repo": "SokichiFujita/raytracer", "path": "/src/ray.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // creating and querying a ray let ray = Ray::from_tuple((2.0, 3.0, 4.0), (1.0, 0.0, 0.0)); assert_eq!(ray.position(0.0), Vector4::point(2.0, 3.0, 4.0)); assert_eq!(ray.position(1.0), Vector4::point(3.0, 3.0, 4.0)); assert_eq!(ray.position(-1.0), Vector4::point(1.0,...
code_fim
hard
{ "lang": "rust", "repo": "SokichiFujita/raytracer", "path": "/src/ray.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SokichiFujita/raytracer path: /src/ray.rs use crate::tuple::TupleOperation; use nalgebra::{Matrix4, Vector4}; #[derive(Debug, Clone)] pub struct Ray { pub origin: Vector4<f32>, pub direction: Vector4<f32>, } impl Ray { pub fn new(origin: Vector4<f32>, direction: Vector4<f32>) -> Se...
code_fim
hard
{ "lang": "rust", "repo": "SokichiFujita/raytracer", "path": "/src/ray.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luhuimao/morgan path: /core/tests/tvu.rs #[macro_use] extern crate morgan; use log::*; use morgan::treasuryStage::create_test_recorder; use morgan::blockBufferPool::{create_new_tmp_ledger, Blocktree}; use morgan::clusterMessage::{ClusterInfo, Node}; use morgan::entryInfo::next_entry_mut; use mo...
code_fim
hard
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/core/tests/tvu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let entries = vec![entry0, entry_tick0, entry_tick1, entry1, entry_tick2]; let blobs = entries.to_shared_blobs(); index_blobs(&blobs, &leader.info.id, blob_idx, 1, 0); blob_idx += blobs.len() as u64; blobs .iter() ...
code_fim
hard
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/core/tests/tvu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let ( bank_forks, _bank_forks_info, blocktree, ledger_signal_receiver, completed_slots_receiver, leader_schedule_cache, _, ) = verifier::new_banks_from_blocktree(&blocktree_path, None); let working_bank = bank_forks.working_bank(); as...
code_fim
hard
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/core/tests/tvu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fetch_u32<T: Read>(reader: &mut T) -> u32 { BigEndian::read_u32(&fetch_bytes(reader, 4)) }<|fim_prefix|>// repo: JohnTortugo/jinterp path: /src/utils.rs use std::io::Read; use byteorder::{ByteOrder, BigEndian, ReadBytesExt}; <|fim_middle|>pub fn fetch_bytes<T: Read>(reader: &mut T, size : usi...
code_fim
hard
{ "lang": "rust", "repo": "JohnTortugo/jinterp", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JohnTortugo/jinterp path: /src/utils.rs use std::io::Read; use byteorder::{ByteOrder, BigEndian, ReadBytesExt}; pub fn fetch_bytes<T: Read>(reader: &mut T, size : usize) -> Vec<u8> { let mut buf = Vec::with_capacity(size); let mut part_reader = reader.take(size as u64); part_reader....
code_fim
medium
{ "lang": "rust", "repo": "JohnTortugo/jinterp", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> buf } pub fn fetch_u16<T: Read>(reader: &mut T) -> u16 { BigEndian::read_u16(&fetch_bytes(reader, 2)) } pub fn fetch_u32<T: Read>(reader: &mut T) -> u32 { BigEndian::read_u32(&fetch_bytes(reader, 4)) }<|fim_prefix|>// repo: JohnTortugo/jinterp path: /src/utils.rs use std::io::Read; use byte...
code_fim
hard
{ "lang": "rust", "repo": "JohnTortugo/jinterp", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let exp = 2.825269; let res = stdev(&data, &mean); assert_approx_eq!(exp, res, 6f64); } #[test] fn csum_test() { let a = vec![1, 2, 3]; let res = vec![1, 3, 6]; assert_eq!(res, cumsum(&a)); } #[test] fn sorted_vec_desc_test() { ...
code_fim
hard
{ "lang": "rust", "repo": "hhandika/simple-qc", "path": "/src/stats.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hhandika/simple-qc path: /src/stats.rs //! Heru Handika //! Module for statistics use std::cmp::Reverse; #[inline] fn sort_vector_asc(vec: &[u32]) -> Vec<u32> { let mut sorted_vec = vec.to_vec(); sorted_vec.sort_unstable(); sorted_vec } pub fn median(vec: &[u32]) -> f64 { let...
code_fim
hard
{ "lang": "rust", "repo": "hhandika/simple-qc", "path": "/src/stats.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulgb/axum path: /src/routing/into_make_service.rs use std::{ convert::Infallible, future::ready, task::{Context, Poll}, }; use tower_service::Service; /// A [`MakeService`] that produces axum router services. /// /// [`MakeService`]: tower::make::MakeService #[derive(Debug, Clone)...
code_fim
medium
{ "lang": "rust", "repo": "paulgb/axum", "path": "/src/routing/into_make_service.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use crate::tests::*; assert_send::<IntoMakeService<()>>(); assert_sync::<IntoMakeService<()>>(); } }<|fim_prefix|>// repo: paulgb/axum path: /src/routing/into_make_service.rs use std::{ convert::Infallible, future::ready, task::{Context, Poll}, }; use tower_servic...
code_fim
hard
{ "lang": "rust", "repo": "paulgb/axum", "path": "/src/routing/into_make_service.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/tcp-stream-ext/src/lib.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::{convert::TryInto as _, os::unix::io::AsRawFd as _}; pub trait ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/tcp-stream-ext/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let socket = Socket::new(Domain::IPV4, Type::STREAM, None)?; Ok(socket.into()) } proptest::proptest! { #[test] fn user_timeout_roundtrip (timeout in 0..=i32::max_value() as u64) { let stream = stream().expect("failed to create stream...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/tcp-stream-ext/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: base0x10/Marzipan path: /src/parser/mod.rs /// Module that exposes nom parsing functions for recoginizing /// and mapping raw redcode lang<|fim_suffix|>ments pub mod atomics; /// parser for loadfiles, a stricter specification of redcode /// that does not require preprocessing, only parsing and ...
code_fim
medium
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/src/parser/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ments pub mod atomics; /// parser for loadfiles, a stricter specification of redcode /// that does not require preprocessing, only parsing and loading /// into the core. pub mod loadfile;<|fim_prefix|>// repo: base0x10/Marzipan path: /src/parser/mod.rs /// Module that exposes nom parsing functions for...
code_fim
medium
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/src/parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>does not require preprocessing, only parsing and loading /// into the core. pub mod loadfile;<|fim_prefix|>// repo: base0x10/Marzipan path: /src/parser/mod.rs /// Module that exposes nom parsing functions for recoginizing /// and mapping raw redcode language elements. /// /// A more or less strict redc...
code_fim
medium
{ "lang": "rust", "repo": "base0x10/Marzipan", "path": "/src/parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn count_trees_in_path(&self, x_vel: usize, y_vel: usize) -> usize { let mut count = 0usize; let mut x = 0usize; let mut y = 0usize; while y < self.height { if self.is_blocked(x, y) { count += 1; } x += x_vel; ...
code_fim
medium
{ "lang": "rust", "repo": "matthewm101/adventofcode2020", "path": "/day3/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let file = fs::read_to_string("input.txt").expect("File does not exist"); let mut forest: Forest = Forest::default(); for line in file.lines() { let mut row: Vec<bool> = vec![]; for b in line.chars().map(|c| c == '#') {row.push(b);} forest.width = row.len();...
code_fim
hard
{ "lang": "rust", "repo": "matthewm101/adventofcode2020", "path": "/day3/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matthewm101/adventofcode2020 path: /day3/src/main.rs use std::fs; #[derive(Default)] struct Forest { width: usize, height: usize, trees: Vec<Vec<bool>> } impl Forest { fn is_blocked(&self, x: usize, y: usize) -> bool { <|fim_suffix|> let file = fs::read_to_string("input.txt"...
code_fim
hard
{ "lang": "rust", "repo": "matthewm101/adventofcode2020", "path": "/day3/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `BPGLCD58`"] pub type BPGLCD58_R = crate::R<bool, BPGLCD58_A>; impl BPGLCD58_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> BPGLCD58_A { match self.bits { false => BPGLCD58...
code_fim
hard
{ "lang": "rust", "repo": "asanza/mkm34z7", "path": "/src/lcd/wf58.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asanza/mkm34z7 path: /src/lcd/wf58.rs value 0"] impl crate::ResetValue for super::WF58 { type Type = u8; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "no description available\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum BP...
code_fim
hard
{ "lang": "rust", "repo": "asanza/mkm34z7", "path": "/src/lcd/wf58.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `BPFLCD58`"] pub type BPFLCD58_R = crate::R<bool, BPFLCD58_A>; impl BPFLCD58_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> BPFLCD58_A { match self.bits { false => BPFLCD58...
code_fim
hard
{ "lang": "rust", "repo": "asanza/mkm34z7", "path": "/src/lcd/wf58.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ddboline/diary_app_rust path: /src/import_gdrive_diary_elog.rs use anyhow::{format_err, Error}; use std::{collections::HashSet, fs::read_to_string, path::Path}; use time::{macros::format_description, Date}; use diary_app_lib::{config::Config, models::DiaryEntries, pgpool::PgPool}; #[tokio::mai...
code_fim
hard
{ "lang": "rust", "repo": "ddboline/diary_app_rust", "path": "/src/import_gdrive_diary_elog.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn extract_dates(path: &Path) -> Result<HashSet<Date>, Error> { path.read_dir()? .map(|entry| { if let Some(filename) = entry?.path().file_name() { let date = Date::parse( &filename.to_string_lossy(), format_desc...
code_fim
hard
{ "lang": "rust", "repo": "ddboline/diary_app_rust", "path": "/src/import_gdrive_diary_elog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !original_text.contains(new_text.trim()) { elog_length.replace(new_text.len()); elog_text = new_text; } } if original_text.is_empty() || diary_length > Some(0) || elog_length > Some(0) { println!( "date...
code_fim
hard
{ "lang": "rust", "repo": "ddboline/diary_app_rust", "path": "/src/import_gdrive_diary_elog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nayuki/Nayuki-web-published-code path: /free-small-fft-in-multiple-languages/fft.rs /* * Free FFT and convolution (Rust) * * Copyright (c) 2020 Project Nayuki. (MIT License) * https://www.nayuki.io/page/free-small-fft-in-multiple-languages * * Permission is hereby granted, free of charg...
code_fim
hard
{ "lang": "rust", "repo": "nayuki/Nayuki-web-published-code", "path": "/free-small-fft-in-multiple-languages/fft.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Bit-reversed addressing permutation let shift: u32 = n.leading_zeros() + 1; for i in 0 .. n { let j: usize = i.reverse_bits() >> shift; if j > i { real.swap(i, j); imag.swap(i, j); } } // Cooley-Tukey decimation-in-time radix-2 FFT let mut size: usize = 2; while size <= n { let h...
code_fim
hard
{ "lang": "rust", "repo": "nayuki/Nayuki-web-published-code", "path": "/free-small-fft-in-multiple-languages/fft.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Postprocessing for i in 0 .. n { real[i] = creal[i] * costable[i] + cimag[i] * sintable[i]; imag[i] = -creal[i] * sintable[i] + cimag[i] * costable[i]; } } /* * Computes the circular convolution of the given real vectors. Each vector's length must be the same. */ pub fn convolve_real(xvec:...
code_fim
hard
{ "lang": "rust", "repo": "nayuki/Nayuki-web-published-code", "path": "/free-small-fft-in-multiple-languages/fft.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub mod tests { pub fn it_works() { println!("hello"); } } pub fn try_me() { most::middle_function(); most::inside::inner_function(); }<|fim_prefix|>// repo: Kangdonghyuk/RustStudy path: /privacyEx/src/lib.rs mod most { pub fn middle_function() { println!("middle"); } fn middle_se...
code_fim
medium
{ "lang": "rust", "repo": "Kangdonghyuk/RustStudy", "path": "/privacyEx/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kangdonghyuk/RustStudy path: /privacyEx/src/lib.rs mod most { pub fn middle_function() { println!("middle"); } fn middle_secret_function() {} <|fim_suffix|> } } pub fn try_me() { most::middle_function(); most::inside::inner_function(); }<|fim_middle|> pub mod inside { pub fn inner_fun...
code_fim
medium
{ "lang": "rust", "repo": "Kangdonghyuk/RustStudy", "path": "/privacyEx/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> std::fs::write("ts_generated.ts", generated.to_string()).unwrap(); }<|fim_prefix|>// repo: sanbox-irl/gm-code-package-generator path: /src/main.rs mod contributes; pub use contributes::*; mod command; pub use command::Command; mod menus; pub use menus::{CommandContext, Context, Menus, SubMenuContex...
code_fim
medium
{ "lang": "rust", "repo": "sanbox-irl/gm-code-package-generator", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> std::fs::write( "contributes.json", serde_json::to_string_pretty(&contributes).unwrap(), ) .unwrap(); std::fs::write("ts_generated.ts", generated.to_string()).unwrap(); }<|fim_prefix|>// repo: sanbox-irl/gm-code-package-generator path: /src/main.rs mod contributes; pub us...
code_fim
hard
{ "lang": "rust", "repo": "sanbox-irl/gm-code-package-generator", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sanbox-irl/gm-code-package-generator path: /src/main.rs mod contributes; pub use contributes::*; mod command; pub use command::Command; mod menus; pub use menus::{CommandContext, Context, Menus, SubMenuContext}; mod ts_generation; pub use ts_generation::TsGenerated; <|fim_suffix|> std::fs...
code_fim
medium
{ "lang": "rust", "repo": "sanbox-irl/gm-code-package-generator", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Main::hello_macro(); println!("Hello, world!"); }<|fim_prefix|>// repo: jasonblog/note path: /Rust/code/learn_rust/learn_macro2/main/src/main.rs use hello_macro::HelloMacro; use hello_macro_derive::HelloMacro; #[derive(HelloMacro)] struct Main; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "jasonblog/note", "path": "/Rust/code/learn_rust/learn_macro2/main/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasonblog/note path: /Rust/code/learn_rust/learn_macro2/main/src/main.rs use hello_macro::HelloMacro; use hello_macro_derive::HelloMacro; <|fim_suffix|> Main::hello_macro(); println!("Hello, world!"); }<|fim_middle|>#[derive(HelloMacro)] struct Main; fn main() {
code_fim
easy
{ "lang": "rust", "repo": "jasonblog/note", "path": "/Rust/code/learn_rust/learn_macro2/main/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use self::ErrorKind::*; match (self, o) { (&Io(_), &Io(_)) => true, (&Unreachable, &Unreachable) => true, (&Decoder(ref a), &Decoder(ref b)) => a == b, (&InvalidResponse(ref a), &InvalidResponse(ref b)) => a == b, (&Transport(ref...
code_fim
hard
{ "lang": "rust", "repo": "witnet/async-jsonrpc-client", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self.kind() { ErrorKind::Io(ref io) => ErrorKind::Io(io.kind().clone().into()), ErrorKind::Unreachable => ErrorKind::Unreachable, ErrorKind::Decoder(ref err) => ErrorKind::Decoder(err.to_owned()), ErrorKind::InvalidResponse(ref t) => ErrorKind...
code_fim
hard
{ "lang": "rust", "repo": "witnet/async-jsonrpc-client", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: witnet/async-jsonrpc-client path: /src/error.rs //! Web3 Error #![allow(unknown_lints)] #![allow(missing_docs)] use crate::rpc; use serde_json; use std::io; error_chain! { foreign_links { Io(io::Error); } errors { Unreachable { description("server is unreachable"), d...
code_fim
hard
{ "lang": "rust", "repo": "witnet/async-jsonrpc-client", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn verbosity(&self) -> i8 { self.default - self.quiet + self.verbose } } fn level_value(level: Option<Level>) -> i8 { match level { None => -1, Some(log::Level::Error) => 0, Some(log::Level::Warn) => 1, Some(log::Level::Info) => 2, Some(log::Lev...
code_fim
hard
{ "lang": "rust", "repo": "liana-p/clap-verbosity-flag", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liana-p/clap-verbosity-flag path: /src/lib.rs //! Easily add a `--verbose` flag to CLIs using Structopt //! //! # Examples //! //! ```rust //! use structopt::StructOpt; //! use clap_verbosity_flag::Verbosity; //! //! /// Le CLI //! #[derive(Debug, StructOpt)] //! struct Cli { //! #[structopt...
code_fim
hard
{ "lang": "rust", "repo": "liana-p/clap-verbosity-flag", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sria91-rlox/worng path: /src/worng/worng_function.rs use std::cell::RefCell; use std::rc::Rc; use std::any::Any; use super::statement::Stmt; use super::callable::Callable; use super::interpreter::Interpreter; use super::environment::Environment; use super::worng_value::WorngValue; use super::wo...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/worng", "path": "/src/worng/worng_function.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let params = match self.declaration { Stmt::Func(_, ref params, _) => params.len(), _ => 0 }; return params; } // TODO: "<fn " + declaration.name.lexeme + ">"; fn func_to_string(&self) -> String{ String::from("<function>") } fn as_any(&self) -> &dyn Any{ ...
code_fim
hard
{ "lang": "rust", "repo": "sria91-rlox/worng", "path": "/src/worng/worng_function.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MR1991/wasp path: /contracts/wasm/donatewithfeedback/src/lib.rs // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 // (Re-)generated by schema tool // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead // @formatter:off #![allow(dead_code)] #![allow(unuse...
code_fim
hard
{ "lang": "rust", "repo": "MR1991/wasp", "path": "/contracts/wasm/donatewithfeedback/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct DonationContext { params: ImmutableDonationParams, results: MutableDonationResults, state: ImmutableDonateWithFeedbackState, } fn view_donation_thunk(ctx: &ScViewContext) { ctx.log("donatewithfeedback.viewDonation"); let f = DonationContext { params: ImmutableDon...
code_fim
hard
{ "lang": "rust", "repo": "MR1991/wasp", "path": "/contracts/wasm/donatewithfeedback/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustWorks/bevy_pen_tool path: /crates/bevy_pen_tool_plugin/src/inputs/actions.rs } } } for bezier_handle in selected.handles.clone() { let bezier = bezier_curves.get_mut(bezier_handle).unwrap(); bezier.grouped = true; } ...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/bevy_pen_tool", "path": "/crates/bevy_pen_tool_plugin/src/inputs/actions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustWorks/bevy_pen_tool path: /crates/bevy_pen_tool_plugin/src/inputs/actions.rs group box quad invisible for mut visible in visible_query.iter_mut() { visible.is_visible = false; } // reset selection selection.selected.group = HashSet::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/bevy_pen_tool", "path": "/crates/bevy_pen_tool_plugin/src/inputs/actions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let group_handle = groups.add(selected); // spawn the middle quads and the bounding box event_writer.send(group_handle.clone()); } } // pub fn ungroup( // mut commands: Commands, // mut groups: ResMut<Assets<Group>>, // globals: ResMut<Globals>, // keyboard_i...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/bevy_pen_tool", "path": "/crates/bevy_pen_tool_plugin/src/inputs/actions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drogue-iot/embassy path: /embassy/src/util/waker.rs use core::ptr::{self, NonNull}; use core::task::Waker; use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering}; use crate::executor::raw::{task_from_waker, wake_task, TaskHeader}; /// Utility struct to register and wake a waker. #[derive(...
code_fim
hard
{ "lang": "rust", "repo": "drogue-iot/embassy", "path": "/embassy/src/util/waker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Wake the registered waker, if any. pub fn wake(&mut self) { if let Some(w) = self.waker.take() { unsafe { wake_task(w) } } } } pub struct AtomicWaker { waker: AtomicPtr<TaskHeader>, } impl AtomicWaker { pub const fn new() -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "drogue-iot/embassy", "path": "/embassy/src/util/waker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct AtomicWaker { waker: AtomicPtr<TaskHeader>, } impl AtomicWaker { pub const fn new() -> Self { Self { waker: AtomicPtr::new(ptr::null_mut()), } } /// Register a waker. Overwrites the previous waker, if any. pub fn register(&self, w: &Waker) { ...
code_fim
medium
{ "lang": "rust", "repo": "drogue-iot/embassy", "path": "/embassy/src/util/waker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PolySync/git-rsl path: /src/bin/git-secure-push.rs #[macro_use] extern crate clap; extern crate git2; extern crate git_rsl; use clap::{App, Arg}; use git_rsl::errors::*; use git_rsl::utils::git; use git_rsl::{secure_push_with_cleanup, BranchName, RemoteName}; use std::process; fn main() { <|f...
code_fim
hard
{ "lang": "rust", "repo": "PolySync/git-rsl", "path": "/src/bin/git-secure-push.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let branch = match matches.value_of("BRANCH") { None => panic!("Must supply a BRANCH argument"), Some(v) => v.to_owned(), }; // TODO - reduce code duplication across the top level of the binaries let mut repo = git::discover_repo() .expect("You don't appear to be in...
code_fim
medium
{ "lang": "rust", "repo": "PolySync/git-rsl", "path": "/src/bin/git-secure-push.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { loop { selfe_sys::seL4_Yield(); } } }<|fim_prefix|>// repo: iCodeIN/ferros path: /example/hello-printer/src/main.rs #![no_std] #![no_main] use ferros::*; extern crate selfe_runtime; use hello_printer::ProcParams; #[no_mangle] pub extern "C" fn _start(params...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/ferros", "path": "/example/hello-printer/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/ferros path: /example/hello-printer/src/main.rs #![no_std] #![no_main] use ferros::*; extern crate selfe_runtime; use hello_printer::ProcParams; <|fim_suffix|> for i in 0..params.number_of_hellos { debug_println!("Hello elven world {}!", i); } unsafe { loop...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/ferros", "path": "/example/hello-printer/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..params.number_of_hellos { debug_println!("Hello elven world {}!", i); } unsafe { loop { selfe_sys::seL4_Yield(); } } }<|fim_prefix|>// repo: iCodeIN/ferros path: /example/hello-printer/src/main.rs #![no_std] #![no_main] use ferros::*; exte...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/ferros", "path": "/example/hello-printer/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn test<Output: ToString>(expect: Option<String>, solution: fn() -> Output) -> Solution { let args: Vec<String> = std::env::args().collect(); let start = time::precise_time_ns(); let actual = (solution)().to_string(); let end = time::precise_time_ns...
code_fim
hard
{ "lang": "rust", "repo": "akmin04/project-euler-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akmin04/project-euler-rust path: /src/lib.rs use colored::*; use std::fmt::Display; #[macro_export] macro_rules! test_solution { ($expect:expr, $solution:expr) => { fn main() { let solution = $crate::Solution::test(Some(String::from($expect)), $solution); pri...
code_fim
hard
{ "lang": "rust", "repo": "akmin04/project-euler-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 13h3r/highloadcup path: /src/api.rs use serde_json; use hyper::StatusCode; use bytes::Bytes; use data::*; use request::*; use database::Database; pub struct Api { pub database: Database } static EMPTY_VISITS_RESPONSE: &'static [u8] = b"{\"visits\":[]}"; static ZERO_AVERAGE_RESPONSE: &'sta...
code_fim
hard
{ "lang": "rust", "repo": "13h3r/highloadcup", "path": "/src/api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Something(visited_at) = update.visited_at { // possibly deleted in previous branch self.database.visits_by_location .get_mut(&visit.location) .map(|visits| visits.remove(&visit.visited_at)); ...
code_fim
hard
{ "lang": "rust", "repo": "13h3r/highloadcup", "path": "/src/api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let oper = v.remove(0); let right = Value::parse_str(position, v.remove(0))?; if v.len() > 0 { return Err(Error::unexpected_message("extra argument to condition")); } match oper { "-d" => return Ok(DirExists(right)), "!-d" => return Ok(DirNotExists(right)), ...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/nginx-config", "path": "/src/rewrite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/nginx-config path: /src/rewrite.rs use combine::{Parser}; use combine::{choice, optional, many1, position}; use combine::error::StreamError; use combine::easy::Error; use ast::{self, Item}; use grammar::{value, block, Code}; use helpers::{semi, ident, string}; use position::Pos; use to...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/nginx-config", "path": "/src/rewrite.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } } }) .map(Item::Return) .skip(semi()) } fn strip_open_paren<'a>(v: &'_ mut Vec<&'a str>) -> Result<(), Error<Token<'a>, Token<'a>>> { match v.get_mut(0) { Some(s) => { if s.starts_with('(') { if &s[..] != "(" ...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/nginx-config", "path": "/src/rewrite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for MainLoopError { #[inline(always)] fn fmt(&self, f: &mut Formatter) -> fmt::Result { Debug::fmt(self, f) } } impl error::Error for MainLoopError { #[inline(always)] fn source(&self) -> Option<&(error::Error + 'static)> { use self::MainLoopError::*; match self { &PollCre...
code_fim
hard
{ "lang": "rust", "repo": "lemonrock/simple-http-server", "path": "/workspace/simple-http-server/src/MainLoopError.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lemonrock/simple-http-server path: /workspace/simple-http-server/src/MainLoopError.rs // This file is part of simple-http-server. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/simp...
code_fim
medium
{ "lang": "rust", "repo": "lemonrock/simple-http-server", "path": "/workspace/simple-http-server/src/MainLoopError.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hashmismatch/periphery.rs path: /periphery_core/src/device_storage.rs //! A high level abstraction for accessing memory devices like flash, //! SD cards or EEPROMs. use prelude::v1::*; use base::*; use bus::*; use system::*; use device::*; pub fn unit_bytes_to_addressing_mask(unit: u64) -> Opt...
code_fim
hard
{ "lang": "rust", "repo": "hashmismatch/periphery.rs", "path": "/periphery_core/src/device_storage.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let first_sector = offset / s; let sector_offset = offset % s; try!(self.read_sector(first_sector * s, &mut buffer[..])); Ok(StorageDeviceReadBytesIterator { device: self, bytes_remaining: b - offset, buffer: buffer, ...
code_fim
hard
{ "lang": "rust", "repo": "hashmismatch/periphery.rs", "path": "/periphery_core/src/device_storage.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn basic2() { let instr = String::from("cbbd"); let result = String::from("bb"); assert_eq!(Solution::longest_palindrome(instr), result); } }<|fim_prefix|>// repo: miRoox/Leetcode path: /rust/longest-palindromic-substring/src/lib.rs pub struct Solution {} //--...
code_fim
hard
{ "lang": "rust", "repo": "miRoox/Leetcode", "path": "/rust/longest-palindromic-substring/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miRoox/Leetcode path: /rust/longest-palindromic-substring/src/lib.rs pub struct Solution {} //--- impl Solution { #[inline(always)] fn center_spread(s: &[u8], left: usize, right: usize) -> (usize, usize) { let mut lp = left; let mut rp = right; while s[lp] == s[r...
code_fim
hard
{ "lang": "rust", "repo": "miRoox/Leetcode", "path": "/rust/longest-palindromic-substring/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result } fn calculate_postfix(tokens : &[Token]) -> f64 { let mut num_stack = Vec::<f64>::new(); for tok in tokens { match tok { Token::Number(num) => num_stack.push(*num), Token::Operator(op) => { let right = num_stack.pop().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "cLazyZombie/calc_rs", "path": "/src/calculator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cLazyZombie/calc_rs path: /src/calculator.rs pub fn calculate(input: &str) -> f64 { let infix_tokens = tokenize(input); let postfix_tokens = infix_to_postfix(&infix_tokens); calculate_postfix(&postfix_tokens) } // 1 + 2 * 3 - 4 // 1 2 3 * + 4 - // + * // post fix로 수정 // 1 2 3 * + ...
code_fim
hard
{ "lang": "rust", "repo": "cLazyZombie/calc_rs", "path": "/src/calculator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(pop) = op_stack.pop() { postfix.push(Token::Operator(pop)); } postfix } fn tokens_to_string(tokens :&[Token]) -> String { let mut result : String = String::new(); for tok in tokens { if result.is_empty() == false { result.push_str(" "); ...
code_fim
hard
{ "lang": "rust", "repo": "cLazyZombie/calc_rs", "path": "/src/calculator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hummer12007/problem-rs path: /src/lib.rs extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate derive_builder; use serde_json; #[derive(Builder, Debug, Serialize, Deserialize, Clone, Default)] #[builder(public, default)] pub struct Problem { pub title: Strin...
code_fim
hard
{ "lang": "rust", "repo": "Hummer12007/problem-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let response = Response::build() .status(self.status.and_then(Status::from_code).unwrap_or(Status::InternalServerError)) .sized_body(Cursor::new(serde_json::to_vec(&self).unwrap())) .header(ContentType::new("application", "json")) .finalize(); ...
code_fim
medium
{ "lang": "rust", "repo": "Hummer12007/problem-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goodbyekansas/wasmtime path: /crates/wasmtime/src/store.rs ated by instantiating a /// [`Module`](crate::Module) within a `Store`. /// /// `Store` is not thread-safe and cannot be sent to other threads. All items /// which refer to a `Store` additionally are not threadsafe and can only be /// us...
code_fim
hard
{ "lang": "rust", "repo": "goodbyekansas/wasmtime", "path": "/crates/wasmtime/src/store.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> self.frame_info().borrow().contains_pc(addr) } fn custom_signal_handler(&self, call: &dyn Fn(&SignalHandler) -> bool) -> bool { if let Some(handler) = &*self.inner.signal_handler.borrow() { return call(handler); } false } fn max_wasm_stack(&sel...
code_fim
hard
{ "lang": "rust", "repo": "goodbyekansas/wasmtime", "path": "/crates/wasmtime/src/store.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goodbyekansas/wasmtime path: /crates/wasmtime/src/store.rs ds. All items /// which refer to a `Store` additionally are not threadsafe and can only be /// used on the original thread that they were created on. /// /// A `Store` is not intended to be a long-lived object in a program. No form of //...
code_fim
hard
{ "lang": "rust", "repo": "goodbyekansas/wasmtime", "path": "/crates/wasmtime/src/store.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vrbala/rust-learn path: /branches/src/main.rs fn fib(n: u32) -> u32 { if n < 2 { n } else { fib(n-2) + fib(n-1) } } fn main() { // if is a expression - so it returns value // similar to pattern matching, different branches of an if expression are called arm...
code_fim
hard
{ "lang": "rust", "repo": "vrbala/rust-learn", "path": "/branches/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }