text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: HomoCodens/adventofcode_2017_rust path: /src/day4.rs
use std::collections::HashMap;
use std::iter::Iterator;
use std::iter::FromIterator;
fn is_valid_passphrase(passphrase: &str) -> bool {
let mut words_seen = HashMap::new();
for word in passphrase.split_ascii_whitespace() {
if ... | code_fim | hard | {
"lang": "rust",
"repo": "HomoCodens/adventofcode_2017_rust",
"path": "/src/day4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: georust/geo path: /geo/src/algorithm/geodesic_length.rs
use crate::GeodesicDistance;
use crate::{Line, LineString, MultiLineString};
/// Determine the length of a geometry on an ellipsoidal model of the earth.
///
/// This uses the geodesic measurement methods given by [Karney (2013)]. As oppos... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo/src/algorithm/geodesic_length.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (start, end) = self.points();
start.geodesic_distance(&end)
}
}
impl GeodesicLength<f64> for LineString {
fn geodesic_length(&self) -> f64 {
let mut length = 0.0;
for line in self.lines() {
length += line.geodesic_length();
}
length
... | code_fim | medium | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo/src/algorithm/geodesic_length.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut length = 0.0;
for line in self.lines() {
length += line.geodesic_length();
}
length
}
}
impl GeodesicLength<f64> for MultiLineString {
fn geodesic_length(&self) -> f64 {
let mut length = 0.0;
for line_string in &self.0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "georust/geo",
"path": "/geo/src/algorithm/geodesic_length.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustype/drone path: /src/macro_drone.rs
use std::marker::PhantomData;
use typestate::typestate;
typestate!(
strict pub Drone <DroneState : StateSet> (state_mod::StateLimit) [Idle, Hovering, Flying] {
x: f32,
y: f32
}
);
impl Drone<Idle> {
pub fn new() -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "rustype/drone",
"path": "/src/macro_drone.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let drone = Drone::<Idle>::new();
// drone.move_to(10.0, 10.0); // comptime error: "move_to" is not a member of type Idle
assert_eq!(drone.x, 0.0);
assert_eq!(drone.y, 0.0);
}
}
// struct NotDroneState;
// impl Drone<NotDroneState> {} // NotDroneState does not satisfy... | code_fim | hard | {
"lang": "rust",
"repo": "rustype/drone",
"path": "/src/macro_drone.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ammkrn/nanoda_lib path: /src/tc/eq.rs
use crate::level::Level;
use crate::expr::{ Expr, ExprsPtr, ExprPtr, Expr::* };
use crate::tc::infer::InferFlag::*;
use crate::utils::{ Ptr, Tc, List::* };
use ShortCircuit::*;
use DeltaResult::*;
#[derive(Debug, Clone, Copy, PartialEq,... | code_fim | hard | {
"lang": "rust",
"repo": "ammkrn/nanoda_lib",
"path": "/src/tc/eq.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let (Lambda {..}, Lambda {..}) = (self.read(tc), other.read(tc)) {
self.def_eq_lambda_aux(other, tc)
} else {
None
}
}
fn def_eq_lambda_aux(mut self, mut other : Self, tc : &mut Tc<'t, 'l, 'e>) -> Option<ShortCircuit> {
let mut local... | code_fim | hard | {
"lang": "rust",
"repo": "ammkrn/nanoda_lib",
"path": "/src/tc/eq.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn rec_check(self, other : Self, tc : &mut Tc<'t, 'l, 'e>) -> DeltaResult<'l> {
if let Some(ss) = self.def_eq_sort(other, tc) {
Short(ss)
} else if let Some(ss) = self.def_eq_pi(other, tc) {
Short(ss)
} else if let Some(ss) = self.def_eq_lambda(other, tc... | code_fim | hard | {
"lang": "rust",
"repo": "ammkrn/nanoda_lib",
"path": "/src/tc/eq.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleAnswer {
/// generic status response
Status {
/// success or failure
status: ResponseStatus,
/// execution description
#[serde(skip_serializing_if = "Option::is_n... | code_fim | hard | {
"lang": "rust",
"repo": "dingchaoz/secret-amm-limit-orders",
"path": "/contracts/secret-order-book/src/msg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dingchaoz/secret-amm-limit-orders path: /contracts/secret-order-book/src/msg.rs
use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr, Uint128};
use schemars::JsonSchema;
use secret_toolkit::utils::{HandleCallback, Query};
use serde::{Deserialize, Serialize};
use crate::{contract::BLOCK_SIZE};
#... | code_fim | hard | {
"lang": "rust",
"repo": "dingchaoz/secret-amm-limit-orders",
"path": "/contracts/secret-order-book/src/msg.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct AmmPairSimulationResponse {
pub return_amount: Uint128,
pub spread_amount: Uint128,
pub commission_amount: Uint128
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct AmmPairRever... | code_fim | hard | {
"lang": "rust",
"repo": "dingchaoz/secret-amm-limit-orders",
"path": "/contracts/secret-order-book/src/msg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// @has dependent/struct.Ty.html
// @has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()'
// @has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()'
// @count - '//*[@class="impl-items"]/section' 2
// @has dependent/trait.Tr.html
// @has - '//*[@id="associatedtyp... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs
// Regression test for issue #95717
// Hide cross-crate `#[doc(hidden)]` associated items in trait impls.
#![crate_name = "dependent"]
// edition:2021
// aux-crate:dependency=cross-crate-hidden-assoc-trait-items.rs
// ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// @has dependent/trait.Tr.html
// @has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()'
// @has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()'
// @count - '//*[@class="impl-items"]/section' 2
pub use dependency::{Tr, Ty};<|fim_prefix|>// repo: rust-lang/... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn build_into_ret(&self, into_ret: &mut [u8]) {
into_ret[0..2].copy_from_slice(&self.interval_min.to_le_bytes());
into_ret[2..4].copy_from_slice(&self.interval_max.to_le_bytes());
into_ret[4..6].copy_from_slice(&self.latency.to_le_bytes());
into_ret[6..8].copy_from_s... | code_fim | hard | {
"lang": "rust",
"repo": "gpace1/bo-tie",
"path": "/host/bo-tie-gatt/src/characteristic/gap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gpace1/bo-tie path: /host/bo-tie-gatt/src/characteristic/gap.rs
//! Types for the GAP service
use bo_tie_att::{TransferFormatError, TransferFormatInto, TransferFormatTryFrom};
#[derive(PartialEq)]
pub struct PreferredConnectionParameters {
pub interval_min: u16,
pub interval_max: u16,
... | code_fim | hard | {
"lang": "rust",
"repo": "gpace1/bo-tie",
"path": "/host/bo-tie-gatt/src/characteristic/gap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TransferFormatInto for PreferredConnectionParameters {
fn len_of_into(&self) -> usize {
8
}
fn build_into_ret(&self, into_ret: &mut [u8]) {
into_ret[0..2].copy_from_slice(&self.interval_min.to_le_bytes());
into_ret[2..4].copy_from_slice(&self.interval_max.to_le_b... | code_fim | hard | {
"lang": "rust",
"repo": "gpace1/bo-tie",
"path": "/host/bo-tie-gatt/src/characteristic/gap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn decrypt(c:&Vec<u8>, key:&Vec<u8>) -> Result<String, ::Error> {
let clen = c.len();
unsafe {
if clen < ::crypto::encryption_abytes {
return Err(::Error::new(::crypto::RC::DecryptionError))
}
let mlen = clen - ::crypto::encryption_abytes;
let mut m... | code_fim | medium | {
"lang": "rust",
"repo": "stormentt/rpass-cryptlib",
"path": "/src/simple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stormentt/rpass-cryptlib path: /src/simple.rs
use ::helpers;
pub fn keygen() -> Vec<u8> {
unsafe {
let mut buf = helpers::raw_bytes(::crypto::encryption_key_len);
::crypto::encryption_keygen(buf.as_mut_ptr());
buf
}
}
pub fn encrypt(m:&str, key:&Vec<u8>) -> Res... | code_fim | medium | {
"lang": "rust",
"repo": "stormentt/rpass-cryptlib",
"path": "/src/simple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aethertap/audio path: /ste/examples/simple_async.rs
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let thread = ste::Builder::new().with_tokio().build()?;
<|fim_suffix|> assert_eq!(result, 1u32);
thread.join();
Ok(())
}<|fim_middle|> let mut... | code_fim | medium | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/ste/examples/simple_async.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(result, 1u32);
thread.join();
Ok(())
}<|fim_prefix|>// repo: aethertap/audio path: /ste/examples/simple_async.rs
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let thread = ste::Builder::new().with_tokio().build()?;
<|fim_middle|> let mut... | code_fim | medium | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/ste/examples/simple_async.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/lexruntimev2/src/client.rs
er.locale_id(inp);
self
}
pub fn set_locale_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_locale_id(input);
self
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/lexruntimev2/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C, M, R>>,
inner: crate::input::recognize_text_input::Builder,
}
impl<C, M, R> RecognizeText<C, M, R>
where
C: smithy_client::bounds::SmithyConnector,
M: smithy_client::bounds::SmithyMiddleware<C>,... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/lexruntimev2/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/lexruntimev2/src/client.rs
C = smithy_client::erase::DynConnector,
M = aws_hyper::AwsMiddleware,
R = smithy_client::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C, M, R>>,
inner: crate::input::get_session_input::Bu... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/lexruntimev2/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ders(
UserService as Arc<dyn User + Sync + Send>,
UserStore as Arc<UserStore>,
)]
#[exports(
Arc<dyn User + Sync + Send>,
)]
pub struct UserModule {}<|fim_prefix|>// repo: zfrzhangfurui/rnest path: /rnest/examples/complex/user/mod.rs
mod service;
mod store;
use crate::api::User;
use rnest::M... | code_fim | medium | {
"lang": "rust",
"repo": "zfrzhangfurui/rnest",
"path": "/rnest/examples/complex/user/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zfrzhangfurui/rnest path: /rnest/examples/complex/user/mod.rs
mod service;
mod store;
use crate::api::User;
use rnest::Module;
use service::U<|fim_suffix|>ders(
UserService as Arc<dyn User + Sync + Send>,
UserStore as Arc<UserStore>,
)]
#[exports(
Arc<dyn User + Sync + Send>,
)]
pub... | code_fim | medium | {
"lang": "rust",
"repo": "zfrzhangfurui/rnest",
"path": "/rnest/examples/complex/user/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tore>,
)]
#[exports(
Arc<dyn User + Sync + Send>,
)]
pub struct UserModule {}<|fim_prefix|>// repo: zfrzhangfurui/rnest path: /rnest/examples/complex/user/mod.rs
mod service;
mod store;
use crate::api::User;
use rnest::Module;
use service::UserService;
use std::sync::Arc;
use store::UserStore;
#[de... | code_fim | medium | {
"lang": "rust",
"repo": "zfrzhangfurui/rnest",
"path": "/rnest/examples/complex/user/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/scuba_sample/derive_tests/inline.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* Licen... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/scuba_sample/derive_tests/inline.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(StructuredSample)]
struct Basic {
field: i32,
}
let _sample: ScubaSample = Basic { field: 5 }.into();
}<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/scuba_sample/derive_tests/inline.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Thi... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/scuba_sample/derive_tests/inline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for CompilationUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.statement)?;
write!(f, "{}", self.end_of_file_token)?;
Ok(())
}
}<|fim_prefix|>// repo: Phytolizer/minsk-rs path: /minsk-language/src/code_analysis/... | code_fim | hard | {
"lang": "rust",
"repo": "Phytolizer/minsk-rs",
"path": "/minsk-language/src/code_analysis/syntax/compilation_unit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn end_of_file_token(&self) -> &SyntaxToken {
&self.end_of_file_token
}
pub fn span(&self) -> TextSpan {
TextSpan {
start: self.statement.span().start,
end: self.end_of_file_token.span.end,
}
}
}
impl Display for CompilationUnit {
f... | code_fim | hard | {
"lang": "rust",
"repo": "Phytolizer/minsk-rs",
"path": "/minsk-language/src/code_analysis/syntax/compilation_unit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phytolizer/minsk-rs path: /minsk-language/src/code_analysis/syntax/compilation_unit.rs
use std::fmt::Display;
use crate::code_analysis::text::text_span::TextSpan;
use super::{statement_syntax::StatementSyntax, syntax_token::SyntaxToken};
#[derive(Debug, Clone, PartialEq)]
pub struct Compilati... | code_fim | hard | {
"lang": "rust",
"repo": "Phytolizer/minsk-rs",
"path": "/minsk-language/src/code_analysis/syntax/compilation_unit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hecrj/ggez path: /src/input/gamepad.rs
//! Gamepad utility functions.
//!
//! This is going to be a bit of a work-in-progress as gamepad input
//! gets fleshed out. The `gilrs` crate needs help to add better
//! cross-platform support. Why not give it a hand?
use std::fmt;
pub use gilrs::{sel... | code_fim | hard | {
"lang": "rust",
"repo": "hecrj/ggez",
"path": "/src/input/gamepad.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// returns the `Gamepad` associated with an id.
fn gamepad(&self, id: GamepadId) -> Gamepad;
}
/// A structure that contains gamepad state using `gilrs`.
pub struct GilrsGamepadContext {
pub(crate) gilrs: Gilrs,
}
impl fmt::Debug for GilrsGamepadContext {
fn fmt(&self, f: &mut fmt::For... | code_fim | hard | {
"lang": "rust",
"repo": "hecrj/ggez",
"path": "/src/input/gamepad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> size_at_last_update = state.size;
}
events_loop.poll_events(|event| {
if let glutin::Event::WindowEvent { event, .. } = event {
match event {
glutin::WindowEvent::CloseRequested
... | code_fim | hard | {
"lang": "rust",
"repo": "eira-fransham/pollock",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eira-fransham/pollock path: /src/lib.rs
ssing,
/// which allows you to call functions that draw to the screen at any time, Pollock only allows
/// you to draw in the draw function itself. You can draw to the screen with `p.circle`, `p.rect`
/// and so forth. For a full list of functions see the ... | code_fim | hard | {
"lang": "rust",
"repo": "eira-fransham/pollock",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut run_context = true;
let mut rendered = false;
while run_application && run_context {
// We do this at the start so that the window size is refreshed
if size_at_last_update != state.size {
let size = LogicalSiz... | code_fim | hard | {
"lang": "rust",
"repo": "eira-fransham/pollock",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asajeffrey/xml5ever path: /src/tree_builder/rules.rs
use std::borrow::Cow::Borrowed;
use tendril::StrTendril;
use tokenizer::{Tag, StartTag, EndTag, ShortTag, EmptyTag};
use tree_builder::types::*;
use tree_builder::interface::TreeSink;
use tree_builder::actions::XmlTreeBuilderActions;
fn any_n... | code_fim | hard | {
"lang": "rust",
"repo": "asajeffrey/xml5ever",
"path": "/src/tree_builder/rules.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.debug_step(mode, &token);
match mode {
StartPhase => match token {
TagToken(Tag{kind: StartTag, name, attrs}) => {
let tag = Tag {
kind: StartTag,
name: name,
attrs... | code_fim | hard | {
"lang": "rust",
"repo": "asajeffrey/xml5ever",
"path": "/src/tree_builder/rules.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcmendes/coding-challenges path: /exercism/rust/proverb/src/lib.rs
/*
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the... | code_fim | hard | {
"lang": "rust",
"repo": "rcmendes/coding-challenges",
"path": "/exercism/rust/proverb/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> proverb.push_str(format!("And all for the want of a {}.", list[0]).as_str());
proverb
}<|fim_prefix|>// repo: rcmendes/coding-challenges path: /exercism/rust/proverb/src/lib.rs
/*
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.... | code_fim | hard | {
"lang": "rust",
"repo": "rcmendes/coding-challenges",
"path": "/exercism/rust/proverb/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> graph: &'a G,
v: usize,
now_ord: &mut usize,
group_num: &mut usize,
visited: &mut Vec<usize>,
low: &mut Vec<usize>,
ord: &mut Vec<Option<usize>>,
ids: &mut Vec<usize>,
) where
E: 'a + DirectedEdge,
G: Graph<'a, E>,
{
*now_ord += 1;
low[v] = *now... | code_fim | medium | {
"lang": "rust",
"repo": "cupro29/cuprolib_rs",
"path": "/src/graph/strongly_connected_components.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cupro29/cuprolib_rs path: /src/graph/strongly_connected_components.rs
use super::{DirectedEdge, Graph};
pub fn scc<'a, G, E>(graph: &'a G) -> Vec<Vec<usize>>
where
E: 'a + DirectedEdge,
G: Graph<'a, E>,
{
let size = graph.size();
let mut now_ord = 0;
let mut group_n... | code_fim | medium | {
"lang": "rust",
"repo": "cupro29/cuprolib_rs",
"path": "/src/graph/strongly_connected_components.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microrack/coresynth path: /fw/rust_lib/src/hal/stm32_hal/bindings.rs
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allo<|fim_suffix|>"/stm32_hal_bindings.rs"));
// TODO separate HAL from statics
include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs"));<|fim_middle|>w(non_upper_case_... | code_fim | medium | {
"lang": "rust",
"repo": "microrack/coresynth",
"path": "/fw/rust_lib/src/hal/stm32_hal/bindings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs"));<|fim_prefix|>// repo: microrack/coresynth path: /fw/rust_lib/src/hal/stm32_hal/bindings.rs
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allo<|fim_middle|>w(non_upper_case_globals)]
include!(concat!(env!("OUT_DIR"), "/stm32_hal_bindi... | code_fim | medium | {
"lang": "rust",
"repo": "microrack/coresynth",
"path": "/fw/rust_lib/src/hal/stm32_hal/bindings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"/stm32_hal_bindings.rs"));
// TODO separate HAL from statics
include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs"));<|fim_prefix|>// repo: microrack/coresynth path: /fw/rust_lib/src/hal/stm32_hal/bindings.rs
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allo<|fim_middle|>w(non_upper_case_... | code_fim | medium | {
"lang": "rust",
"repo": "microrack/coresynth",
"path": "/fw/rust_lib/src/hal/stm32_hal/bindings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dysquard/arb-os path: /src/evm/benchmarks.rs
/*
* Copyright 2020, Offchain Labs, Inc. All rights reserved.
*/
use crate::evm::abi::AbiForContract;
use crate::run::{load_from_file, RuntimeEnvironment};
use crate::uint256::Uint256;
use ethers_signers::Signer;
use std::path::Path;
pub fn make_ben... | code_fim | hard | {
"lang": "rust",
"repo": "dysquard/arb-os",
"path": "/src/evm/benchmarks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let wallet = machine.runtime_env.new_wallet();
let _my_addr = Uint256::from_bytes(wallet.address().as_bytes());
let my_addr = Uint256::from_u64(1025);
let contract = match AbiForContract::new_from_file("contracts/add/build/contracts/Add.json") {
Ok(mut contract) => {
l... | code_fim | hard | {
"lang": "rust",
"repo": "dysquard/arb-os",
"path": "/src/evm/benchmarks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> enum TestActorMsg {
Hi,
}
#[async_trait]
impl ActorMessageHandler for TestActor {
type Message = TestActorMsg;
type Context = ();
type Result = ();
async fn apply(&mut self, msg: Self::Message) -> Self::Result {
()
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "Hoyt-Systems-Texas/HoytSys.Rust_Common",
"path": "/a19_concurrent/src/actor/collection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hoyt-Systems-Texas/HoytSys.Rust_Common path: /a19_concurrent/src/actor/collection.rs
use crate::event::*;
use super::{ Actor, ActorMessageHandler };
use std::sync::Arc;
use std::{hash::Hash, collections::HashMap};
use async_trait::async_trait;
use futures::channel::oneshot;
use std::cell::RefCel... | code_fim | hard | {
"lang": "rust",
"repo": "Hoyt-Systems-Texas/HoytSys.Rust_Common",
"path": "/a19_concurrent/src/actor/collection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn load(actor_id: K) -> Option<V::Context>;
}
impl<K: Eq + Hash + Clone + Send + Sync + 'static, V: ActorMessageHandler + PersistedActor<K, V> + 'static> ActorCollection<K, V>
where <V as ActorMessageHandler>::Context: std::marker::Send
{
pub fn new() -> Self {
let (reader, wri... | code_fim | hard | {
"lang": "rust",
"repo": "Hoyt-Systems-Texas/HoytSys.Rust_Common",
"path": "/a19_concurrent/src/actor/collection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn clear(&mut self) {
self.clear_java_package();
self.clear_java_outer_classname();
self.clear_java_multiple_files();
self.clear_java_generate_equals_and_hash();
self.clear_optimize_for();
self.clear_go_package();
self.clear_cc_generic_services()... | code_fim | hard | {
"lang": "rust",
"repo": "victorvde/rust-protobuf",
"path": "/src/lib/descriptor.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: victorvde/rust-protobuf path: /src/lib/descriptor.rs
not initialized, it is initialized with default value first.
pub fn mut_experimental_map_key(&'a mut self) -> &'a mut ~str {
if self.experimental_map_key.is_none() {
self.experimental_map_key = Some(~"");
};
... | code_fim | hard | {
"lang": "rust",
"repo": "victorvde/rust-protobuf",
"path": "/src/lib/descriptor.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
fn merge_from(&mut self, is: &mut CodedInputStream) {
while !is.eof() {
let (field_number, wire_type) = is.read_tag_unpack();
match field_number {
1 => {
assert_eq!(wire_format::WireTypeLengthDelimited, wire_type);... | code_fim | hard | {
"lang": "rust",
"repo": "victorvde/rust-protobuf",
"path": "/src/lib/descriptor.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut mapped = buffer.map(factory.device(), 0..data.len() as u64).unwrap();
let mut writer = unsafe {
mapped
.write(factory.device(), 0..data.len() as u64)
.unwrap()
};
let dst_slice = unsafe { writer... | code_fim | hard | {
"lang": "rust",
"repo": "MirecIT/amethyst",
"path": "/amethyst_rendy/src/submodules/skinning.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MirecIT/amethyst path: /amethyst_rendy/src/submodules/skinning.rs
//! 3D Skinned per-image buffer handling.
use amethyst_core::ecs::*;
use fnv::FnvHashMap;
use rendy::resource::SubRange;
#[cfg(feature = "profiler")]
use thread_profiler::profile_scope;
use crate::{
rendy::{
command::... | code_fim | hard | {
"lang": "rust",
"repo": "MirecIT/amethyst",
"path": "/amethyst_rendy/src/submodules/skinning.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if data.is_empty() {
return;
}
let allocated = util::ensure_buffer(
&factory,
&mut self.buffer,
hal::buffer::Usage::STORAGE,
rendy::memory::Dynamic,
data.len() as u64,
)
.unwrap();
if ... | code_fim | hard | {
"lang": "rust",
"repo": "MirecIT/amethyst",
"path": "/amethyst_rendy/src/submodules/skinning.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Ord + ?Sized> Comparator<T> for OrdComparator {
fn compare(x: &T, y: &T) -> Ordering {
Ord::cmp(x, y)
}
}<|fim_prefix|>// repo: frxstrem/sorted-array path: /src/comparator.rs
use core::cmp::Ordering;
pub trait Comparator<T: ?Sized> {
fn compare(x: &T, y: &T) -> Ordering;
}
<... | code_fim | easy | {
"lang": "rust",
"repo": "frxstrem/sorted-array",
"path": "/src/comparator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frxstrem/sorted-array path: /src/comparator.rs
use core::cmp::Ordering;
pub trait Comparator<T: ?Sized> {
fn compare(x: &T, y: &T) -> Ordering;
}
<|fim_suffix|> Ord::cmp(x, y)
}
}<|fim_middle|>pub struct OrdComparator;
impl<T: Ord + ?Sized> Comparator<T> for OrdComparator {
... | code_fim | medium | {
"lang": "rust",
"repo": "frxstrem/sorted-array",
"path": "/src/comparator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e::message::{LidarDriverCommand, LidarDriverMessage};
}
pub use driver::*;<|fim_prefix|>// repo: Jesus805/neato-xv11-rs path: /neato_xv11/src/lib.rs
mod driver;
mod test;
pub mod data;
pub mod error;
pub mod message;
pub mod prelude {
pub use crate::data::{LidarReading, LidarPacket};
pub<|fim_m... | code_fim | medium | {
"lang": "rust",
"repo": "Jesus805/neato-xv11-rs",
"path": "/neato_xv11/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jesus805/neato-xv11-rs path: /neato_xv11/src/lib.rs
mod driver;
mod test;
pub mod data;
pub mod error;
pub mod message;
pub m<|fim_suffix|> use crate::error::{LidarDriverError, LidarReadingError};
pub use crate::message::{LidarDriverCommand, LidarDriverMessage};
}
pub use driver::*;<|fim_m... | code_fim | medium | {
"lang": "rust",
"repo": "Jesus805/neato-xv11-rs",
"path": "/neato_xv11/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CMaybe/RustStudy path: /4. Variable Bindings/freezing/src/main.rs
fn main() {
let mut _mutable_integer = 7i32;
<|fim_suffix|> // 여기에서의 _mutable_integer은 mut이 아닙니다.
// _mutable_integer = 50;
}
_mutable_integer = 3;
println!("_mutable_integer: {}", _mutable_integer);... | code_fim | easy | {
"lang": "rust",
"repo": "CMaybe/RustStudy",
"path": "/4. Variable Bindings/freezing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _mutable_integer = 3;
println!("_mutable_integer: {}", _mutable_integer);
}<|fim_prefix|>// repo: CMaybe/RustStudy path: /4. Variable Bindings/freezing/src/main.rs
fn main() {
let mut _mutable_integer = 7i32;
<|fim_middle|> {
let _mutable_integer = _mutable_integer;
// 여기에서의... | code_fim | medium | {
"lang": "rust",
"repo": "CMaybe/RustStudy",
"path": "/4. Variable Bindings/freezing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn sync_to_model(&mut self, editor_scene: Option<&EditorScene>, ui: &mut UserInterface) {
scope_profile!();
for &widget in [
self.file_menu.close_scene,
self.file_menu.save,
self.file_menu.save_as,
self.create_entity_menu.menu,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/menu/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /editor/src/menu/mod.rs
use crate::{
animation::AnimationEditor,
menu::{
create::CreateEntityRootMenu, edit::EditMenu, file::FileMenu, help::HelpMenu,
utils::UtilsMenu, view::ViewMenu,
},
message::MessageSender,
scene::EditorScene,
... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/editor/src/menu/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oknozor/valr path: /valr/src/lib.rs
extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
use std::marker::PhantomData;
use syn::parse::Parse;
use syn::parse::ParseStream;
use syn::parse::Result;
use syn::Lit;
use syn::Lit::*;
use syn::Meta;
use syn::NestedMeta;
use syn::{
... | code_fim | hard | {
"lang": "rust",
"repo": "oknozor/valr",
"path": "/valr/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_validators_ident(field: &Field) -> Vec<Validator> {
let mut meta_attributes = vec![];
for attr in field.attrs.iter() {
let meta_list = match attr.parse_meta().unwrap() {
Meta::List(meta_list) => meta_list,
_ => panic!("expected a Meta::List",),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "oknozor/valr",
"path": "/valr/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_metas_ident(meta: &Meta) -> Vec<Ident> {
meta.path()
.segments
.pairs()
.map(|pair| pair.into_value())
.map(|seg| seg.ident.clone())
.collect::<Vec<Ident>>()
}
#[proc_macro_derive(Validator)]
pub fn derive_validator(input: TokenStream) -> TokenStream {
... | code_fim | hard | {
"lang": "rust",
"repo": "oknozor/valr",
"path": "/valr/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acdandrew/crypto_challenges path: /src/crypt_util.rs
extern crate rand;
use rand::Rng;
/// A function that pkcs #7 pads a vector according to the provided block size
pub fn pkcs_7(to_modify : &mut Vec<u8>, block_size : u32) {
let modulus = to_modify.len() as u32 % block_size;
let bytes... | code_fim | hard | {
"lang": "rust",
"repo": "acdandrew/crypto_challenges",
"path": "/src/crypt_util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result
}
/// Parse a string of key values of form key1=val1&key2=val2...
///
/// #Arguments
///
/// 'input' - a string of key and value pairs
///
/// #Output
/// Vec<(String,String)> - a vec containing key value pairs
///
pub fn parse_key_value_pairs(input : &str) -> Vec<(String,String)>
{
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "acdandrew/crypto_challenges",
"path": "/src/crypt_util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /** Called by purple_core_get_ui_info(); should return the information
* documented there.
*/
pub get_ui_info: Option<fn() -> GHashTable>
}
#[link(name="purple")]
extern {
pub fn purple_core_init(_: *const c_char) -> ();
pub fn purple_core_quit() -> ();
pub fn purple_core_quit_cb(unused:gpointe... | code_fim | hard | {
"lang": "rust",
"repo": "catharsis/purple.rs",
"path": "/src/ffi/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: catharsis/purple.rs path: /src/ffi/core.rs
#![allow(dead_code)]
use libc::c_char;
use ffi::glibtypes::*;
pub struct PurpleCore;
pub struct PurpleCoreUiOps {
/** Called just after the preferences subsystem is initialized; the UI
* could use this callback to add some preferences it needs to b... | code_fim | hard | {
"lang": "rust",
"repo": "catharsis/purple.rs",
"path": "/src/ffi/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[link(name="purple")]
extern {
pub fn purple_core_init(_: *const c_char) -> ();
pub fn purple_core_quit() -> ();
pub fn purple_core_quit_cb(unused:gpointer) -> gboolean;
pub fn purple_core_get_ui() -> *const c_char;
pub fn purple_get_core() -> *mut PurpleCore;
pub fn purple_core_set_ui_ops(_: *mut ... | code_fim | hard | {
"lang": "rust",
"repo": "catharsis/purple.rs",
"path": "/src/ffi/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cryspen/hacl-packages path: /rust/tests/test_aead.rs
mod test_util;
use test_util::*;
use hacl::aead::{hacl_aes_available, Aead, Algorithm, Error};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[allow(non_snake_case)]
struct AeadTestVector {
algorithm: String,
generatorVersion: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "cryspen/hacl-packages",
"path": "/rust/tests/test_aead.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg = b"HACL rules";
let aad = b"associated data";
let key = b"This key should never be used!!!" as &[u8; 32];
let iv = b"used more...";
let mut io = *msg;
let tag = chacha20_poly1305::encrypt(key, &mut io, *iv, aad);
assert!(chacha20_poly1305::decrypt(key, &mut io, *iv, a... | code_fim | hard | {
"lang": "rust",
"repo": "cryspen/hacl-packages",
"path": "/rust/tests/test_aead.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robinoffzewood/aoc-2020 path: /day-05/src/main.rs
use std::time::Instant;
use std::fs;
use std::cmp::max;
fn main() {
let start = Instant::now();
test();
let contents = fs::read_to_string("input.txt").expect("Error in reading file");
let mut seat_id_max = 0;
let mut seat_id... | code_fim | hard | {
"lang": "rust",
"repo": "robinoffzewood/aoc-2020",
"path": "/day-05/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn to_int (b: &str) -> u32 {
let mut result = 0;
for c in b.chars() {
result *= 2;
if let Some(digit) = c.to_digit(2) {
result += digit;
}
}
result
}<|fim_prefix|>// repo: robinoffzewood/aoc-2020 path: /day-05/src/main.rs
use std::time::Instant;
use std... | code_fim | medium | {
"lang": "rust",
"repo": "robinoffzewood/aoc-2020",
"path": "/day-05/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> logging::init();
let mut ui = match curses::Ui::new() {
Ok(res) => res,
Err(err) => {
match err {
curses::Error::ColorCount => println!("rhex requires a terminal with 256 color support. Exiting."),
_ => println!("An error occurred while ... | code_fim | medium | {
"lang": "rust",
"repo": "dpc/rhex",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dpc/rhex path: /src/main.rs
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
extern crate simplemap;
extern crate ncurses;
extern crate hex2d;
extern crate hex2d_dpcext as hex2dext;
extern crate rand;
extern crate num;
extern crate chrono;
//#[macro... | code_fim | medium | {
"lang": "rust",
"repo": "dpc/rhex",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod ai;
mod curses;
mod game;
mod generate;
mod util;
mod logging;
fn main() {
logging::init();
let mut ui = match curses::Ui::new() {
Ok(res) => res,
Err(err) => {
match err {
curses::Error::ColorCount => println!("rhex requires a terminal with 256 co... | code_fim | hard | {
"lang": "rust",
"repo": "dpc/rhex",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SSSuperTIan/b2dp path: /b2dp/benches/benchmarks/laplace_benchmark.rs
use criterion::{criterion_group, Criterion, BenchmarkId};
use b2dp::{Eta, GeneratorOpenSSL,mechanisms::naive::naive_exponential_mechanism, mechanisms::laplace::clamped_laplace_mechanism};
use b2dp::mechanisms::exponential::Expo... | code_fim | hard | {
"lang": "rust",
"repo": "SSSuperTIan/b2dp",
"path": "/b2dp/benches/benchmarks/laplace_benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut group = c.benchmark_group("Laplace");
group.sample_size(10);
for i in [1.0,0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625].iter() {
group.bench_with_input(BenchmarkId::new("Not Optimized", i), i,
|b, i| b.iter(|| not_optimized(*i)));
gro... | code_fim | hard | {
"lang": "rust",
"repo": "SSSuperTIan/b2dp",
"path": "/b2dp/benches/benchmarks/laplace_benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl QueryRequest {
fn choose_query_request() -> Self {
println!();
let variants = QueryRequestDiscriminants::iter().collect::<Vec<_>>();
let requests = variants
.iter()
.map(|p| p.get_message().unwrap().to_owned())
.collect::<Vec<_>>();
... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/near-cli",
"path": "/src/commands/view_command/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evgenykuzyakov/near-cli path: /src/commands/view_command/mod.rs
use dialoguer::{theme::ColorfulTheme, Select};
use strum::{EnumDiscriminants, EnumIter, EnumMessage, IntoEnumIterator};
mod view_account;
mod view_contract_code;
mod view_contract_state;
mod view_nonce;
mod view_transaction_status;... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/near-cli",
"path": "/src/commands/view_command/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!();
let variants = QueryRequestDiscriminants::iter().collect::<Vec<_>>();
let requests = variants
.iter()
.map(|p| p.get_message().unwrap().to_owned())
.collect::<Vec<_>>();
let selected_request = Select::with_theme(&ColorfulTheme... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/near-cli",
"path": "/src/commands/view_command/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/system/system_comb_pvt_err_nvt_site0.rs
#[doc = "Reader of register SYSTEM_COMB_PVT_ERR_NVT_SITE0"]
pub type R = crate::R<u32, super::SYSTEM_COMB_PVT_ERR_NVT_SITE0>;
#[doc = "Reader of field `SYSTEM_COMB_TIMING_ERR_CNT_NVT_SITE0`"]
pub type SYSTEM_COMB_TIMI... | code_fim | medium | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/system/system_comb_pvt_err_nvt_site0.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>STEM_COMB_TIMING_ERR_CNT_NVT_SITE0_R {
SYSTEM_COMB_TIMING_ERR_CNT_NVT_SITE0_R::new((self.bits & 0xffff) as u16)
}
}<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/system/system_comb_pvt_err_nvt_site0.rs
#[doc = "Reader of register SYSTEM_COMB_PVT_ERR_NVT_SITE0"]
pub type R = cra... | code_fim | medium | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/system/system_comb_pvt_err_nvt_site0.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mangolang/compiler path: /src/common/error.rs
use ::std::fmt;
use crate::io::slice::SourceSlice;
pub type MangoResult<T> = Result<T, MangoErr>;
pub type MsgResult<T> = Result<T, ErrMsg>;
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Severity {
Error,
Warning,
Debug,
}
/// This ... | code_fim | hard | {
"lang": "rust",
"repo": "mangolang/compiler",
"path": "/src/common/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<&str> for ErrMsg {
fn from(text: &str) -> Self {
ErrMsg {
friendly: text.to_owned(),
debug: None,
}
}
}
impl fmt::Display for ErrMsg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", &self.friendly)
}
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "mangolang/compiler",
"path": "/src/common/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn next(&self, eval: Eval) -> MtdState {
if eval < self.guess {
MtdState {
lower: self.lower,
guess: eval,
upper: eval + 1,
}
} else {
MtdState {
lower: eval,
guess: eval... | code_fim | hard | {
"lang": "rust",
"repo": "WiebeCnossen/draughts",
"path": "/src/algorithm/mtdf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WiebeCnossen/draughts path: /src/algorithm/mtdf.rs
use super::alphabeta::{makes_cut, makes_cut_parallel};
use super::judge::{Eval, Judge, MAX_EVAL, MIN_EVAL};
use super::meta::Meta;
use super::scope::{Depth, Scope};
use crate::board::mv::Move;
use crate::board::position::Position;
struct MtdSta... | code_fim | hard | {
"lang": "rust",
"repo": "WiebeCnossen/draughts",
"path": "/src/algorithm/mtdf.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn mtd_f<TScope>(
judge: &mut dyn Judge,
position: &Position,
depth: Depth,
guess: Eval,
) -> MtdResult
where
TScope: Scope,
{
let scope = &TScope::from_depth(depth);
let mut state = MtdState::initial(guess);
let mut meta = Meta::create();
let mut mv = None;
loo... | code_fim | hard | {
"lang": "rust",
"repo": "WiebeCnossen/draughts",
"path": "/src/algorithm/mtdf.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teloxide/teloxide path: /crates/teloxide-core/src/types/parse_mode.rs
// see https://github.com/rust-lang/rust/issues/38832
// (for built ins there no warnings, but for (De)Serialize, there are)
#![allow(deprecated)]
use std::{
convert::{TryFrom, TryInto},
str::FromStr,
};
use serde::{... | code_fim | hard | {
"lang": "rust",
"repo": "teloxide/teloxide",
"path": "/crates/teloxide-core/src/types/parse_mode.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TryFrom<String> for ParseMode {
type Error = ();
fn try_from(value: String) -> Result<Self, Self::Error> {
value.as_str().try_into()
}
}
impl FromStr for ParseMode {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
s.try_into()
}
}
#[cfg(tes... | code_fim | hard | {
"lang": "rust",
"repo": "teloxide/teloxide",
"path": "/crates/teloxide-core/src/types/parse_mode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: meilisearch/transplant path: /meilisearch-http/src/index_controller/mod.rs
use std::collections::BTreeMap;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use actix_web::web::Bytes;
use chrono::{DateTime, Utc};
use futures::stream::StreamExt;
use log::error;
use log::info;
use... | code_fim | hard | {
"lang": "rust",
"repo": "meilisearch/transplant",
"path": "/meilisearch-http/src/index_controller/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn get_index(&self, uid: String) -> Result<IndexMetadata> {
let uuid = self.uuid_resolver.get(uid.clone()).await?;
let meta = self.index_handle.get_index_meta(uuid).await?;
let meta = IndexMetadata {
uuid,
name: uid.clone(),
uid,
... | code_fim | hard | {
"lang": "rust",
"repo": "meilisearch/transplant",
"path": "/meilisearch-http/src/index_controller/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vincenthouyi/LakeOS path: /lib/naive/src/objects/mod.rs
use core::marker::PhantomData;
use rustyl4api::syscall::{syscall, MsgInfo, SyscallOp};
mod cap_slot;
mod capref;
pub mod cnode;
pub mod endpoint;
pub mod identify;
pub mod interrupt;
pub mod monitor;
pub mod ram;
pub mod reply;
pub mod tc... | code_fim | hard | {
"lang": "rust",
"repo": "vincenthouyi/LakeOS",
"path": "/lib/naive/src/objects/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.slot.slot()
}
pub fn into_slot(self) -> CapSlot {
/* Get inner slot without runinng destructor */
let slot = self.slot();
core::mem::forget(self);
CapSlot::new(slot)
}
fn delete(&self) {
let info = MsgInfo::new(SyscallOp::CNodeDelete, ... | code_fim | medium | {
"lang": "rust",
"repo": "vincenthouyi/LakeOS",
"path": "/lib/naive/src/objects/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn example4() {
assert_eq!(
'a',
Solution::find_the_difference("ae".to_string(), "aea".to_string()),
);
}
}<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/find-the-difference/src/lib.rs
// https://leetcode.com/c0x10/... | code_fim | medium | {
"lang": "rust",
"repo": "csixteen/LeetCode",
"path": "/Problems/Algorithms/src/Rust/find-the-difference/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.