text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: Diggsey/srcl path: /src/digest/mod.rs use std::fmt::Debug; #[macro_use] pub mod macros; pub mod chunked; pub mod sha1; pub mod sha2; pub trait Digest: Clone + AsRef<[u8]> + Into<Box<[u8]>> + Debug {} <|fim_suffix|> fn new() -> Self; fn update(&mut self, input: &[u8]); fn digest(sel...
code_fim
easy
{ "lang": "rust", "repo": "Diggsey/srcl", "path": "/src/digest/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut state = Self::new(); state.update(input); state.digest() } }<|fim_prefix|>// repo: Diggsey/srcl path: /src/digest/mod.rs use std::fmt::Debug; #[macro_use] pub mod macros; pub mod chunked; pub mod sha1; pub mod sha2; pub trait Digest: Clone + AsRef<[u8]> + Into<Box<[u...
code_fim
medium
{ "lang": "rust", "repo": "Diggsey/srcl", "path": "/src/digest/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreywkruger/rustd path: /src/entities/mod.rs pub mod screen; pub mod game; pub mod keymap<|fim_suffix|>vector2d; pub mod face; pub mod mesh; pub mod geometry; pub mod importer; pub mod scene;<|fim_middle|>; pub mod camera; pub mod vector3d; pub mod
code_fim
easy
{ "lang": "rust", "repo": "coreywkruger/rustd", "path": "/src/entities/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coreywkruger/rustd path: /src/entities/mod.rs pub mod screen; pub mod game; pub mod keymap; pub mod camera; pub mod vector3d; pub mod <|fim_suffix|>d geometry; pub mod importer; pub mod scene;<|fim_middle|>vector2d; pub mod face; pub mod mesh; pub mo
code_fim
easy
{ "lang": "rust", "repo": "coreywkruger/rustd", "path": "/src/entities/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>vector2d; pub mod face; pub mod mesh; pub mod geometry; pub mod importer; pub mod scene;<|fim_prefix|>// repo: coreywkruger/rustd path: /src/entities/mod.rs pub mod screen; pub mod game; pub mod keymap<|fim_middle|>; pub mod camera; pub mod vector3d; pub mod
code_fim
easy
{ "lang": "rust", "repo": "coreywkruger/rustd", "path": "/src/entities/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sfackler/rust-postgres path: /postgres-types/src/bit_vec_06.rs use bit_vec_06::BitVec; use bytes::BytesMut; use postgres_protocol::types; use std::error::Error; use crate::{FromSql, IsNull, ToSql, Type}; impl<'a> FromSql<'a> for BitVec { fn from_sql(_: &Type, raw: &[u8]) -> Result<BitVec, ...
code_fim
hard
{ "lang": "rust", "repo": "sfackler/rust-postgres", "path": "/postgres-types/src/bit_vec_06.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ToSql for BitVec { fn to_sql(&self, _: &Type, out: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> { types::varbit_to_sql(self.len(), self.to_bytes().into_iter(), out)?; Ok(IsNull::No) } accepts!(BIT, VARBIT); to_sql_checked!(); }<|fim_prefix|>// repo: ...
code_fim
medium
{ "lang": "rust", "repo": "sfackler/rust-postgres", "path": "/postgres-types/src/bit_vec_06.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> types::varbit_to_sql(self.len(), self.to_bytes().into_iter(), out)?; Ok(IsNull::No) } accepts!(BIT, VARBIT); to_sql_checked!(); }<|fim_prefix|>// repo: sfackler/rust-postgres path: /postgres-types/src/bit_vec_06.rs use bit_vec_06::BitVec; use bytes::BytesMut; use postgres_pro...
code_fim
hard
{ "lang": "rust", "repo": "sfackler/rust-postgres", "path": "/postgres-types/src/bit_vec_06.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if user_resp.code != ResponseCode::from(381) { return Err(Error::Failure { code: user_resp.code, resp: user_resp, msg: Some("AUTHINFO USER failed".to_string()), }); } debug!("Sending AUTHINFO PASS"); let pass_resp = conn.command(&cmd::Au...
code_fim
hard
{ "lang": "rust", "repo": "stefan-kuepper/brokaw", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stefan-kuepper/brokaw path: /src/client.rs use std::borrow::Borrow; use std::convert::{TryFrom, TryInto}; use std::net::ToSocketAddrs; use log::*; use crate::error::{Error, Result}; use crate::raw::connection::{ConnectionConfig, NntpConnection}; use crate::raw::response::RawResponse; use crat...
code_fim
hard
{ "lang": "rust", "repo": "stefan-kuepper/brokaw", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> debug!("Sending AUTHINFO PASS"); let pass_resp = conn.command(&cmd::AuthInfo::Pass(password.as_ref().to_string()))?; if pass_resp.code() != ResponseCode::Known(Kind::AuthenticationAccepted) { return Err(Error::Failure { code: pass_resp.code, resp: pass_resp, ...
code_fim
hard
{ "lang": "rust", "repo": "stefan-kuepper/brokaw", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> format!( "{}: {}{}{}", line_num, before.bright_white(), self.search_str.bright_red(), after.bright_white() ) } }<|fim_prefix|>// repo: TamplierS1/tinygrep path: /src/result.rs use colored::*; #[derive(Clone)] pub struct Sear...
code_fim
medium
{ "lang": "rust", "repo": "TamplierS1/tinygrep", "path": "/src/result.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // There is no need for pattern matching, we know that the line // contains the word let (before, after) = self.line.split_once(&self.search_str).unwrap(); format!( "{}: {}{}{}", line_num, before.bright_white(), self.search_s...
code_fim
medium
{ "lang": "rust", "repo": "TamplierS1/tinygrep", "path": "/src/result.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TamplierS1/tinygrep path: /src/result.rs use colored::*; #[derive(Clone)] pub struct SearchResult { pub index: usize, pub line: String, pub search_str: String, pub filename: String, } <|fim_suffix|> format!( "{}: {}{}{}", line_num, bef...
code_fim
hard
{ "lang": "rust", "repo": "TamplierS1/tinygrep", "path": "/src/result.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> std::thread::spawn(move || stdin_loop(tx)); } fn stdin_loop(tx: mpsc::Sender<Message>) { loop { let mut line = String::new(); let line = match io::stdin().read_line(&mut line) { Ok(0) => break, Ok(_len) => line.trim().to_string(), Err(error) => ...
code_fim
hard
{ "lang": "rust", "repo": "jessa0/minecraft-relay", "path": "/relay/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jessa0/minecraft-relay path: /relay/src/main.rs use anyhow::Context; use bytes::Bytes; use core::convert::Infallible; use core::time::Duration; use std::io; use std::net::SocketAddr; use std::sync::mpsc; use minecraft_relay::discovery::DiscoveryListener; use minecraft_relay::relay::{Relay, Relay...
code_fim
hard
{ "lang": "rust", "repo": "jessa0/minecraft-relay", "path": "/relay/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn start_listen_thread(listener: RelayListener, relay: RelayHandle, tx: mpsc::Sender<Message>) { std::thread::spawn(move || async_io::block_on(listen_loop(listener, relay, tx))); } async fn listen_loop(listener: RelayListener, relay: RelayHandle, tx: mpsc::Sender<Message>) -> Infallible { relay.l...
code_fim
hard
{ "lang": "rust", "repo": "jessa0/minecraft-relay", "path": "/relay/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StefanMoller1/actix_with_tokio_microservice path: /src/web/router/mod.rs use actix_session::Session; use actix_web::Error; #[allow(unused_imports)] use log::{debug, error, info}; use serde::{Deserialize, Serialize}; use std::{fmt, str}; <|fim_suffix|>impl fmt::Display for Cache { fn fmt(&self...
code_fim
medium
{ "lang": "rust", "repo": "StefanMoller1/actix_with_tokio_microservice", "path": "/src/web/router/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let encoded: Vec<u8> = bincode::serialize(&data).unwrap(); session.set("session", encoded) }<|fim_prefix|>// repo: StefanMoller1/actix_with_tokio_microservice path: /src/web/router/mod.rs use actix_session::Session; use actix_web::Error; #[allow(unused_imports)] use log::{debug, error, info}; use ser...
code_fim
hard
{ "lang": "rust", "repo": "StefanMoller1/actix_with_tokio_microservice", "path": "/src/web/router/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_time(&self) -> &Option<CmusTime> { &self.time } } impl TryFrom<String> for CmusData { type Error = Error; fn try_from(string: String) -> Result<Self, Self::Error> { const STATUS_NAME: &str = "status"; const FILE_NAME: &str = "file"; const TIME_D...
code_fim
hard
{ "lang": "rust", "repo": "Noah2610/cmus-status-line", "path": "/src/cmus_status/data/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *data_name { STATUS_NAME => { status = Some(CmusPlaybackStatus::try_from(data_line.as_str())?); } FILE_NAME => { file = Some(PathBuf::from(data_line.as_str())); ...
code_fim
hard
{ "lang": "rust", "repo": "Noah2610/cmus-status-line", "path": "/src/cmus_status/data/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noah2610/cmus-status-line path: /src/cmus_status/data/mod.rs mod playback_status; mod time; pub mod prelude { pub use super::CmusData; pub use super::CmusPlaybackStatus; pub use super::{CmusTime, Seconds}; } pub use playback_status::CmusPlaybackStatus; pub use time::{CmusTime, Seco...
code_fim
hard
{ "lang": "rust", "repo": "Noah2610/cmus-status-line", "path": "/src/cmus_status/data/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // The text is explicitly aligned to the right of the cell. Right, } #[derive(Deserialize, Serialize, Debug, Default)] #[serde(rename_all = "camelCase")] pub struct EmbeddedChart { pub chart_id: Option<u64>, pub spec: ChartSpec, pub position: EmbeddedObjectPosition, } #[derive(Deseri...
code_fim
hard
{ "lang": "rust", "repo": "makarski/esurvey", "path": "/src/sheets/spreadsheets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(default)] pub font_size: u64, #[serde(default)] pub bold: bool, #[serde(default)] pub italic: bool, #[serde(default)] pub strikethrough: bool, #[serde(default)] pub underline: bool, } #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelC...
code_fim
hard
{ "lang": "rust", "repo": "makarski/esurvey", "path": "/src/sheets/spreadsheets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makarski/esurvey path: /src/sheets/spreadsheets.rs use serde_derive::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Debug, Default)] #[serde(rename_all = "camelCase")] pub struct Spreadsheet { pub spreadsheet_id: String, // #[serde(skip)] // properties: Vec<SpreadsheetPr...
code_fim
hard
{ "lang": "rust", "repo": "makarski/esurvey", "path": "/src/sheets/spreadsheets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match *self { Error::DecodeBase64(ref err) => fmt::Display::fmt(err, f), Error::DecodeJson(ref err) => fmt::Display::fmt(err, f), Error::OpensslError(ref err) => fmt::Display::fmt(err, f), Error::InvalidToken => write!(f, "Invalid Token"), ...
code_fim
hard
{ "lang": "rust", "repo": "borisfaure/signin", "path": "/src/errors.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl From<base64::DecodeError> for Error { #[inline] fn from(error: base64::DecodeError) -> Error { Error::DecodeBase64(error) } } impl From<serde_json::Error> for Error { #[inline] fn from(error: serde_json::Error) -> Error { Error::DecodeJson(error) } } impl From<...
code_fim
hard
{ "lang": "rust", "repo": "borisfaure/signin", "path": "/src/errors.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: borisfaure/signin path: /src/errors.rs use base64; use openssl; use serde_json; use std::fmt; #[derive(Debug)] pub enum Error { DecodeBase64(base64::DecodeError), DecodeJson(serde_json::Error), OpensslError(openssl::error::ErrorStack), InvalidToken, InvalidIssuer, Invali...
code_fim
hard
{ "lang": "rust", "repo": "borisfaure/signin", "path": "/src/errors.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub mod alpha_compositing; pub mod aura_shell; pub mod buffer; pub mod client; pub mod compositor; pub mod data_device_manager; pub mod dispatcher; pub mod display; pub mod linux_dmabuf; pub mod object; pub mod output; pub mod pointer_constraints; pub mod registry; pub mod relative_pointer; pub mod scenic...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/wayland/server/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/lib/ui/wayland/server/src/lib.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. <|fim_suffix|>pub mod alpha_compositing; pub mod aura_shell; pub mod b...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/lib/ui/wayland/server/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Texture { id: u32, } impl Texture { pub fn new(width: i32, height: i32, data: &[u8]) -> Self { assert_eq!(data.len() as i32, width * height); unsafe { let mut texture: u32 = 0; gl::GenTextures(1, &mut texture); gl::Bi...
code_fim
hard
{ "lang": "rust", "repo": "rehwinkel/winkel", "path": "/src/gl_renderer/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rehwinkel/winkel path: /src/gl_renderer/utils.rs pub mod shader { use std::collections::HashMap; pub struct Shader { id: u32, } impl Shader { fn new(source: &str, kind: u32) -> Self { let bytes = [source.as_bytes(), &[0]].concat(); let src ...
code_fim
hard
{ "lang": "rust", "repo": "rehwinkel/winkel", "path": "/src/gl_renderer/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { gl::DeleteBuffers(1, &self.vertex_buffer); gl::DeleteVertexArrays(1, &self.id); } } } #[derive(Debug)] pub struct Texture { id: u32, } impl Texture { pub fn new(width: i32, height: i32, data: &[u8]) -> Self { assert_eq!(data.len() as i...
code_fim
hard
{ "lang": "rust", "repo": "rehwinkel/winkel", "path": "/src/gl_renderer/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jibbow/arrow2 path: /src/array/primitive/ffi.rs use crate::{ array::{FromFFI, ToFFI}, datatypes::DataType, ffi::ArrowArray, types::NativeType, }; use crate::error::Result; use super::PrimitiveArray; unsafe impl<T: NativeType> ToFFI for PrimitiveArray<T> { fn buffers(&self)...
code_fim
hard
{ "lang": "rust", "repo": "Jibbow/arrow2", "path": "/src/array/primitive/ffi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if offset > 0 { values = values.slice(offset, length); validity = validity.map(|x| x.slice(offset, length)) } Ok(Self::from_data(data_type, values, validity)) } }<|fim_prefix|>// repo: Jibbow/arrow2 path: /src/array/primitive/ffi.rs use crate::{ arr...
code_fim
hard
{ "lang": "rust", "repo": "Jibbow/arrow2", "path": "/src/array/primitive/ffi.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reem/httparse path: /src/lib.rs r = "!" / "#" / "$" / "%" / "&" / "'" / "*" /// > / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" /// > / DIGIT / ALPHA /// > ; any VCHAR, except delimiters /// > ``` macro_rules! is_token { ($b:expr) => ({...
code_fim
hard
{ "lang": "rust", "repo": "reem/httparse", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_shrink() { let mut arr = [EMPTY_HEADER; 16]; { let slice = &mut &mut arr[..]; assert_eq!(slice.len(), 16); shrink!(slice, 4); assert_eq!(slice.len(), 4); } assert_eq!(arr.len(), 16); } macro_ru...
code_fim
hard
{ "lang": "rust", "repo": "reem/httparse", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reem/httparse path: /src/lib.rs unsafe { use std::mem::transmute; use std::raw::Slice; transmute(Slice { data: $buf.as_ptr().offset($from as isize), len: $to - $from }) } } } macro_rules! shrink { (...
code_fim
hard
{ "lang": "rust", "repo": "reem/httparse", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..MAX_BANK_SNAPSHOTS_TO_RETAIN + 2 { let parent_slot = i as Slot; let bank = Bank::new_from_parent( bank_forks[parent_slot].clone(), &Pubkey::default(), parent_slot + 1, ); let slot = bank.slot(); let key1 = Keypair:...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/core/tests/snapshots.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/solana path: /core/tests/snapshots.rs AccountSecondaryIndexes::default(), None, accounts_db::AccountShrinkThreshold::default(), check_hash_calculation, false, false, Some(ACCOUNTS_DB_CONFIG_FOR_TESTING), None, Arc::defa...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/core/tests/snapshots.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solana-labs/solana path: /core/tests/snapshots.rs ot_config.maximum_incremental_snapshot_archives_to_retain, ) .unwrap(); // Restore bank from snapshot let (_tmp_dir, temporary_accounts_dir) = create_tmp_accounts_dir_for_tests(); let account_paths = &[temporary_accounts_dir]...
code_fim
hard
{ "lang": "rust", "repo": "solana-labs/solana", "path": "/core/tests/snapshots.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: declanvk/scalable-concurrent-containers path: /src/ebr.rs //! Epoch-based reclamation. //! //! The epoch consensus algorithm and the use of memory barriers and RMW are similar to that of //! [`crossbeam_epoch`](https://docs.rs/crossbeam-epoch/), however the API set is vastly //! different, for i...
code_fim
hard
{ "lang": "rust", "repo": "declanvk/scalable-concurrent-containers", "path": "/src/ebr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>`ebr::AtomicArc` can be converted into `ebr::Arc`. //! let arc: Arc<usize> = atomic_arc.try_into_arc(Relaxed).unwrap(); //! assert_eq!(*arc, 18); //! //! // `18` will be garbage-collected later. //! drop(arc); //! //! // `17` is still valid as `barrier` keeps the garbage collector from dropping it. //! as...
code_fim
hard
{ "lang": "rust", "repo": "declanvk/scalable-concurrent-containers", "path": "/src/ebr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let reinject = self.accumulator; let w1 = self.lfo1.get_next(); let w2 = self.lfo2.get_next(); self.accumulator += self.feedback1; self.all_pass_wobble(672, 0.5, w1); self.all_pass(1800, 0.5); self.delay(4453); ...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/examples/ironfish/synth_ironfish/src/delay_toys.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn linear_interpolate(&mut self, index: usize, offset: f32) -> f32 { let adjustedindex = (index + MAX_DELAYTOY_DELAY - (offset.floor() as usize)) & DELAYTOY_BUFFERMASK; let frac = offset.fract(); let ifrac = 1.0 - frac; return self.buffer[adjustedindex] * ifrac ...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/examples/ironfish/synth_ironfish/src/delay_toys.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/makepad path: /examples/ironfish/synth_ironfish/src/delay_toys.rs const MAX_DELAYTOY_BITS: usize = 16; const MAX_DELAYTOY_DELAY: usize = 1 << MAX_DELAYTOY_BITS; const DELAYTOY_BUFFERMASK: usize = MAX_DELAYTOY_DELAY - 1; #[derive(Clone)] pub struct ResonatorLFO { cospart: f32, ...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/examples/ironfish/synth_ironfish/src/delay_toys.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greglearns/okra path: /src/okta/models/saml_application_settings_sign_on.rs r#recipient_override: Option<String>, #[serde(rename = "requestCompressed", skip_serializing_if = "Option::is_none")] r#request_compressed: Option<bool>, #[serde(rename = "responseSigned", skip_serializing_i...
code_fim
hard
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/saml_application_settings_sign_on.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn r#idp_issuer(&self) -> Option<&str> { self.r#idp_issuer.as_ref().map(|x| x.borrow()) } pub fn reset_idp_issuer(&mut self) { self.r#idp_issuer = None; } pub fn set_recipient(&mut self, r#recipient: String) { self.r#recipient = Some(r#recipient); } ...
code_fim
hard
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/saml_application_settings_sign_on.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greglearns/okra path: /src/okta/models/saml_application_settings_sign_on.rs g_if = "Option::is_none")] r#destination_override: Option<String>, #[serde(rename = "digestAlgorithm", skip_serializing_if = "Option::is_none")] r#digest_algorithm: Option<String>, #[serde(rename = "honor...
code_fim
hard
{ "lang": "rust", "repo": "greglearns/okra", "path": "/src/okta/models/saml_application_settings_sign_on.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl ToString for Unit { fn to_string(&self) -> String { match self { Unit::Auto => "auto".into(), Unit::Ch(n) => format!("{:.1}ch", n), Unit::Cm(n) => format!("{:.1}cm", n), Unit::Dpcm(n) => format!("{:.1}dpcm", n), Unit::Dpi(n) => f...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/elvis", "path": "/core/src/value/unit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v: f64 = t[..u] .trim() .parse() .unwrap_or_else(|_| t[u..].trim().parse().unwrap_or(1.0)); Ok(match t[u..].trim().to_ascii_lowercase().as_str() { "auto" | "inherit" => Unit::Auto, "ch" => Unit::Ch(v), "cm" => Uni...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/elvis", "path": "/core/src/value/unit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songlinshu/elvis path: /core/src/value/unit.rs //! unit system use crate::Error; use std::{cmp::Ordering, str::FromStr}; /// Follows [CSS Values 3][1] drafted in [csswg.org][2]. /// /// ## Absolute Lengths /// | unit | name | equivalence | /// |------|-------------------...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/elvis", "path": "/core/src/value/unit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(result) } fn delete_recursive(&self, path: &str) -> ZkResult<()> { trace!("delete_recursive {}", path); let children = self.get_children_recursive(path)?; for child in children.iter().rev() { self.delete(child, None)?; } Ok(()) }...
code_fim
hard
{ "lang": "rust", "repo": "bonifaido/rust-zookeeper", "path": "/src/zookeeper_ext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bonifaido/rust-zookeeper path: /src/zookeeper_ext.rs use acl::*; use consts::{CreateMode, ZkError}; use zookeeper::{ZkResult, ZooKeeper}; use std::iter::once; use std::collections::VecDeque; /// Extended ZooKeeper operations that are not needed for the "core." pub trait ZooKeeperExt { /// E...
code_fim
hard
{ "lang": "rust", "repo": "bonifaido/rust-zookeeper", "path": "/src/zookeeper_ext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> InternalError { cause: Some(TransactionAborted(format!("{:?}", e))) } } } impl<T: fmt::Debug> From<::sled::TransactionError<T>> for InternalError { fn from(e: ::sled::TransactionError<T>) -> Self { InternalError { cause: Some(TransactionAborted(format!("{:?}", e))) } } } pub ...
code_fim
hard
{ "lang": "rust", "repo": "cotyar/fulcrum", "path": "/src/fulcrum/error_handling.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: fmt::Debug> From<::sled::TransactionError<T>> for InternalError { fn from(e: ::sled::TransactionError<T>) -> Self { InternalError { cause: Some(TransactionAborted(format!("{:?}", e))) } } } pub fn unwrap_field<T>(msg: Option<T>, field_name: &str) -> Result<T, InternalError> { ...
code_fim
hard
{ "lang": "rust", "repo": "cotyar/fulcrum", "path": "/src/fulcrum/error_handling.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cotyar/fulcrum path: /src/fulcrum/error_handling.rs use std::*; use crate::pb::*; use internal_error::{Cause::*}; // fn format_internal_error(e: InternalError) -> String { // match e.cause { // None => String::from("Undefined error"), // Some(MissingRequiredArgument(s)) => ...
code_fim
hard
{ "lang": "rust", "repo": "cotyar/fulcrum", "path": "/src/fulcrum/error_handling.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tings = config::Config::default(); settings.merge(config::File::with_name("Settings")).unwrap(); settings.try_into().unwrap() } }<|fim_prefix|>// repo: Hexilee/BronzeDB path: /bronzedb-memory-db-server/src/conf.rs #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub db...
code_fim
medium
{ "lang": "rust", "repo": "Hexilee/BronzeDB", "path": "/bronzedb-memory-db-server/src/conf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hexilee/BronzeDB path: /bronzedb-memory-db-server/src/conf.rs #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub db_ad<|fim_suffix|>tings = config::Config::default(); settings.merge(config::File::with_name("Settings")).unwrap(); settings.try_into().unwrap() ...
code_fim
medium
{ "lang": "rust", "repo": "Hexilee/BronzeDB", "path": "/bronzedb-memory-db-server/src/conf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// P49WP pub mod P49WP { /// Offset (17 bits) pub const offset: u32 = 17; /// Mask (1 bit: 1 << 17) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub mod R {} /// Write-only values (empty) pub mod W {} /// R...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l5/peripherals/syscfg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32l5/peripherals/syscfg.rs {} } /// P26WP pub mod P26WP { /// Offset (26 bits) pub const offset: u32 = 26; /// Mask (1 bit: 1 << 26) pub const mask: u32 = 1 << offset; /// Read-only values (empty) pub m...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l5/peripherals/syscfg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32l5/peripherals/syscfg.rs (empty) pub mod RW {} } /// Fast-mode Plus (Fm+) driving capability activation on PB9 pub mod I2C_PB9_FMP { /// Offset (19 bits) pub const offset: u32 = 19; /// Mask (1 bit: 1 << 19) ...
code_fim
hard
{ "lang": "rust", "repo": "adamgreig/stm32ral", "path": "/src/stm32l5/peripherals/syscfg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline(always)] fn iter_blocks<'a, 'r, R, const N: usize>(&'a self, recorder: &'r R) -> Self::BlockIterator<'a, 'r, N, R> where R: InputRecorder<&'a [u8]>, { BorrowedBytesBlockIterator::new(&self.mmap, &self.last_block, recorder) } #[inline] fn seek_backward(...
code_fim
hard
{ "lang": "rust", "repo": "V0ldek/rsonpath", "path": "/crates/rsonpath-lib/src/input/mmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: V0ldek/rsonpath path: /crates/rsonpath-lib/src/input/mmap.rs //! Uses [`Mmap`](memmap2) to map a file into memory with kernel support. //! //! Choose this implementation if: //! //! 1. Your platform supports memory maps. //! 2. The input data is in a file or comes from standard input: //! a) i...
code_fim
hard
{ "lang": "rust", "repo": "V0ldek/rsonpath", "path": "/crates/rsonpath-lib/src/input/mmap.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Handle the volume state acquired from the switchboard, and determine whether /// the sounds should be played. async fn handle_volume_request( audio: Option<SettingResponse>, last_media_user_volume: Arc<Mutex<Option<f32>>>, volume_button_event: Arc<Mutex<i8>>, common_earcons_params: Com...
code_fim
hard
{ "lang": "rust", "repo": "Autumin/fuchsia", "path": "/garnet/bin/setui/src/agent/volume_change_earcons_handler.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Autumin/fuchsia path: /garnet/bin/setui/src/agent/volume_change_earcons_handler.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 crate::agent::earcons_agent::{connect_to_sou...
code_fim
hard
{ "lang": "rust", "repo": "Autumin/fuchsia", "path": "/garnet/bin/setui/src/agent/volume_change_earcons_handler.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>THLV or more than FTHLV free locations in the TxFIFO TXP flag is changed by hardware. It monitors overall space currently available at TxFIFO no matter if SPI is enabled or not. It has to be checked once a complete data packet is stored at TxFIFO."] #[inline(always)] pub fn txp(&self) -> TXP_R { ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/spi1/sr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h5/src/stm32h503/spi1/sr.rs #[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Field `RXP` reader - Rx-Packet available In I2S mode, it must be interpreted as follow: RxFIFO level is lower than FTHLV In I2S mode, it must be interprete...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h5/src/stm32h503/spi1/sr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bvaisvil/sysinfo path: /src/freebsd/cpu.rs // Take a look at the license at the top of the repository in the LICENSE file. use crate::CpuExt; #[doc = include_str!("../../md_doc/cpu.md")] pub struct Cpu { pub(crate) cpu_usage: f32, name: String, pub(crate) vendor_id: String, pub...
code_fim
medium
{ "lang": "rust", "repo": "bvaisvil/sysinfo", "path": "/src/freebsd/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn frequency(&self) -> u64 { self.frequency } fn vendor_id(&self) -> &str { &self.vendor_id } fn brand(&self) -> &str { "" } }<|fim_prefix|>// repo: bvaisvil/sysinfo path: /src/freebsd/cpu.rs // Take a look at the license at the top of the repository in t...
code_fim
hard
{ "lang": "rust", "repo": "bvaisvil/sysinfo", "path": "/src/freebsd/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn delete_user(&self, id: i32) -> Result<(), Error> { let changes = self.conn.execute(query::DELETE_USER, &[id])?; info!("{} users were deleted", changes); Ok(()) } pub fn get_tweets_by_user_id(&self, user_id: i32, limit: i32) -> Result<Vec<models::Tweet>, Error> ...
code_fim
hard
{ "lang": "rust", "repo": "sunny4381/twitnot", "path": "/src/db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunny4381/twitnot path: /src/db.rs use std::convert::TryFrom; use chrono::Utc; use log::info; use rusqlite::{self, NO_PARAMS, Connection, params}; use crate::error::Error; pub mod models; mod query; pub struct Db { conn: Connection, } impl Db { pub fn open(database_file: &str) -> Res...
code_fim
hard
{ "lang": "rust", "repo": "sunny4381/twitnot", "path": "/src/db.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devnought/gitplz path: /command/src/checkout.rs use crate::{Command, CommandBoxClone, WorkOption, WorkResult}; use color_printer::{Color, ColorPrinter, ColorSpec}; use command_derive::CommandBoxClone; use gitlib::GitRepo; use std::{io::Write, path::PathBuf}; <|fim_suffix|> printer.color_...
code_fim
hard
{ "lang": "rust", "repo": "devnought/gitplz", "path": "/command/src/checkout.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl WorkResult for CheckoutCommandResult { fn print(&self, printer: &mut ColorPrinter<'_>) { let mut cs = ColorSpec::new(); cs.set_intense(true); cs.set_fg(Some(Color::Yellow)); printer.color_context(&cs, |h| write!(h, " {}", self.branch).expect("write fail")); ...
code_fim
hard
{ "lang": "rust", "repo": "devnought/gitplz", "path": "/command/src/checkout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut w1 = WordShape::new(7); let mut w2 = WordShape::new(5); w1.slice = (0, w1.len()); w2.slice = (w1.slice.1 - 2, w1.slice.1 - 2 + w2.len()); w1.dist(&w2); } #[test] fn word_join_basic() { let mut w1 = WordShape::new(7); let mut w2 =...
code_fim
hard
{ "lang": "rust", "repo": "DougAnderson444/deno-autosuggest", "path": "/rust/core/src/tokenization/word_shape.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DougAnderson444/deno-autosuggest path: /rust/core/src/tokenization/word_shape.rs use crate::lang::{Lang, CharClass, CharPattern, PartOfSpeech}; use super::word::Word; use super::word_view::WordView; use super::word_split::WordSplit; use super::text::Text; #[derive(PartialEq, Debug, Clone)] pub...
code_fim
hard
{ "lang": "rust", "repo": "DougAnderson444/deno-autosuggest", "path": "/rust/core/src/tokenization/word_shape.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { &**(self.ppvt as *mut *mut _) } } /// [`IFileSaveDialog::SetSaveAsItem`](https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifilesavedialog-setsaveasitem) /// method. pub fn SetSaveAsItem(&self, psi: IShellItem) -> WinResult<()> { hr_to_wi...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/winsafe", "path": "/src/com/shell/ifilesavedialog.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songlinshu/winsafe path: /src/com/shell/ifilesavedialog.rs #![allow(non_snake_case)] use crate::com::shell::vt::{IFileDialogVT, IModalWindowVT}; use crate::com::traits::{ComInterface, PPI}; use crate::ffi::{BOOL, HANDLE, HRESULT}; use crate::structs::IID; /// [`IFileSaveDialog`](crate::...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/winsafe", "path": "/src/com/shell/ifilesavedialog.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itok01/giteki path: /src/num/client.rs use crate::endpoint; use crate::num::model::{RequestParameters, Response}; <|fim_suffix|> let resp: Response = get(&req_params).await.unwrap(); assert!(resp.giteki_information.last_update_date.is_ascii()); assert!(resp.giteki_information.total_...
code_fim
hard
{ "lang": "rust", "repo": "itok01/giteki", "path": "/src/num/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(resp.giteki_information.last_update_date.is_ascii()); assert!(resp.giteki_information.total_count > 0); assert!(resp.giteki.count > 0); }<|fim_prefix|>// repo: itok01/giteki path: /src/num/client.rs use crate::endpoint; use crate::num::model::{RequestParameters, Response}; pub async ...
code_fim
hard
{ "lang": "rust", "repo": "itok01/giteki", "path": "/src/num/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for n in 0..150 { // Get `reverse`'s answer let k = f(n); // Let's not have assertions mutate the cache being tested let mut ref_cache = SimpleCache::new(); // Get the corresponding Fibonacci number let closest = ref_cache.fi...
code_fim
hard
{ "lang": "rust", "repo": "ISSOtm/fibrs", "path": "/fibrs_lib/src/simple_cache.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ISSOtm/fibrs path: /fibrs_lib/src/simple_cache.rs use crate::Cache; use std::fmt::Debug; #[derive(Debug)] pub struct SimpleCache(Vec<u64>); impl Cache<usize, u64> for SimpleCache { fn new() -> Self { let mut cache = Vec::new(); cache.push(0); // fib(0) cache.push(1)...
code_fim
hard
{ "lang": "rust", "repo": "ISSOtm/fibrs", "path": "/fibrs_lib/src/simple_cache.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kszucs/arrow-datafusion path: /datafusion/src/physical_plan/expressions/nth_value.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright owner...
code_fim
hard
{ "lang": "rust", "repo": "kszucs/arrow-datafusion", "path": "/datafusion/src/physical_plan/expressions/nth_value.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>> { vec![self.expr.clone()] } fn name(&self) -> &str { &self.name } fn create_accumulator(&self) -> Result<Box<dyn WindowAccumulator>> { Ok(Box::new(NthValueAccumulator::try_new( self.n, ...
code_fim
hard
{ "lang": "rust", "repo": "kszucs/arrow-datafusion", "path": "/datafusion/src/physical_plan/expressions/nth_value.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tirust/msp432e4 path: /src/adc0/ssmux1.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::SSMUX1 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub f...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/adc0/ssmux1.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> } #[doc = "Bits 8:11 - 3rd Sample Input Select"] #[inline(always)] pub fn adc_ssmux1_mux2(&self) -> ADC_SSMUX1_MUX2R { let bits = ((self.bits >> 8) & 15) as u8; ADC_SSMUX1_MUX2R { bits } } #[doc = "Bits 12:15 - 4th Sample Input Select"] #[inline(always)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "tirust/msp432e4", "path": "/src/adc0/ssmux1.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/ast/node/conditional/tests.rs #[test] fn fmt() { super::super::test_formatting( r#" let a = true ? 5 : 6; <|fim_suffix|> a = 20; } "#, ); }<|fim_middle|> if (false) { a = 10; ...
code_fim
easy
{ "lang": "rust", "repo": "CalliEve/boa", "path": "/boa_engine/src/syntax/ast/node/conditional/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> a = 20; } "#, ); }<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/ast/node/conditional/tests.rs #[test] fn fmt() { super::super::test_formattin<|fim_middle|>g( r#" let a = true ? 5 : 6; if (false) { a = 10; ...
code_fim
medium
{ "lang": "rust", "repo": "CalliEve/boa", "path": "/boa_engine/src/syntax/ast/node/conditional/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Job { requested_intent: ThreadIntent, f: Box<dyn FnOnce() + Send + 'static>, } impl Pool { pub fn new(threads: usize) -> Pool { const STACK_SIZE: usize = 8 * 1024 * 1024; const INITIAL_INTENT: ThreadIntent = ThreadIntent::Worker; let (job_sender, job_receiver) ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-analyzer", "path": "/crates/stdx/src/thread/pool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-analyzer path: /crates/stdx/src/thread/pool.rs //! [`Pool`] implements a basic custom thread pool //! inspired by the [`threadpool` crate](http://docs.rs/threadpool). //! When you spawn a task you specify a thread intent //! so the pool can schedule it to run on a thread with that...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-analyzer", "path": "/crates/stdx/src/thread/pool.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn spawn<F>(&self, intent: ThreadIntent, f: F) where F: FnOnce() + Send + 'static, { let f = Box::new(move || { if cfg!(debug_assertions) { intent.assert_is_used_on_current_thread(); } f() }); let job = Jo...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-analyzer", "path": "/crates/stdx/src/thread/pool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bufrsh/bufrd path: /src/main.rs use std::fs::File; use std::io::{BufRead,BufReader}; use std::process::exit; use std::thread; use std::time::Duration; use std::env; mod msg; mod point; mod cron; mod cert; mod conf; fn load_cron(id: &[u8], crons: &mut Vec<cron::Cron>) -> Option<()> { let f = F...
code_fim
hard
{ "lang": "rust", "repo": "bufrsh/bufrd", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { //make sure we wait exactly until next minute mark let waitsec = 60 - point::Point::get_secs(); thread::sleep(Duration::from_secs(waitsec)); msg::poll_triggers(&id,&mut crons); let p = point::Point::now(); println!("{}",p); for c in crons.iter_mut() { c.check_and_run(&id,&p); } ...
code_fim
hard
{ "lang": "rust", "repo": "bufrsh/bufrd", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut id = [0;16]; if msg::login(&mut id) == None { std::process::exit(-1); } let mut crons: Vec<cron::Cron> = Vec::new(); match load_cron(&id,&mut crons) { Some(()) => println!("{}","cron load OK"), None => { println!("{}","cron load FAIL"); exit(-2); } } loop { //make sure we ...
code_fim
hard
{ "lang": "rust", "repo": "bufrsh/bufrd", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Token a is stable coin worth $1 contract.bind_pool( pool_id, &token_a(), U128(to_token_denom(20)), U128(to_token_denom(200)) ); // Token b is a token worth $0.5 contract.bind_pool( pool_id, &token_b(), U128(to_token_denom(10))...
code_fim
hard
{ "lang": "rust", "repo": "jasperdg/near-balancer", "path": "/src/tests/swap_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasperdg/near-balancer path: /src/tests/swap_tests.rs use super::*; fn create_even_pool() -> (PoolFactory, U64) { let context = get_context(alice(), 0); testing_env!(context); let mut contract = PoolFactory::init(alice()); let pool_id = contract.new_pool(swap_fee()); /...
code_fim
hard
{ "lang": "rust", "repo": "jasperdg/near-balancer", "path": "/src/tests/swap_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (tokens_out, spot_price_after) = contract.swap_exact_amount_in( pool_id, &token_a(), U128(tokens_in), &token_b(), U128(0), U128(to_token_denom(1000)) ); /*** verify post swap pricing ***/ let expected_a_to_b_spot_price = 80525500000000...
code_fim
hard
{ "lang": "rust", "repo": "jasperdg/near-balancer", "path": "/src/tests/swap_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let home = IpAddr { kind: IpAddrKind::V4, addr: String::from("127.0.0.1"), }; let loopback = IpAddr { kind: IpAddrKind::V6, addr: String::from("::1"), }; println!("{:?} {:?}", home, loopback); let q = Message::Quit; let m = Message::Move { x: ...
code_fim
medium
{ "lang": "rust", "repo": "BearGrass/rust_demo", "path": "/enum_demo/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BearGrass/rust_demo path: /enum_demo/src/main.rs #[derive(Debug)] enum IpAddrKind { V4, V6, } #[derive(Debug)] struct IpAddr { kind: IpAddrKind, addr: String, } enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32), } impl Messag...
code_fim
hard
{ "lang": "rust", "repo": "BearGrass/rust_demo", "path": "/enum_demo/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shadw3002/risp path: /src/processor.rs use super::{Token, LexerError, Located, ProcessorError, Datum, ToLocated, DatumPair, Primitive, Complex, Real}; use peekmore::{PeekMore, PeekMoreIterator}; type Result<T> = std::result::Result<T, Located<ProcessorError>>; type TResult = Located<std::resu...
code_fim
hard
{ "lang": "rust", "repo": "shadw3002/risp", "path": "/src/processor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }