text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>pub(crate) fn parse_date(value: &str, time_zone: Tz) -> Result<DateTime<Tz>, Error> { if value.contains(':') { let datetime = NaiveDateTime::parse_from_str(value, DATETIME_FORMAT)?; time_zone .from_local_datetime(&datetime) .single() .ok_or_else(|| E...
code_fim
hard
{ "lang": "rust", "repo": "asmarques/alphavantage", "path": "/src/deserialize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asmarques/alphavantage path: /src/deserialize.rs use crate::error::Error; use chrono::prelude::*; use chrono_tz::Tz; use serde::de::{self, Deserialize, Deserializer}; use std::fmt::Display; use std::str::FromStr; <|fim_suffix|>pub(crate) fn parse_date(value: &str, time_zone: Tz) -> Result<DateT...
code_fim
hard
{ "lang": "rust", "repo": "asmarques/alphavantage", "path": "/src/deserialize.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>m::drop); my_demux[c] -> for_each(std::mem::drop); my_demux[c] -> for_each(std::mem::drop); }; df.run_available(); }<|fim_prefix|>// repo: hydro-project/hydroflow path: /hydroflow/tests/compile-fail/surface_demux_port_duplicate.rs use hydroflow::{hydroflow_syntax, var_args}; fn m...
code_fim
hard
{ "lang": "rust", "repo": "hydro-project/hydroflow", "path": "/hydroflow/tests/compile-fail/surface_demux_port_duplicate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hydro-project/hydroflow path: /hydroflow/tests/compile-fail/surface_demux_port_duplicate.rs use hydroflow::{hydroflow_syntax, var_args}; fn main() { let mut df = hydroflow_syntax! { my_demux = source_iter(0..10) -> dem<|fim_suffix|> 2 => c.give(item), } });...
code_fim
medium
{ "lang": "rust", "repo": "hydro-project/hydroflow", "path": "/hydroflow/tests/compile-fail/surface_demux_port_duplicate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// An specified `<integer>`, optionally coming from a `calc()` expression. /// /// https://drafts.csswg.org/css-values/#integers #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Integer ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/style/values/specified/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 9999years/dotfile-manager path: /src/nix.rs use std::io; use std::path::Path; use std::process::Command; use serde::de::DeserializeOwned; use thiserror::Error; #[derive(Error, Debug)] pub enum NixEvalError { #[error("nix-instantiate binary not found: {0}")] NoNix(io::Error), #[erro...
code_fim
medium
{ "lang": "rust", "repo": "9999years/dotfile-manager", "path": "/src/nix.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use super::*; #[test] fn nix_eval_file() { let res = dbg!(eval_file::<Vec<String>>(&PathBuf::from("test-data/string-list.nix"))); // Allow tests to pass on systems without Nix installed. if res.is_err() { assert!(matches!(res, Err(NixEvalError::NoNix(_))));...
code_fim
hard
{ "lang": "rust", "repo": "9999years/dotfile-manager", "path": "/src/nix.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let signal = [0.0, 1.0, 2.0, 5.0, 2.0, 1.0]; let target = [1.0, 2.0]; assert_eq!(correlate_signal(&signal, &target), vec![2.0, 5.0, 12.0, 9.0, 4.0, 1.0]); } #[test] fn test_correlation() { let signal = [0.0, 1.0, 2.0, 5.0, 2.0, 1.0]; let target = [1.0, 2.0]; assert_eq!(correlation::<Correl...
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/signal_processing", "path": "/src/correlation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamnemecek/signal_processing path: /src/correlation.rs use super::fourier_transform; use super::fourier_transform::FourierTransform; use super::polar::Polar; use super::rectangular::Rectangular; use super::Sample; pub fn correlate_signal(signal: &[Sample], target: &[Sample]) -> Vec<Sample> { ...
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/signal_processing", "path": "/src/correlation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustyPro/rust_gpiozero path: /src/input_devices.rs //! Input device component interfaces for devices such as `Button` use rppal::gpio::{Gpio, InputPin, Level, Trigger}; use std::time::Duration; /// Represents a generic GPIO input device. #[derive(Debug)] pub struct InputDevice { pin: InputP...
code_fim
hard
{ "lang": "rust", "repo": "RustyPro/rust_gpiozero", "path": "/src/input_devices.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> match timeout { None => { if active { self.pin.set_interrupt(Trigger::RisingEdge).unwrap(); self.pin.poll_interrupt(true, None).unwrap(); } else { self.pin.set_interr...
code_fim
hard
{ "lang": "rust", "repo": "RustyPro/rust_gpiozero", "path": "/src/input_devices.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magiclen/boyer-moore-magiclen path: /tests/character.rs #![cfg(feature = "character")] mod common; use boyer_moore_magiclen::*; const INPUT_DATA_PATH: &str = r"tests/data/character.txt"; <|fim_suffix|> common::data_input_from_file( INPUT_DATA_PATH, |text, pattern, answer, ...
code_fim
medium
{ "lang": "rust", "repo": "magiclen/boyer-moore-magiclen", "path": "/tests/character.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(answer, bm.find_full_all_in(&text)); assert_eq!( answer.iter().rev().copied().collect::<Vec<usize>>(), bm.rfind_full_all_in(&text) ); assert_eq!(answer_not_full, bm.find_all_in(&text)); assert_eq!(answer...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/boyer-moore-magiclen", "path": "/tests/character.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: southwhale/FlashFunk path: /flashfunk-core/src/types/message.rs use crate::structs::{AccountData, CancelRequest, ContractData, OrderData, OrderRequest, PositionData, QueryRequest, SubscribeRequest, TickData, TradeData, ExtraOrder, ExtraTrade, ContractVec}; pub enum MdApiMessage { TickData(...
code_fim
hard
{ "lang": "rust", "repo": "southwhale/FlashFunk", "path": "/flashfunk-core/src/types/message.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub enum StrategyMessage { OrderRequest(OrderRequest), CancelRequest(CancelRequest), QueryReq(QueryRequest), MockTdTickData(TickData), } impl From<OrderRequest> for StrategyMessage { fn from(data: OrderRequest) -> Self { Self::OrderRequest(data) } } impl From<CancelReque...
code_fim
hard
{ "lang": "rust", "repo": "southwhale/FlashFunk", "path": "/flashfunk-core/src/types/message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/ui/carnelian/examples/textgrid.rs // Copyright 2021 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::Error, argh::FromArgs, carnelian::{ ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/carnelian/examples/textgrid.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn create_view_assistant(&mut self, _: ViewKey) -> Result<ViewAssistantPtr, Error> { let filename = self.filename.clone(); let background = self.background; let foreground = self.foreground; let cell_size = self.cell_size; Ok(Box::new(Text...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/carnelian/examples/textgrid.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl TextGridViewAssistant { pub fn new(filename: String, background: Color, foreground: Color, cell_size: Size) -> Self { Self { filename, background, foreground, cell_size, scene_details: None } } } impl ViewAssistant for TextGridViewAssistant { fn resize(&mut self, _new_size: &Size...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/carnelian/examples/textgrid.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn list_objects(&self, bucket: String, after: Option<String>) -> Result<Vec<String>> { let mut objects = Vec::new(); if let Some(items) = self .client .list_objects_v2(ListObjectsV2Request { bucket, start_after: after, ...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/aws/s3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saturn-xiv/peony path: /src/aws/s3.rs use std::fmt; use rusoto_core::{request::HttpClient, Region}; use rusoto_s3::{ CreateBucketRequest, DeleteBucketRequest, DeleteObjectRequest, GetBucketLocationRequest, ListObjectsV2Request, PutObjectRequest, S3Client, S3 as S3Provider, }; use super...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/aws/s3.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn put_object( &self, bucket: String, name: String, body: Vec<u8>, acl: &Acl, ) -> Result<()> { self.client .put_object(PutObjectRequest { acl: Some(acl.to_string()), bucket, key: ...
code_fim
hard
{ "lang": "rust", "repo": "saturn-xiv/peony", "path": "/src/aws/s3.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>&self) -> NyetR { let bits = { const MASK: u8 = 1; const OFFSET: u8 = 6; ((self.bits >> OFFSET) & MASK as u32) as u8 }; NyetR { bits } } #[doc = "Bit 7 - Transaction error"] #[inline(always)] pub fn txerr(&self) -> TxerrR { ...
code_fim
hard
{ "lang": "rust", "repo": "gbip/stm32f429x", "path": "/src/otg_hs_host/otg_hs_hcint4/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gbip/stm32f429x path: /src/otg_hs_host/otg_hs_hcint4/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::OtgHsHcint4 { #[doc = r" Modifies the contents of the register"] #...
code_fim
hard
{ "lang": "rust", "repo": "gbip/stm32f429x", "path": "/src/otg_hs_host/otg_hs_hcint4/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcmehta/raytracer path: /src/perlin.rs use rand::{prelude::SliceRandom, thread_rng}; use crate::vec3::*; const POINT_COUNT: usize = 256; pub struct Perlin { random_vectors: Vec<Vec3>, perm_x: Vec<usize>, perm_y: Vec<usize>, perm_z: Vec<usize>, } impl Perlin { pub fn new()...
code_fim
hard
{ "lang": "rust", "repo": "rcmehta/raytracer", "path": "/src/perlin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PetoStr/dinai path: /src/main.rs use dinai::math::{AABBf, Matrix, Vector2f}; use dinai::neuralnet::NeuralNetwork; use dinai::window::{GameWindow, TextRenderer, WindowConfig}; use rayon::prelude::*; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::Rect; use std::time::Instant...
code_fim
hard
{ "lang": "rust", "repo": "PetoStr/dinai", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if ctx.game_window.is_key_pressed(&Keycode::K) { ctx.speed += 0.3 * ctx.step_s; } if ctx.game_window.is_key_pressed(&Keycode::J) { ctx.speed -= 0.3 * ctx.step_s; ctx.speed = ctx.speed.max(0.1); } Ok(()) } fn update(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "PetoStr/dinai", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> properties.insert("prototype".to_string(), JSItem::Object { mutable: false, properties: prototype }); if let Ok(..) = set_object(&mut int, or_path.clone(), JSItem::Object { mutable: false, properties ...
code_fim
hard
{ "lang": "rust", "repo": "richwandell/rustjs", "path": "/src/ast_interpreter/std/function.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: richwandell/rustjs path: /src/ast_interpreter/std/function.rs use crate::parser::symbols::{JSItem, StdFun}; use crate::lexer::js_token::Tok; use crate::ast_interpreter::std::inherit::inherit; use crate::ast_interpreter::interpreter::Interpreter; use crate::ast_interpreter::std::array::array_cons...
code_fim
hard
{ "lang": "rust", "repo": "richwandell/rustjs", "path": "/src/ast_interpreter/std/function.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> b.iter(|| 1232.5768787779797.to_string()); }<|fim_prefix|>// repo: yberreby/benchmarks path: /benches/to_string.rs #![feature(test)] extern crate test; use test::Bencher; #[bench] fn bench_integer_to_string(b: &mut Bencher) { b.iter(|| 1232.to_string()); } <|fim_middle|>#[bench] fn bench_floa...
code_fim
easy
{ "lang": "rust", "repo": "yberreby/benchmarks", "path": "/benches/to_string.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yberreby/benchmarks path: /benches/to_string.rs #![feature(test)] extern crate test; use test::Bencher; #[bench] fn bench_integer_to_string(b: &mut Bencher) { <|fim_suffix|>#[bench] fn bench_float_to_string(b: &mut Bencher) { b.iter(|| 1232.5768787779797.to_string()); }<|fim_middle|> b....
code_fim
easy
{ "lang": "rust", "repo": "yberreby/benchmarks", "path": "/benches/to_string.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: conf8o/chohnaikai path: /src/survey/mod.rs use std::fmt; use std::error::Error; pub trait Survey where Self::Item: Weightable, Self::Items: Iterator<Item=Self::Item> { type Item; type Items; fn gather(&self) -> Result<Self::Items, SurveyError>; <|fim_suffix|>} ...
code_fim
medium
{ "lang": "rust", "repo": "conf8o/chohnaikai", "path": "/src/survey/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct SurveyError { pub msg: &'static str } impl fmt::Display for SurveyError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "notice error: {}", self.msg) } } impl Error for SurveyError {}<|fim_prefix|>// repo: conf8o/chohnaik...
code_fim
hard
{ "lang": "rust", "repo": "conf8o/chohnaikai", "path": "/src/survey/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bazaah/jira-rs path: /crates/libjira/src/models/issue/mod.rs pub mod common; pub mod create; pub mod issue; pub mod metadat<|fim_suffix|>b use {common::*, create::*, issue::*, metadata::*, search::*};<|fim_middle|>a; pub mod search; use { super::cow, serde::{Deserialize, Serialize}, ...
code_fim
medium
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/models/issue/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ze, Serialize}, std::{borrow::Cow, convert::TryFrom}, }; pub use {common::*, create::*, issue::*, metadata::*, search::*};<|fim_prefix|>// repo: bazaah/jira-rs path: /crates/libjira/src/models/issue/mod.rs pub mod common; pub mod create; pub mod issue; pub mod metadat<|fim_middle|>a; pub mod search; ...
code_fim
medium
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/models/issue/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b use {common::*, create::*, issue::*, metadata::*, search::*};<|fim_prefix|>// repo: bazaah/jira-rs path: /crates/libjira/src/models/issue/mod.rs pub mod common; pub mod create; pub mod issue; pub mod metadat<|fim_middle|>a; pub mod search; use { super::cow, serde::{Deserialize, Serialize}, ...
code_fim
medium
{ "lang": "rust", "repo": "bazaah/jira-rs", "path": "/crates/libjira/src/models/issue/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while leaves > 0 { // (2n-5)!! res *= leaves % 1_000_000; leaves -= 2; } println!("{}", res); Ok(()) }<|fim_prefix|>// repo: tamerh/rosalind2 path: /src/phylogeny/cunr.rs use std::io; //https://cis.gvsu.edu/~wolffe/courses/cs677/projects/treeConstruction.pdf //http://www.cs.cornell...
code_fim
medium
{ "lang": "rust", "repo": "tamerh/rosalind2", "path": "/src/phylogeny/cunr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tamerh/rosalind2 path: /src/phylogeny/cunr.rs use std::io; //https://cis.gvsu.edu/~wolffe/courses/cs677/projects/treeConstruction.pdf //http://www.cs.cornell.edu/courses/cs426/2003fa/Week10%20Phylogenetic%20Trees.pdf //http://carrot.mcb.uconn.edu/mcb396_41/tree_number.html //http://static.cs.br...
code_fim
medium
{ "lang": "rust", "repo": "tamerh/rosalind2", "path": "/src/phylogeny/cunr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { match try_main() { Err(KvError::KeyNotFound(_)) => { // The spec states that these errors go to stdout. println!("Key not found"); std::process::exit(1); } Err(err) => { eprintln!("{}", err); let mut src_op...
code_fim
hard
{ "lang": "rust", "repo": "nthery/practical-networked-apps-rust", "path": "/src/bin/kvs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match try_main() { Err(KvError::KeyNotFound(_)) => { // The spec states that these errors go to stdout. println!("Key not found"); std::process::exit(1); } Err(err) => { eprintln!("{}", err); let mut src_opt = err.sour...
code_fim
hard
{ "lang": "rust", "repo": "nthery/practical-networked-apps-rust", "path": "/src/bin/kvs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nthery/practical-networked-apps-rust path: /src/bin/kvs.rs use clap::{App, AppSettings, Arg, SubCommand}; use kvs::{self, EngineKind, KvError, KvStore, KvsEngine, Result, SledKvsEngine}; use std::error::Error; fn try_main() -> Result<()> { let matches = App::new("kvs") .version(env!...
code_fim
hard
{ "lang": "rust", "repo": "nthery/practical-networked-apps-rust", "path": "/src/bin/kvs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zlcatwu/kvs path: /src/lib.rs #![deny(missing_docs)] //! KvStore lib code use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fs::{File, OpenOptions}; use std::io::{BufRead, BufReader, Seek, SeekFrom, Write, BufWriter}; use std::path::PathBuf; use failure::Fail; /// Kv...
code_fim
hard
{ "lang": "rust", "repo": "zlcatwu/kvs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn fetch_value(&mut self, offset: u64) -> Result<String> { self.file_handle.seek(SeekFrom::Start(offset))?; let mut cmd = String::new(); let mut reader = BufReader::new(&self.file_handle); reader.read_line(&mut cmd)?; if let Command::Set { ...
code_fim
hard
{ "lang": "rust", "repo": "zlcatwu/kvs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-dapp-collecation/share-ride path: /program/programs/share-ride/src/lib.rs // #region code use anchor_lang::prelude::*; use borsh::{BorshDeserialize, BorshSerialize}; #[program] pub mod share_ride { use super::*; #[state] pub struct ShareRideState { pub authority: Pub...
code_fim
hard
{ "lang": "rust", "repo": "solana-dapp-collecation/share-ride", "path": "/program/programs/share-ride/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remove_driver(&mut self, _ctx: Context<Auth>, archive: Archive) -> Result<()> { let dummy = Archive { archive: String::from("___________________________________________"), }; msg!("Dummy {:?}", dummy); for i in 0..10 { ...
code_fim
hard
{ "lang": "rust", "repo": "solana-dapp-collecation/share-ride", "path": "/program/programs/share-ride/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn remove_ride(&mut self, _ctx: Context<Auth>, archive: Archive) -> Result<()> { let dummy = Archive { archive: String::from("___________________________________________"), }; msg!("Dummy {:?}", dummy); for i in 0..10 { ...
code_fim
hard
{ "lang": "rust", "repo": "solana-dapp-collecation/share-ride", "path": "/program/programs/share-ride/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Source::from_str("true").unwrap(), Source::Const(true.into()) ); assert_eq!( Source::from_str("false").unwrap(), Source::Const(false.into()) ); } #[test] fn parse_int_src() { assert_eq!(Source:...
code_fim
hard
{ "lang": "rust", "repo": "slowtec/msr", "path": "/crates/msr-legacy/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slowtec/msr path: /crates/msr-legacy/src/parser.rs use super::*; use std::io::{Error, ErrorKind, Result}; use std::str::FromStr; impl FromStr for Comparison { type Err = Error; fn from_str(s: &str) -> Result<Self> { use crate::Comparator::*; if s.trim().is_empty() { ...
code_fim
hard
{ "lang": "rust", "repo": "slowtec/msr", "path": "/crates/msr-legacy/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanmonstar/warp path: /src/filter/and_then.rs use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use futures_util::{ready, TryFuture}; use pin_project::pin_project; use super::{Filter, FilterBase, Func, Internal}; use crate::reject::CombineRejection; #[derive(Clone, ...
code_fim
hard
{ "lang": "rust", "repo": "seanmonstar/warp", "path": "/src/filter/and_then.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { self.project().state.poll(cx) } } impl<T, F> Future for State<T, F> where T: TryFuture, F: Func<T::Ok>, F::Output: TryFuture + Send, <F::Output as TryFuture>::Error: CombineRejection<T::Error>, { ...
code_fim
hard
{ "lang": "rust", "repo": "seanmonstar/warp", "path": "/src/filter/and_then.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dqsully/aw-time-limit path: /src/main.rs use std::error::Error; use std::env; use std::fs; use std::ops::{Add, Sub}; use std::path::Path; use std::process::exit; use std::thread; use std::time; use notify_rust::Notification; use reqwest::blocking as reqwest; use ::reqwest::StatusCode; use chrono...
code_fim
hard
{ "lang": "rust", "repo": "dqsully/aw-time-limit", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let today = get_today(); let today_naive = today.naive_local(); self.load_extension(today_naive)?; let seconds = self.query_aw(today)?; if seconds > DEFAULT_TIME + self.extension { let new_overage = match self.logged_overage_date { Non...
code_fim
hard
{ "lang": "rust", "repo": "dqsully/aw-time-limit", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cargorust/point_cloud_viewer path: /xray/src/bin/merge_xray_quadtrees.rs use fnv::FnvHashSet; use point_viewer::color::Color; use quadtree::{Node, NodeId}; use std::fs::create_dir_all; use std::path::{Path, PathBuf}; use structopt::StructOpt; use xray::{generation, Meta}; #[derive(StructOpt, De...
code_fim
hard
{ "lang": "rust", "repo": "cargorust/point_cloud_viewer", "path": "/xray/src/bin/merge_xray_quadtrees.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let args = CommandlineArguments::from_args(); for input_directory in &args.input_directories { assert!( input_directory.exists(), format!("Input directory {:?} doesn't exist.", input_directory) ); assert!( input_directory.metadata().unwra...
code_fim
hard
{ "lang": "rust", "repo": "cargorust/point_cloud_viewer", "path": "/xray/src/bin/merge_xray_quadtrees.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>where I: Iterator<Item = V>, V: std::cmp::PartialEq, { all_equal_by_func(iterator, |left, right| left == right) } fn all_equal_by_func<I, V, F>(mut iterator: I, comp: F) -> Option<V> where I: Iterator<Item = V>, F: Fn(&V, &V) -> bool, { iterator.next().and_then(|first_element| { ...
code_fim
hard
{ "lang": "rust", "repo": "cargorust/point_cloud_viewer", "path": "/xray/src/bin/merge_xray_quadtrees.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lapz/tox path: /semant/src/lower/enums.rs use crate::impl_collector; use crate::{ hir::{self, Enum, FunctionAstMap}, util, HirDatabase, TextRange, }; use std::sync::Arc; use syntax::{ast, AstNode, NameOwner, TypeParamsOwner, TypesOwner, VisibilityOwner}; #[derive(Debug)] pub(crate) str...
code_fim
hard
{ "lang": "rust", "repo": "Lapz/tox", "path": "/semant/src/lower/enums.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let exported = enum_.visibility().is_some(); if let Some(type_params_list) = enum_.type_param_list() { for type_param in type_params_list.type_params() { collector.lower_type_param(type_param); } } if let Some(variant_list) = enum_.variant_list() { for...
code_fim
hard
{ "lang": "rust", "repo": "Lapz/tox", "path": "/semant/src/lower/enums.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn run (&mut self, (world, phys_objects, mut world_positions): Self::SystemData) { for (phys_object, mut world_pos) in (&phys_objects, &mut world_positions).join() { match phys_object.body_handle { Uninitialized => {}, Initialized(body_handle) => { ...
code_fim
hard
{ "lang": "rust", "repo": "thealexhoar/ligeia", "path": "/src/game/systems/phys/physics_set_position.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thealexhoar/ligeia path: /src/game/systems/phys/physics_set_position.rs use specs::{Join, ParJoin, ReadExpect, ReadStorage, System, WriteStorage}; use game::components::{PhysicsHandle::*, PhysicsObject, WorldPosition}; use physics::{meters_to_pix, PhysicsWorld}; pub struct PhysicsSetPosition; ...
code_fim
hard
{ "lang": "rust", "repo": "thealexhoar/ligeia", "path": "/src/game/systems/phys/physics_set_position.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match matches.subcommand() { ("show", Some(show_matches)) => { let mut all = false; verbosity += show_matches.occurrences_of("verbose"); match show_matches.subcommand() { ("all", Some(all_matches)) => { all = true; ...
code_fim
hard
{ "lang": "rust", "repo": "mre/repoctl", "path": "/src/bin/repoctl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mre/repoctl path: /src/bin/repoctl.rs #[macro_use] extern crate clap; extern crate repoctl; extern crate syslog; extern crate walkdir; use clap::{App, AppSettings}; use walkdir::WalkDir; use repoctl::repository::*; use syslog::{Facility, Severity}; fn main() { // Loading the arguments desc...
code_fim
hard
{ "lang": "rust", "repo": "mre/repoctl", "path": "/src/bin/repoctl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: igaryhe/Raytracer path: /src/hitable/mod.rs mod hitrecord; mod hitablelist; mod sphere; <|fim_suffix|>pub trait Hitable { fn hit(&self, r: &Ray, t_min: f32, t_max: f32, rec: &mut HitRecord) -> bool; }<|fim_middle|>pub use hitrecord::HitRecord; pub use hitablelist::HitableList; pub use spher...
code_fim
medium
{ "lang": "rust", "repo": "igaryhe/Raytracer", "path": "/src/hitable/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adam-mcdaniel/maroon-lang path: /tools/src/evaluator.rs use io_tools::*; use logging::*; use preprocessor::*; use std::process; use string_tools::*; use std::cmp; pub struct Evaluator { preserved_program: String, data: Vec<String>, logging: bool, } impl Evaluator { pub fn new(p...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/maroon-lang", "path": "/tools/src/evaluator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.push( vec!["none.(\\.".to_owned() + &num.to_string()+"\\.)"] ); } else if n == "@index_string".to_string() { let num_a = &self.safe_pop(); let string_a = &self.safe_pop(); ...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/maroon-lang", "path": "/tools/src/evaluator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = match arg1 == arg2 { true => "a.b.a", false => "a.b.b", }; self.push(vec![result.to_string()]); } else if n == "@concat".to_string() { let arg1 = &se...
code_fim
hard
{ "lang": "rust", "repo": "adam-mcdaniel/maroon-lang", "path": "/tools/src/evaluator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let zero = Word::new([O; 16]); let mut clock = Clock::new(); let mut ram4k = RAM4K::new(); let word1 = Word::new([I, O, I, O, I, O, I, O, I, O, I, O, I, O, I, O]); ram4k.input(&clock, word1, [O, O, O, O, O, O, O, O, O, O, O, O], I); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "cola119/nand2tetris-rs", "path": "/hardware/src/base/ram.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> clock.next(); // Tick ram8.input(&clock, one, [O, O, I], I); // register[0]: prev: 1, cur: I, register[1]: prev: 0, cur: 1 assert_eq!(ram8.output(&clock, [O, O, O]), one); assert_eq!(ram8.output(&clock, [O, O, I]), zero); assert_eq!(ram8.output(&clock, [O, I...
code_fim
hard
{ "lang": "rust", "repo": "cola119/nand2tetris-rs", "path": "/hardware/src/base/ram.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cola119/nand2tetris-rs path: /hardware/src/base/ram.rs RAM8::new(); 8], } } pub fn input(&mut self, clock_t: &Clock, input: Word, address: [bit; 6], load: bit) { let load_bit = dmux8way(load, [address[0], address[1], address[2]]); let register_address = [address[3...
code_fim
hard
{ "lang": "rust", "repo": "cola119/nand2tetris-rs", "path": "/hardware/src/base/ram.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>> [-<<<->>>]<<<[->>>+<<<]>>>>>>>>]<<<<<<<<+<[>[->+>[-<-<<<<<<<<<<+>>>>>>>>>>>>[-<< +>>]<]>[-<<-<<<<<<<<<<+>>>>>>>>>>>>]<<<]>>[-<+>>[-<<-<<<<<<<<<<+>>>>>>>>>>>>]<]> [-<<+>>]<<<<<<<<<<<<<]]>>>>[-<<<<+>>>>]<<<<[->>>>+>>>>>[>+>>[-<<->>]<<[->>+<<]>> >>>>>>]<<<<<<<<+<[>[->+>>[-<<-<<<<<<<<<<+>>>>>>>>>>>[-<+>]>]<...
code_fim
hard
{ "lang": "rust", "repo": "Sirius708/brainfuck-interpreter", "path": "/examples/mandelbrot.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sirius708/brainfuck-interpreter path: /examples/mandelbrot.rs use brainfuck_interpreter::run_program; static PROGRAM: &str = r#" A mandelbrot set fractal viewer in brainf*** written by Erik Bosman +++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ >>>>>>>>>]+[...
code_fim
hard
{ "lang": "rust", "repo": "Sirius708/brainfuck-interpreter", "path": "/examples/mandelbrot.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>[->>>->[-<<<<+>>>>]<<<<[->>>>+<<<<<<<<<<<<<[<<<<<<<<< ]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>[-<<<<->>>>]+<<<<[->>>>-<[-<<<+>>>]<<<[->>>+< <<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]> >>>>>>>]<<<<<<<<<[<<<<<<<<<]>>->>[-<<<<+>>>>]<<<<[->>>>+<<[-]<<]>>]<<+>>>>[-<<<< ->>>>]+<<...
code_fim
hard
{ "lang": "rust", "repo": "Sirius708/brainfuck-interpreter", "path": "/examples/mandelbrot.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> for (mut dude, velocity) in (&mut dudes, &velocities).join() { println!("{:?}", velocity); } } }<|fim_prefix|>// repo: jakequade/strain path: /src/systems/physics.rs use amethyst::{ core::{SystemDesc, Transform}, derive::SystemDesc, ecs::{Join, Read, ReadStorag...
code_fim
medium
{ "lang": "rust", "repo": "jakequade/strain", "path": "/src/systems/physics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakequade/strain path: /src/systems/physics.rs use amethyst::{ core::{SystemDesc, Transform}, derive::SystemDesc, ecs::{Join, Read, ReadStorage, System, SystemData, WriteStorage}, }; use crate::components::{dude::Dude, velocity::Velocity}; #[derive(SystemDesc)] pub struct PhysicsSy...
code_fim
medium
{ "lang": "rust", "repo": "jakequade/strain", "path": "/src/systems/physics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elitecodegroovy/thinking-in-rust path: /app06/src/routes/answer.rs use warp::http::StatusCode; use crate::store::Store; use crate::types::answer::NewAnswer; pub async fn add_answer( store: Store, new_answer: NewAnswer, ) -> Result<impl warp::Reply, warp::Rejection<|fim_suffix|>tatus("A...
code_fim
medium
{ "lang": "rust", "repo": "elitecodegroovy/thinking-in-rust", "path": "/app06/src/routes/answer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>> { match store.add_answer(new_answer).await { Ok(_) => { Ok(warp::reply::with_status("Answer added", StatusCode::OK)) } Err(e) => Err(warp::reject::custom(e)), } }<|fim_prefix|>// repo: elitecodegroovy/thinking-in-rust path: /app06/src/routes/answer.rs use war...
code_fim
medium
{ "lang": "rust", "repo": "elitecodegroovy/thinking-in-rust", "path": "/app06/src/routes/answer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let instance = <&Client>::clone(&self); let mut req = instance.client.request(method, url); // Set the default headers. req = req.header( reqwest::header::ACCEPT, reqwest::header::HeaderValue::from_static("application/json"), ); req...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/shipbob/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /shipbob/src/lib.rs st form that tells ShipBob's fulfillment centers what inventory should be received and stocked. Some other solutions call this an “ASN” or Advanced Ship Notice. WROs may include multiple inventory items with specific quantities. Mor...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/shipbob/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Use the Products Resource to retrieve and create product records in ShipBob. /// /// A product is a virtual record created in ShipBob’s system via a channel. Say a merchant has two Shopify stores (each store would have its own channel), Kevin’s Shopify Store #133 and Kevin’s Shopify store ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/shipbob/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = [0x41, 0x42, 0xab, 0xcd]; let _ = spi.transfer(&mut buf); loop {} }<|fim_prefix|>// repo: koalatux/riscv-rust-mfrc522 path: /examples/spi.rs #![no_std] #![no_main] extern crate panic_halt; use riscv_rt::entry; use hifive1::hal::prelude::*; use hifive1::hal::e310x::Peripherals...
code_fim
hard
{ "lang": "rust", "repo": "koalatux/riscv-rust-mfrc522", "path": "/examples/spi.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koalatux/riscv-rust-mfrc522 path: /examples/spi.rs #![no_std] #![no_main] extern crate panic_halt; use riscv_rt::entry; use hifive1::hal::prelude::*; use hifive1::hal::e310x::Peripherals; use hifive1::hal::spi::{Spi, MODE_0}; #[entry] fn main() -> ! { <|fim_suffix|> // Configure SPI le...
code_fim
hard
{ "lang": "rust", "repo": "koalatux/riscv-rust-mfrc522", "path": "/examples/spi.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fitzgen/z3-rs path: /src/model.rs use z3_sys::*; use Solver; use Optimize; use Model; use Ast; use Z3_MUTEX; use std::ffi::CStr; use std::fmt::{Display, Formatter}; use std; use context; impl<'ctx> Model<'ctx> { pub fn of_solver(slv: &Solver<'ctx>) -> Model<'ctx> { Model { ...
code_fim
hard
{ "lang": "rust", "repo": "fitzgen/z3-rs", "path": "/src/model.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn eval(&self, ast: &Ast<'ctx>) -> Option<Ast<'ctx>> { unsafe { let mut tmp : Z3_ast = ast.z3_ast; let res; { let guard = Z3_MUTEX.lock().unwrap(); res = Z3_model_eval(self.ctx.z3_ctx, s...
code_fim
hard
{ "lang": "rust", "repo": "fitzgen/z3-rs", "path": "/src/model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ula-lang/ula path: /src/parser/parselets/led/multiplicative.rs use crate::ast::Expr; use crate::lexer::{Op, Token}; use crate::parser::parselets::Led; use crate::parser::Parser; use crate::ast::exprs::{Div, Mod, Mul}; pub struct MultiplicativeParselet; impl Led for MultiplicativeParselet { ...
code_fim
medium
{ "lang": "rust", "repo": "ula-lang/ula", "path": "/src/parser/parselets/led/multiplicative.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Token::Op(Op::Div) => { Ok(Div::new(lhs, rhs).into()) } Token::Op(Op::Mod) => { Ok(Mod::new(lhs, rhs).into()) } _ => unreachable!() } } fn get_precedence(&self) -> i8 { 13 } }<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "ula-lang/ula", "path": "/src/parser/parselets/led/multiplicative.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn my_test() { assert_eq!(Solution::max_value(7,2,7+3), 2); // 1 1 1 1 1 1 1 // ^ // 1 1 2 1 1 1 1 (8) assert_eq!(Solution::max_value(7,2,7+4), 3); // 1 2 3 2 1 1 1 (11) assert_eq!(Solution::max_value(7,2,7+15), 4+1); // 2...
code_fim
hard
{ "lang": "rust", "repo": "Ainevsia/Leetcode-Rust", "path": "/1802. Number of Students Unable to Eat Lunch/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_works() { assert_eq!(Solution::max_value(4,2,6), 2); assert_eq!(Solution::max_value(6,1,10), 3); assert_eq!(Solution::max_value(16,4,200), 17); assert_eq!(Solution::max_value(2,1,865959216), 432979608); } #[test] fn my_test() { ass...
code_fim
medium
{ "lang": "rust", "repo": "Ainevsia/Leetcode-Rust", "path": "/1802. Number of Students Unable to Eat Lunch/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ainevsia/Leetcode-Rust path: /1802. Number of Students Unable to Eat Lunch/src/lib.rs pub struct Solution {} impl Solution { pub fn max_value(n: i32, index: i32, max_sum: i32) -> i32 { let (n, index, max_sum) = (n as usize, index as usize, max_sum as usize); let l = index.mi...
code_fim
hard
{ "lang": "rust", "repo": "Ainevsia/Leetcode-Rust", "path": "/1802. Number of Students Unable to Eat Lunch/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lamakaio/tinyjazz path: /src/frontend/parser_wrapper/parser.rs __end0 = __lookahead.clone(); let __temp0 = __action192( file_id, input, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); __action304( file_id, input, ...
code_fim
hard
{ "lang": "rust", "repo": "Lamakaio/tinyjazz", "path": "/src/frontend/parser_wrapper/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 'input, >( file_id: usize, input: &'input str, __lookbehind: &usize, __lookahead: &usize, ) -> Vec<Arg> { let __start0 = __lookbehind.clone(); let __end0 = __lookahead.clone(); let __temp0 = __action157( file_id, input, &__start0, &__end0, ...
code_fim
hard
{ "lang": "rust", "repo": "Lamakaio/tinyjazz", "path": "/src/frontend/parser_wrapper/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>(__start, __Symbol::Variant23(__nt), __end)); (0, 32) } pub(crate) fn __reduce57< 'input, >( file_id: usize, input: &'input str, __lookahead_start: Option<&usize>, __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, _: ::std:...
code_fim
hard
{ "lang": "rust", "repo": "Lamakaio/tinyjazz", "path": "/src/frontend/parser_wrapper/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lizechoo/Rust-vs-Clang-CPSC311 path: /Rust/ownership2.rs fn main() { // understanding ownership <|fim_suffix|> let p = &mut a; println!("p is {}, {}, {}", p[0], p[1], p[2]); let v = vec![1, 2, 3]; let mut v2 = v; println!("v is {:?}", v); println!("v2 is {:?}", v...
code_fim
medium
{ "lang": "rust", "repo": "lizechoo/Rust-vs-Clang-CPSC311", "path": "/Rust/ownership2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v = vec![1, 2, 3]; let mut v2 = v; println!("v is {:?}", v); println!("v2 is {:?}", v2); }<|fim_prefix|>// repo: lizechoo/Rust-vs-Clang-CPSC311 path: /Rust/ownership2.rs fn main() { // understanding ownership <|fim_middle|> let mut a: [i32; 3] = [1, 2, 3]; println!("a i...
code_fim
medium
{ "lang": "rust", "repo": "lizechoo/Rust-vs-Clang-CPSC311", "path": "/Rust/ownership2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("v is {:?}", v); println!("v2 is {:?}", v2); }<|fim_prefix|>// repo: lizechoo/Rust-vs-Clang-CPSC311 path: /Rust/ownership2.rs fn main() { // understanding ownership let mut a: [i32; 3] = [1, 2, 3]; println!("a is {}, {}, {}", a[0], a[1], a[2]); let p = &mut a; pr...
code_fim
easy
{ "lang": "rust", "repo": "lizechoo/Rust-vs-Clang-CPSC311", "path": "/Rust/ownership2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> name: &Ident, generics: &syn::Generics, its: impl Iterator<Item = IterMeta<'a>>, ) -> proc_macro2::TokenStream { let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); let implementations = its.map( |IterMeta { primary_field, field...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/cao-storage-derive/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kissmikijr/caolo-backend path: /sim/cao-storage-derive/src/lib.rs //! Helper crate to generate the caolo-sim crate's data storage structs' //! #![crate_type = "proc-macro"] use proc_macro::TokenStream; use proc_macro2::TokenTree; use quote::quote; use std::collections::HashMap; use syn::{parse_m...
code_fim
hard
{ "lang": "rust", "repo": "kissmikijr/caolo-backend", "path": "/sim/cao-storage-derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: subsid/sandbox path: /rust-sandbox/src/bin/smart_pointers.rs mod box_basics { use std::ops::Deref; #[derive(Debug)] enum List<T> { Cons(T, Box<List<T>>), Nil } struct MyBox<T>(T); impl<T> Deref for MyBox<T> { type Target = T; fn deref(&...
code_fim
hard
{ "lang": "rust", "repo": "subsid/sandbox", "path": "/rust-sandbox/src/bin/smart_pointers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(v, *w); } } mod ref_counting { use std::rc::Rc; #[derive(Debug)] pub enum List<T> { Cons(T, Rc<List<T>>), Nil } pub fn run() { let a = Rc::new(List::Cons("my dear ", Rc::new(List::Cons("world", Rc::new(List::Nil))))); println!("...
code_fim
hard
{ "lang": "rust", "repo": "subsid/sandbox", "path": "/rust-sandbox/src/bin/smart_pointers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalorder/tetrust path: /src/playtime_ctrl.rs use crate::updateable_view::{UpdatableView, Ctrl}; use crate::view::{View, ShowArgs}; pub struct PlaytimeCtrl { frame_counter: u32, view: UpdatableView, } <|fim_suffix|> pub fn frames(self: &Self) -> u32 { self.frame_counter ...
code_fim
medium
{ "lang": "rust", "repo": "digitalorder/tetrust", "path": "/src/playtime_ctrl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let min = self.frame_counter / 60 / 60; let sec = self.frame_counter / 60 % 60; let csec = (self.frame_counter % 60) * 100 / 60; self.view.show(view, &ShowArgs::PlaytimeArgs{ min, sec, csec }); } }<|fim_prefix|>// repo: digitalorder/tetrust path: /s...
code_fim
hard
{ "lang": "rust", "repo": "digitalorder/tetrust", "path": "/src/playtime_ctrl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Interval::OneMinute => { write!(f, "1m") }, Interval::TwoMinute => { write!(f, "2m") }, Interval::FiveMinutes => { write!(f, "5m") }, Interval::FifteenMi...
code_fim
hard
{ "lang": "rust", "repo": "svmk/fund-watch-bot", "path": "/src/yahoo_finance/model/common_api/interval.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svmk/fund-watch-bot path: /src/yahoo_finance/model/common_api/interval.rs use std::fmt; #[derive(Debug)] #[allow(dead_code)] pub enum Interval { OneMinute, TwoMinute, FiveMinutes, FifteenMinutes, ThirtyMinutes, SixtyMinutes, NinetyMinutes, OneHour, OneDay, ...
code_fim
hard
{ "lang": "rust", "repo": "svmk/fund-watch-bot", "path": "/src/yahoo_finance/model/common_api/interval.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }