text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: tg-rs/tgbot path: /src/types/stickers.rs use crate::types::{ file::InputFile, photo_size::PhotoSize, primitive::{Float, Integer}, }; use serde::{Deserialize, Serialize}; use serde_json::Error as JsonError; use std::{error::Error as StdError, fmt}; /// The part of the face relative t...
code_fim
hard
{ "lang": "rust", "repo": "tg-rs/tgbot", "path": "/src/types/stickers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for MaskPositionError { fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { match self { MaskPositionError::Serialize(err) => write!(out, "can not serialize mask position: {}", err), } } } /// Sticker #[derive(Clone, Debug, Deserialize)] pub stru...
code_fim
hard
{ "lang": "rust", "repo": "tg-rs/tgbot", "path": "/src/types/stickers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let keypair = read_keypair_file(&keypair_path).or_else(|err| { Err(CliError::BadParameter(format!( "{}: Unable to open keypair file: {}", err, keypair_path ))) })?; (key...
code_fim
hard
{ "lang": "rust", "repo": "VIP21/solana", "path": "/cli/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VIP21/solana path: /cli/src/main.rs use clap::{crate_description, crate_name, AppSettings, Arg, ArgGroup, ArgMatches, SubCommand}; use console::style; use solana_clap_utils::{ input_validators::is_url, keypair::{ self, keypair_input, KeypairWithSource, ASK_SEED_PHRASE_ARG, ...
code_fim
hard
{ "lang": "rust", "repo": "VIP21/solana", "path": "/cli/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (results_size_bytes, rest) = rest.split_at(std::mem::size_of::<u64>()); let results_size = u64::from_be_bytes(results_size_bytes.try_into().unwrap()); let (results_bytes, _rest) = rest.split_at(results_size as usize); return bincode::deserialize(results_bytes).unwrap(); }<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "marvis/stork", "path": "/archive/src/index_helpers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marvis/stork path: /archive/src/index_helpers.rs use std::collections::HashMap; use std::convert::TryInto; use crate::models::{StorkEntry, StorkResultOrAlias}; pub fn get_index_version(index: &[u8]) -> String { let (version_size_bytes, rest) = index.split_at(std::mem::size_of::<u64>()); ...
code_fim
hard
{ "lang": "rust", "repo": "marvis/stork", "path": "/archive/src/index_helpers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { ink_env::test::run_test::<ink_env::DefaultEnvironment, _>(|_| { let contract = Contract::default(); assert_eq!(contract.key(), 0); assert_eq!(contract.0.key(), KeyComposer::from_str("Contract::0")); assert_eq!(contract.1.key(), KeyComposer::from_str("Contra...
code_fim
medium
{ "lang": "rust", "repo": "paritytech/ink", "path": "/crates/ink/tests/ui/storage_item/pass/non_packed_tuple_struct.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/ink path: /crates/ink/tests/ui/storage_item/pass/non_packed_tuple_struct.rs use ink_primitives::KeyComposer; use ink_storage::{ traits::StorageKey, Lazy, Mapping, }; <|fim_suffix|> assert_eq!(contract.0.key(), KeyComposer::from_str("Contract::0")); assert_e...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/ink", "path": "/crates/ink/tests/ui/storage_item/pass/non_packed_tuple_struct.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut time = match bus_ids[0].1 { ID(n) => n, NIL => 0, }; let mut jump_by = 1; for (i, bus) in bus_ids { let bus_id = match bus { ID(n) => n, NIL => continue, }; loop { if (time + i as u64) % bus_id == 0 { ...
code_fim
hard
{ "lang": "rust", "repo": "WonderJ13/advent-of-code-2020", "path": "/day13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WonderJ13/advent-of-code-2020 path: /day13/src/main.rs use std::io; use std::str::FromStr; enum Bus { ID(u64), NIL, } use Bus::{ID, NIL}; fn main() { <|fim_suffix|> loop { if (time + i as u64) % bus_id == 0 { jump_by = jump_by * bus_id; ...
code_fim
hard
{ "lang": "rust", "repo": "WonderJ13/advent-of-code-2020", "path": "/day13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod event_channel_ext;<|fim_prefix|>// repo: azriel91/autexousious path: /crate/shrev_support/src/lib.rs #![deny(missing_debug_implementations, missing_docs)] // kcov-ignore <|fim_middle|>//! Extension traits for working with `EventChannel`s. pub use crate::event_channel_ext::EventChannelExt;
code_fim
medium
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/shrev_support/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/shrev_support/src/lib.rs #![deny(missing_debug_implementations, missing_docs)] // kcov-ignore <|fim_suffix|>mod event_channel_ext;<|fim_middle|>//! Extension traits for working with `EventChannel`s. pub use crate::event_channel_ext::EventChannelExt;
code_fim
medium
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/shrev_support/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bernhardfritz/pitunes-archive path: /pitunes-tui/src/models.rs _path = "src/graphql/delete_track_mutation.graphql", response_derives = "Debug" )] pub struct DeleteTrackMutation; #[derive(GraphQLQuery)] #[graphql( schema_path = "src/graphql/schema.json", query_path = "src/graphql/gen...
code_fim
hard
{ "lang": "rust", "repo": "bernhardfritz/pitunes-archive", "path": "/pitunes-tui/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! impl_from { ($from: ty, $for: ty, $($field: ident),*) => { impl From<$from> for $for { fn from(from: $from) -> Self { Self { $($field: from.$field),* } } } }; } impl_from!(album_query::AlbumQu...
code_fim
hard
{ "lang": "rust", "repo": "bernhardfritz/pitunes-archive", "path": "/pitunes-tui/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bernhardfritz/pitunes-archive path: /pitunes-tui/src/models.rs path = "src/graphql/delete_playlist_track_mutation.graphql", response_derives = "Debug" )] pub struct DeletePlaylistTrackMutation; #[derive(GraphQLQuery)] #[graphql( schema_path = "src/graphql/schema.json", query_path = ...
code_fim
hard
{ "lang": "rust", "repo": "bernhardfritz/pitunes-archive", "path": "/pitunes-tui/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kinghajj/netholdem path: /game/src/server.rs /// The core business logic of the server. use std::collections::BTreeMap; use std::convert::From; use std::default::Default; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use futures::channel::mpsc; use futures::lock::Mutex; use ...
code_fim
hard
{ "lang": "rust", "repo": "kinghajj/netholdem", "path": "/game/src/server.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<PendingPhase> for Phase { fn from(p: PendingPhase) -> Self { Phase::Pending(p) } } struct ValidatedPhase { status: Synced<ClientStatus>, } impl From<ValidatedPhase> for Phase { fn from(p: ValidatedPhase) -> Self { Phase::Validated(p) } } struct PlayingPhase...
code_fim
hard
{ "lang": "rust", "repo": "kinghajj/netholdem", "path": "/game/src/server.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = [0u8; (256 * 256) - 1]; loop { let len = socket.recv(&mut buf).await?; let mut packet = PacketHeaders::from_ip_slice(&buf[0..len])?; println!("{:?}", packet.transport); } Ok(()) }<|fim_prefix|>// repo: chengyuhui/win-rawcap path: /src/main.rs use any...
code_fim
medium
{ "lang": "rust", "repo": "chengyuhui/win-rawcap", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chengyuhui/win-rawcap path: /src/main.rs use anyhow::{anyhow, Result}; use etherparse::PacketHeaders; use win_rawcap::create_raw_socket; <|fim_suffix|> let mut buf = [0u8; (256 * 256) - 1]; loop { let len = socket.recv(&mut buf).await?; let mut packet = PacketHeaders::fro...
code_fim
medium
{ "lang": "rust", "repo": "chengyuhui/win-rawcap", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 0x08: unsigned byte // 0x09: signed byte // 0x0B: short (2 bytes) // 0x0C: int (4 bytes) // 0x0D: float (4 bytes) // 0x0E: double (8 bytes) // let dt = match byte32[2] { // 0x08 => DataType::U8, // 0x09 => DataType::I8, ...
code_fim
hard
{ "lang": "rust", "repo": "coriolinus/idx-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coriolinus/idx-rs path: /src/lib.rs use std::io; use std::io::Read; use std::marker::PhantomData; mod casts; use casts::ValueExtractor; #[derive(Debug)] pub enum IdxErr { IOError(io::Error), WrongHeader, UnknownDataType, } pub struct IdxReader<R: Read, T> { source: R, data...
code_fim
hard
{ "lang": "rust", "repo": "coriolinus/idx-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geomatsi/rust-blue-pill-tests path: /src/bin/adc-dma-test3.rs #![no_main] #![no_std] use cm::interrupt::Mutex; use cm::singleton; use core::cell::RefCell; use cortex_m as cm; use cortex_m_rt::entry; use cortex_m_semihosting::hprintln; use hal::adc; use hal::delay::Delay; use hal::dma; use hal::...
code_fim
hard
{ "lang": "rust", "repo": "geomatsi/rust-blue-pill-tests", "path": "/src/bin/adc-dma-test3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let buf = singleton!(: [u16; 4] = [0; 4]).unwrap(); let adc_dma = adc1.with_dma(adc_ch0, dma_ch1); unsafe { nvic.set_priority(stm32::Interrupt::DMA1_CHANNEL1, 1); cm::peripheral::NVIC::unmask(stm32::Interrupt::DMA1_CHANNEL1); } cm::peripheral::NVIC::unpend(stm32::Int...
code_fim
hard
{ "lang": "rust", "repo": "geomatsi/rust-blue-pill-tests", "path": "/src/bin/adc-dma-test3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cxt90730/yigfs path: /client/io_engine/src/types.rs extern crate crossbeam_channel; use common::error::Errno; use crossbeam_channel::Sender; use log::error; #[derive(Debug)] pub struct MsgFileOpenOp { pub id0: u64, pub id1: u64, pub dir: String, pub resp_sender: Sender<MsgFileO...
code_fim
hard
{ "lang": "rust", "repo": "cxt90730/yigfs", "path": "/client/io_engine/src/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct MsgFileWriteOp { // segment ids. pub id0: u64, pub id1: u64, pub dir: String, // maximum size of this segment pub max_size: u64, // file offset, not the offset in the segment. pub offset: u64, pub data: Vec<u8>, pub resp_sender: Sender<Ms...
code_fim
hard
{ "lang": "rust", "repo": "cxt90730/yigfs", "path": "/client/io_engine/src/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut r=self; r.range.step=step; r.range.li_step=r.range.step.x as usize* r.range.li_stride.x as usize; r } } /// interfacing generic 3d array stores/views with iterators /// uses this interface, supporting 3d indices&linear indices /// e.g. in a copy allows traversing one linearly pub trait ...
code_fim
hard
{ "lang": "rust", "repo": "dobkeratops/array3d", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dobkeratops/array3d path: /src/lib.rs n(v3i(2,2,2), |pos|pos.x*200+pos.y*30+pos.z*4); assert_eq!(ar.linear_index(v3i(1,1,1)),1+1*2+1*2*2); assert_eq!(ar[v3i(0,0,0)],000); assert_eq!(ar[v3i(1,0,0)],200); assert_eq!(ar[v3i(1,0,1)],204); assert_eq!(ar[v3i(0,0,1)],004); assert_eq!(ar[v3i...
code_fim
hard
{ "lang": "rust", "repo": "dobkeratops/array3d", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dobkeratops/array3d path: /src/lib.rs et shp=self.shape.clone(); let strd=self.linear_stride(); Array3dIterMut(self, IterXYZ::new(v3i(0,0,0),shp, 0 , strd)) } /// compute the index scales of x/y/z respectively /// x-stride assumed not necaserily one, to allow /// swizzled/strided views e...
code_fim
hard
{ "lang": "rust", "repo": "dobkeratops/array3d", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use crate::nm_access_point::OrgFreedesktopNetworkManagerAccessPoint; let con = Connection::new_system().unwrap(); let proxy = con.with_proxy("org.freedesktop.NetworkManager", p, Duration::new(5, 0)); let hw_addr = proxy.hw_address().expect("can't get HwAddr from DBus"); ...
code_fim
hard
{ "lang": "rust", "repo": "athk0r/net_mgr_handler", "path": "/src/access_point.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: athk0r/net_mgr_handler path: /src/access_point.rs use dbus::blocking::Connection; use std::fmt; use std::time::Duration; #[derive(Clone, PartialEq)] pub struct AccessPoint<'a> { pub path: dbus::Path<'a>, pub ssid: String, pub hw_address: String, pub wpa_flags: u32, } impl<'a> A...
code_fim
hard
{ "lang": "rust", "repo": "athk0r/net_mgr_handler", "path": "/src/access_point.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let wpa_flags = proxy.wpa_flags().expect("can't get WPAFlags from DBus"); wpa_flags } } impl fmt::Debug for AccessPoint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessPoint") .field("Path", &self.path) .field(...
code_fim
hard
{ "lang": "rust", "repo": "athk0r/net_mgr_handler", "path": "/src/access_point.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jackwener/leetcode path: /401.二进制手表.rs /* * @lc app=leetcode.cn id=401 lang=rust * * [401] 二进制手表 */ // @lc code=start use std::cmp::{max, min}; use std::collections::HashMap; <|fim_suffix|> let mut result = vec![]; // there are at most 3 digits for hour and 5 digits for minu...
code_fim
hard
{ "lang": "rust", "repo": "jackwener/leetcode", "path": "/401.二进制手表.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = vec![]; // there are at most 3 digits for hour and 5 digits for minutes for i in max(0, num - 5)..=min(num, 3) { for hour in inverted_map[&i].iter().take_while(|&&h| h < 12) { for minute in inverted_map[&(num - i)].iter() { ...
code_fim
hard
{ "lang": "rust", "repo": "jackwener/leetcode", "path": "/401.二进制手表.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laldon/Pleco path: /pleco/src/bots/mod.rs //! Contains all of the currently completed standard bots/searchers/AIs. //! //! These are mostly for example purposes, to see how one can create a chess AI. //! extern crate rand; pub mod minimax; pub mod parallel_minimax; pub mod alphabeta; pub mod j...
code_fim
hard
{ "lang": "rust", "repo": "laldon/Pleco", "path": "/pleco/src/bots/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl BestMove { #[inline(always)] pub fn new_none(score: Value) -> Self { BestMove { best_move: None, score: score, } } #[inline(always)] pub fn negate(mut self) -> Self { self.score = self.score.wrapping_neg(); self } #...
code_fim
hard
{ "lang": "rust", "repo": "laldon/Pleco", "path": "/pleco/src/bots/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reproto/reproto path: /lib/backend-swift/src/lib.rs mod codegen; mod compiler; mod flavored; mod module; use crate::compiler::Compiler; use crate::flavored::Type; use backend::Initializer; use genco::prelude::*; use manifest::{Lang, Manifest, NoModule, TryFromToml}; use reproto_core::errors::Re...
code_fim
hard
{ "lang": "rust", "repo": "reproto/reproto", "path": "/lib/backend-swift/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut options = Options::new(); for m in modules { log::debug!("+module: {:?}", m); let initializer: Box<dyn Initializer<Options = Options>> = match m { Grpc => Box::new(module::Grpc::new()), Simple => Box::new(module::Simple::new()), Codable...
code_fim
hard
{ "lang": "rust", "repo": "reproto/reproto", "path": "/lib/backend-swift/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub const COEFFICIENTS: [&[f64]; 2] = [ &[ 1.726464144520494, -1.527463564012656, 0.00943060854246944, 0.01318569813624873, 0.00558664508412498, 0.001504104374467998, 0.0002905046453761779, 0.0000409535288341242, 4.026552513069559...
code_fim
hard
{ "lang": "rust", "repo": "hep-rs/special-functions", "path": "/src/other/gamma.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hep-rs/special-functions path: /src/other/gamma.rs #![allow(clippy::all)] use crate::approximations::polynomial; pub fn lower(x: f64) -> f64 { x.recip() * polynomial( x, &[ 1., -0.5772156649015329, 0.9890559953...
code_fim
hard
{ "lang": "rust", "repo": "hep-rs/special-functions", "path": "/src/other/gamma.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yaa110/nomino path: /src/input/source.rs use crate::errors::SortOrderError; use anyhow::Result; use regex::Regex; use std::collections::HashMap; use std::fs; use std::path::MAIN_SEPARATOR; #[derive(PartialEq)] pub enum SortOrder { Asc, Desc, } pub enum Source { Regex(Regex, usize, ...
code_fim
hard
{ "lang": "rust", "repo": "yaa110/nomino", "path": "/src/input/source.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_sort(order: &str) -> Result<Self> { Ok(Self::Sort(match order.to_lowercase().as_str() { "asc" => SortOrder::Asc, "desc" => SortOrder::Desc, _ => return Err(SortOrderError::new(order).into()), })) } }<|fim_prefix|>// repo: yaa110/nomino...
code_fim
hard
{ "lang": "rust", "repo": "yaa110/nomino", "path": "/src/input/source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_map(filename: &str) -> Result<Self> { let contents = fs::read_to_string(filename)?; Ok(Self::Map(serde_json::from_str(contents.as_str()).map( |map: HashMap<String, String>| map.into_iter().collect(), )?)) } pub fn new_sort(order: &str) -> Result<...
code_fim
hard
{ "lang": "rust", "repo": "yaa110/nomino", "path": "/src/input/source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> MutableDocument}; pub use path::Path; pub use value::{Conflicts, Cursor, Primitive, Value};<|fim_prefix|>// repo: ttiurani/automerge-rs path: /automerge-frontend/src/lib.rs mod error; mod frontend; mod mutation; mod path; mod state; mod state_tree; mod value; pub m<|fim_middle|>od value_ref; pub use er...
code_fim
medium
{ "lang": "rust", "repo": "ttiurani/automerge-rs", "path": "/automerge-frontend/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ttiurani/automerge-rs path: /automerge-frontend/src/lib.rs mod error; mod frontend; mod mutation; mod path; mod state; mod state_tree; mod value; pub m<|fim_suffix|> MutableDocument}; pub use path::Path; pub use value::{Conflicts, Cursor, Primitive, Value};<|fim_middle|>od value_ref; pub use er...
code_fim
medium
{ "lang": "rust", "repo": "ttiurani/automerge-rs", "path": "/automerge-frontend/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tialStateError, InvalidPatch, }; pub use frontend::Frontend; pub use mutation::{LocalChange, MutableDocument}; pub use path::Path; pub use value::{Conflicts, Cursor, Primitive, Value};<|fim_prefix|>// repo: ttiurani/automerge-rs path: /automerge-frontend/src/lib.rs mod error; mod frontend; mod mutation; ...
code_fim
medium
{ "lang": "rust", "repo": "ttiurani/automerge-rs", "path": "/automerge-frontend/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elijahandrews/ncollide path: /src/procedural/to_polyline/cuboid_to_polyline.rs use na; use geom::Cuboid; use procedural::{Polyline, ToPolyline}; use procedural; use math::{Scalar, Point, Vect}; impl ToPolyline<()> for Cuboid { fn to_polyline(&self, _: ()) -> Polyline<Scalar, Point, Vect> {...
code_fim
easy
{ "lang": "rust", "repo": "elijahandrews/ncollide", "path": "/src/procedural/to_polyline/cuboid_to_polyline.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> procedural::rectangle(&(self.half_extents() * _2)) } }<|fim_prefix|>// repo: elijahandrews/ncollide path: /src/procedural/to_polyline/cuboid_to_polyline.rs use na; use geom::Cuboid; use procedural::{Polyline, ToPolyline}; use procedural; use math::{Scalar, Point, Vect}; <|fim_middle|>impl T...
code_fim
medium
{ "lang": "rust", "repo": "elijahandrews/ncollide", "path": "/src/procedural/to_polyline/cuboid_to_polyline.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vorot93/rust-btrfs path: /src/linux/types/file_descriptor.rs use crate::linux::imports::*; // ---------- file descriptor with destructor pub struct FileDescriptor { value: libc::c_int, } impl FileDescriptor { pub fn open<AsPath: AsRef<Path>>( path: AsPath, flags: libc:...
code_fim
medium
{ "lang": "rust", "repo": "vorot93/rust-btrfs", "path": "/src/linux/types/file_descriptor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&'a FileDescriptor> for libc::c_int { fn from(file_descriptor: &'a FileDescriptor) -> libc::c_int { file_descriptor.value } }<|fim_prefix|>// repo: vorot93/rust-btrfs path: /src/linux/types/file_descriptor.rs use crate::linux::imports::*; // ---------- file descriptor with ...
code_fim
medium
{ "lang": "rust", "repo": "vorot93/rust-btrfs", "path": "/src/linux/types/file_descriptor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: minterest-finance/minterest-chain-node path: /pallets/traits/src/lib.rs balance-changing action. fn get_user_borrow_index(who: &AccountId, pool_id: CurrencyId) -> Rate; /// Gets total user borrowing. fn get_user_borrow_balance(who: &AccountId, pool_id: CurrencyId) -> Balance; } /// Provide...
code_fim
hard
{ "lang": "rust", "repo": "minterest-finance/minterest-chain-node", "path": "/pallets/traits/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: minterest-finance/minterest-chain-node path: /pallets/traits/src/lib.rs ted data. fn get_pool_data(pool_id: CurrencyId) -> PoolData; /// Get list of users with active loan positions for a particular pool. fn get_pool_members_with_loan(underlying_asset: CurrencyId) -> Vec<AccountId>; /// Ge...
code_fim
hard
{ "lang": "rust", "repo": "minterest-finance/minterest-chain-node", "path": "/pallets/traits/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> /// Checks if the account is a whitelist member. fn is_whitelist_member(who: &AccountId) -> bool; /// Returns the set of all accounts in the whitelist. fn get_whitelist_members() -> BTreeSet<AccountId>; } /// This trait is used to get the exchange rate between underlying assets and wrapped tokens. ...
code_fim
hard
{ "lang": "rust", "repo": "minterest-finance/minterest-chain-node", "path": "/pallets/traits/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgouly/mkl27z-rs path: /build.rs extern crate cc; use std::env; use std::fs; use std::path::PathBuf; fn main() { // Pass our linker script to the top crate let script = "mkl27z.ld"; let src = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()) .join("src"); let out = PathBuf:...
code_fim
medium
{ "lang": "rust", "repo": "jgouly/mkl27z-rs", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let src = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()) .join("src"); let third_party_dir = src.join("third_party"); let files = vec![ "clz.c", "systick.c", "usb_dev.c", "usb_desc.c", "usb_mem.c", "usb_keyboard.c", ]; let flags = vec![ "-mcpu=cortex-m0...
code_fim
medium
{ "lang": "rust", "repo": "jgouly/mkl27z-rs", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtak-/phoenix-tls path: /src/lib.rs //! Utilities for creating always present thread locals. //! //! The `phoenix_tls!` macro creates a `thread_local!` style variable that is lazily initialized. If //! the `thread_local` is accessed after it's destroyed, a new temporary will be created using //!...
code_fim
hard
{ "lang": "rust", "repo": "mtak-/phoenix-tls", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] unsafe fn clone_raw(raw: NonNull<T>) -> Self { let result = ManuallyDrop::new(Phoenix { raw: raw.cast::<PhoenixImpl<T>>(), phantom: PhantomData, }); (*result).clone() } #[inline] fn as_ref(&self) -> &PhoenixImpl<T> { ...
code_fim
hard
{ "lang": "rust", "repo": "mtak-/phoenix-tls", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Phoenix { raw: self.raw, phantom: PhantomData, } } } impl<T: 'static + PhoenixTarget> Drop for Phoenix<T> { #[inline] fn drop(&mut self) { let count = self.as_ref().ref_count.get(); debug_assert!(count > 0, "double free on `Phoenix` ...
code_fim
hard
{ "lang": "rust", "repo": "mtak-/phoenix-tls", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xuorig/anicca path: /src/diff/content.rs use super::media_type::MediaTypeDiff; use crate::openapi::MediaType; use std::collections::BTreeMap; use serde::Serialize; use std::collections::HashMap; pub type MediaTypePair = (String, MediaType); #[derive(Debug, Serialize)] pub struct ContentDiff { ...
code_fim
hard
{ "lang": "rust", "repo": "xuorig/anicca", "path": "/src/diff/content.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> for (media_type, media_type_definition) in base { match head.get(media_type) { Some(head_media_type) => { let media_type_diff = MediaTypeDiff::from_media_types(&media_type_definition, &head_media_type); if...
code_fim
hard
{ "lang": "rust", "repo": "xuorig/anicca", "path": "/src/diff/content.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> print!( "{} {}\n prune to {}? ", &revision.hash[..12], revision.subject().unwrap_or("<no description>"), successor ); loop { print!("[Yn] > "); stdout.flush().await?; ...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/hg-bz-prune", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mythmon/hg-bz-prune path: /src/main.rs //! A tool to automate pruning Mercurial revisions that have landed in mozilla-central. #![deny(clippy::all, clippy::cargo, unsafe_code)] #![warn( clippy::pedantic, clippy::nursery, missing_copy_implementations, missing_crate_level_docs, ...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/hg-bz-prune", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // For every revision, look for a bug number in the revision and then scan // that bug for any comments that indicate the draft has merged. // // The intent is that once a revision that appears prunable is found, the // user will be prompted immediately. At the same time, the search wi...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/hg-bz-prune", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mankenavenkatesh/ibc-rs path: /modules/src/core/ics26_routing/context.rs use crate::applications::ics20_fungible_token_transfer::context::Ics20Context; use crate::core::ics02_client::context::{ClientKeeper, ClientReader}; use crate::core::ics03_connection::context::{ConnectionKeeper, ConnectionR...
code_fim
hard
{ "lang": "rust", "repo": "mankenavenkatesh/ibc-rs", "path": "/modules/src/core/ics26_routing/context.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>t chain. pub trait Ics26Context: ClientReader + ClientKeeper + ConnectionReader + ConnectionKeeper + ChannelKeeper + ChannelReader + PortReader + Ics20Context + Clone { }<|fim_prefix|>// repo: mankenavenkatesh/ibc-rs path: /modules/src/core/ics26_routing/context.rs use...
code_fim
hard
{ "lang": "rust", "repo": "mankenavenkatesh/ibc-rs", "path": "/modules/src/core/ics26_routing/context.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> fn iter_ids(self) -> Self::IntoIterIds { self.iter().with_id().map(|(id, _)| id) } }<|fim_prefix|>// repo: NonJam/shipyard path: /src/iter/mod.rs mod abstract_mut; mod enumerate; mod filter; mod into_abstract; mod into_iter; pub mod iterators; mod map; mod shiperator; mod with_id; <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "NonJam/shipyard", "path": "/src/iter/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NonJam/shipyard path: /src/iter/mod.rs mod abstract_mut; mod enumerate; mod filter; mod into_abstract; mod into_iter; pub mod iterators; mod map; mod shiperator; mod with_id; <|fim_suffix|>impl<T> IntoIterIds for T where T: IntoIter, <T as IntoIter>::IntoIter: CurrentId, { #[allow(c...
code_fim
hard
{ "lang": "rust", "repo": "NonJam/shipyard", "path": "/src/iter/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(get_ngram_with_padding("my fleas", 2, "boo"), vec![ vec!["boo", "my"], vec!["my", "fleas"], vec!["fleas", "boo"]]); }<|fim_prefix|>// repo: hexgnu/rs-natural path: /tests/ngram_tests.rs extern crate natural; use natural::ngram::get_ngram; use natural::ngram::get_ngram_with_padding; <|f...
code_fim
medium
{ "lang": "rust", "repo": "hexgnu/rs-natural", "path": "/tests/ngram_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hexgnu/rs-natural path: /tests/ngram_tests.rs extern crate natural; use natural::ngram::get_ngram; use natural::ngram::get_ngram_with_padding; #[test] fn test_ngram() { assert_eq!(get_ngram("hello my darling", 2), vec![vec!["hello", "my"], vec!["my", "darling"]]); } <|fim_suffix|> assert_e...
code_fim
easy
{ "lang": "rust", "repo": "hexgnu/rs-natural", "path": "/tests/ngram_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use cpucurl::CpuCurl; pub type DefaultCurl = CpuCurl<trytes::BCTrit>; pub type SimpleCurl = CpuCurl<trytes::BCTrit>; pub use ham::CpuHam;<|fim_prefix|>// repo: paulhandy/iota.rs path: /curl-cpu/src/lib.rs #![cfg_attr(test, feature(alloc))] #![no_std] #[cfg(feature = "parallel")] #[macro_use] extern...
code_fim
hard
{ "lang": "rust", "repo": "paulhandy/iota.rs", "path": "/curl-cpu/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulhandy/iota.rs path: /curl-cpu/src/lib.rs #![cfg_attr(test, feature(alloc))] #![no_std] #[cfg(feature = "parallel")] #[macro_use] extern crate std; <|fim_suffix|>#[cfg(test)] extern crate iota_curl_tests as curl_tests; mod indices; mod search; pub mod copy; pub mod cpucurl; pub mod pow; pu...
code_fim
medium
{ "lang": "rust", "repo": "paulhandy/iota.rs", "path": "/curl-cpu/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod indices; mod search; pub mod copy; pub mod cpucurl; pub mod pow; pub mod ham; pub mod simple; pub mod pair; pub use cpucurl::CpuCurl; pub type DefaultCurl = CpuCurl<trytes::BCTrit>; pub type SimpleCurl = CpuCurl<trytes::BCTrit>; pub use ham::CpuHam;<|fim_prefix|>// repo: paulhandy/iota.rs path: /cu...
code_fim
medium
{ "lang": "rust", "repo": "paulhandy/iota.rs", "path": "/curl-cpu/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn rotate(&self, degrees: i32) -> Coordinates { let left_turns = (degrees / 90).rem_euclid(4); let (mut new_x, mut new_y) = (self.x, self.y); for _ in 0..left_turns { // Swap the coordinates, and negate the correct one let swp = new_y; new_y ...
code_fim
hard
{ "lang": "rust", "repo": "Nikheln/advent-of-code-2020", "path": "/src/bin/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nikheln/advent-of-code-2020 path: /src/bin/day12.rs mod helpers; fn main() { let filename: &str = "day12.txt"; let input = helpers::input_helpers::read_input(&filename).unwrap(); task_1(&input); task_2(&input); } fn task_1(input: &[String]) -> u32 { let starting_position = ...
code_fim
hard
{ "lang": "rust", "repo": "Nikheln/advent-of-code-2020", "path": "/src/bin/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnhurt/four-fours path: /four-fours-core/src/native/textures.rs use native::{Texture, TextureLoader}; macro_rules! count { ($h:expr) => (1); ($h:expr, $($t:expr),*) => (1 + count!($($t),*)); } macro_rules! define_texture_atlas { ($texture_type:ident ( x_tile_count: $...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/src/native/textures.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }; } define_texture_atlas!(Card(x_tile_count: 1, y_tile_count: 1) { card(left: 0, top: 0, width: 1, height: 1) }); define_texture_atlas!(Symbols (x_tile_count: 6, y_tile_count: 6) { zero(left: 0, top: 0, width: 1, height: 1), one(left: 1, top: 0, width: 1, height: 1), two(left: 2, top: 0, widt...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/src/native/textures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut counter : f64 = 0.; progress_callback(counter / sub_tex_count); $( let $name = texture_atlas.get_sub_texture( ($left) * tile_width, ($top) * tile_height, ($width) * tile_width, ($height) * tile_heig...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/src/native/textures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>:write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [segd2l](segd2l) module"] pub type SEGD2L = crate::Reg<u32, _SEGD2L>; #[allow(missing_doc...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/lcd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/lcd.rs x64 - Segment Data Low Register 5"] pub segd5l: SEGD5L, #[doc = "0x68 - Segment Data Low Register 6"] pub segd6l: SEGD6L, #[doc = "0x6c - Segment Data Low Register 7"] pub segd7l: SEGD7L, #[doc = "0x70 - Segment Data H...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/lcd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [segd7l](segd7l) module"] pub type SEGD7L = crate::Reg<u32, _SEGD7L>; #[allow(missing_docs)] #[doc(hidden)] pub struct _SEGD7L; #[doc = "`read()` method returns [segd7l::R](segd7l::R) reader stru...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/lcd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sergiineodnichyk/rpi4-rust-workspace path: /rtsp/src/response.rs //! Response //! //! [RFC2326](https://tools.ietf.org/html/rfc2326#section-7) use crate::{Emit, Headers, Parse, StatusLine}; use core::fmt; use nom::IResult; // TODO - flatten status line fields #[derive(Clone, Debug, PartialEq, ...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/rtsp/src/response.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let hdrs = headers_for_options(); let t = Response { status_line: (Version::new(1, 0), StatusCode::new(200)).into(), headers: hdrs, }; let mut buffer: String<U256> = String::new(); assert_eq!(t.emit(&mut buffer), Ok(())); assert_eq!(b...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/rtsp/src/response.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn emit_describe() { let hdrs = headers_for_describe(); let t = Response { status_line: (Version::new(1, 0), StatusCode::new(200)).into(), headers: hdrs, }; let mut buffer: String<U256> = String::new(); assert_eq!(t.emit(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/rtsp/src/response.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>RUCT ! { struct DCOMPOSITION_FRAME_STATISTICS { lastFrameTime : LARGE_INTEGER currentCompositionRate : DXGI_RATIONAL currentTime : LARGE_INTEGER timeFrequency : LARGE_INTEGER nextEstimatedFrameTime : LARGE_INTEGER } } pub const COMPOSITIONOBJECT_READ : DWORD = 0x0001 ; pub const COMPOSITIONOBJECT_WRITE : ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/winapi/src/shared/dcomptypes.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/winapi/src/shared/dcomptypes.rs use shared : : dxgitype : : DXGI_RATIONAL ; use shared : : minwindef : : DWORD ; use um : : winnt : : LARGE_INTEGER ; ENUM ! { enum DCOMPOSITION_BITMAP_INTERPOLATION_MODE { DCOMPOSITION_BITMA...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/winapi/src/shared/dcomptypes.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Copy, Debug)] pub enum EarnedPointType { Point1600, Point1000, Point800, Point400, } pub fn to_earned_point_type(point: u32) -> Option<EarnedPointType> { match point { 1600 => Some(EarnedPointType::Point1600), 1000 => Some(EarnedPointType::Point1000), ...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/galangua", "path": "/galangua-core/src/app/game/effect/effect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoangpq/galangua path: /galangua-core/src/app/game/effect/effect.rs use crate::app::consts::*; use crate::app::game::enemy::EnemyType; use crate::framework::types::Vec2I; use crate::framework::RendererTrait; use crate::util::math::{quantize_angle, round_up}; pub enum Effect { SequentialSpri...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/galangua", "path": "/galangua-core/src/app/game/effect/effect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.frame < self.sprites.len() as u32 } pub fn draw<R>(&self, renderer: &mut R) where R: RendererTrait, { if self.delay >= 0 { return; } let sprite = self.sprites[self.frame as usize]; renderer.draw_sprite(sprite, &self.pos); ...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/galangua", "path": "/galangua-core/src/app/game/effect/effect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmars/glop path: /src/agent/server.rs extern crate bytes; extern crate futures; extern crate futures_cpupool; extern crate itertools; extern crate serde_json; extern crate tokio_core; extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; use std; use std::collections::Has...
code_fim
hard
{ "lang": "rust", "repo": "cmars/glop", "path": "/src/agent/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self.decode_prelude(buf) { Ok(Some((id, codec))) => { self.auth_id = Some(id); self.codec = Some(codec); } Ok(None) => {} Err(e) => return Err(e), } if let (&Some(ref id), &mut Some(ref mut codec)...
code_fim
hard
{ "lang": "rust", "repo": "cmars/glop", "path": "/src/agent/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_addr(addr: std::net::SocketAddr, path: &str) -> Result<Server, Error> { std::fs::DirBuilder::new().recursive(true) .mode(0o700) .create(path) .map_err(Error::IO)?; Ok(Server { addr: addr, agents_path: std::path::Pat...
code_fim
hard
{ "lang": "rust", "repo": "cmars/glop", "path": "/src/agent/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs // run-pass // Check tautalogically false `Sized` bounds #![feature(trivial_bounds)] #![allow(unused)] trait A {} impl A for i32 {} <|fim_suffix|>fn return_str() -> str where str: Sized { ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn unsized_local() where for<'a> T<dyn A + 'a>: Sized { let x: T<dyn A> = *(Box::new(T { x: 1 }) as Box<T<dyn A>>); } fn return_str() -> str where str: Sized { *"Sized".to_string().into_boxed_str() } fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/trivial-b...
code_fim
easy
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gunjunlee/ps path: /baekjoon/src/bin/2580.rs macro_rules! parse_list { ($t: ty) => {{ let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let list: Vec<$t> = line .split_whitespace() .map(|w| w.parse::<$t>().unwrap()) ...
code_fim
hard
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/2580.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// 0 0 4 6 0 0 2 8 0 // 0 1 0 0 8 2 0 0 7 // 0 5 0 0 3 9 0 0 6 // 0 0 8 3 0 0 1 6 0 // 0 9 7 0 0 0 0 0 0 // 4 0 0 2 0 8 9 0 0 // 3 0 0 1 4 0 0 9 0 // 0 7 9 0 2 0 0 4 0 // 0 0 0 0 0 5 6 0 0 // 0 0 5 3 0 0 0 0 0 // 8 0 0 0 0 0 0 2 0 // 0 7 0 0 1 0 5 0 0 // 4 0 0 0 0 5 3 0 0 // 0 1 0 0 7 0 0 0 6 // 0 0 3 2 ...
code_fim
hard
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/2580.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut arr = vec![vec![0; 9]; 9]; for i in 0..9 { arr[i] = parse_list!(i32); } solve_sudoku(&mut arr, 0, 0); for i in arr.iter() { for j in i.iter() { print!("{} ", j); } println!(""); } } // 0 0 4 6 0 0 2 8 0 // 0 1 0 0 8 2 0 0 7 // 0 ...
code_fim
hard
{ "lang": "rust", "repo": "gunjunlee/ps", "path": "/baekjoon/src/bin/2580.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: projektir/algs-data-structs path: /Rust/rs-fizzbuzz/src/main.rs fn main() { let fizz_buzz = fizz_buzz(100); print!("{}", fizz_buzz); } <|fim_suffix|> let mut fizz_buzz = String::default(); let mut current = 1; while current < count { if current % 15 == 0 { ...
code_fim
medium
{ "lang": "rust", "repo": "projektir/algs-data-structs", "path": "/Rust/rs-fizzbuzz/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while current < count { if current % 15 == 0 { fizz_buzz.push_str("FizzBuzz\n"); } else if current % 5 == 0 { fizz_buzz.push_str("Buzz\n"); } else if current % 3 == 0 { fizz_buzz.push_str("Fizz\n"); } else { fizz_buzz = fo...
code_fim
medium
{ "lang": "rust", "repo": "projektir/algs-data-structs", "path": "/Rust/rs-fizzbuzz/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haze/dawn path: /cache/trait/src/lib.rs use async_trait::async_trait; use std::fmt::Debug; pub trait Cache: Debug + Send + Sync {} #[async_trait] pub trait UpdateCache<T: Cache, Err> { async fn update(&self, item: &T) -> Result<(), Err>; } #[cfg(test)] mod tests { use super::{Cache, U...
code_fim
medium
{ "lang": "rust", "repo": "haze/dawn", "path": "/cache/trait/src/lib.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_cache_bounds() { static_assertions::assert_obj_safe!(Cache); assert_impl_all!(dyn Cache: Debug, Send, Sync); } #[test] fn test_cache_update_bounds() { static_assertions::assert_obj_safe!(UpdateCache<(), ()>); } }<|fim_prefix|>// repo: haze/d...
code_fim
medium
{ "lang": "rust", "repo": "haze/dawn", "path": "/cache/trait/src/lib.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> _ => return Err(SQLRiteError::Internal("Error parsing query".to_string())), } } } #[cfg(test)] mod tests { use super::*; use crate::sql::*; // A simple test just have something for now #[test] fn create_table_test() { let input = process_command("CRE...
code_fim
hard
{ "lang": "rust", "repo": "xiongxin/rust_sqlite", "path": "/src/sql/parser/create.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }