text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // fn define_trait()
}
pub static OK_RESULT_LABEL: Lazy<InternedString> = Lazy::new(|| "Ok".into());
pub static SOME_OPTION_LABEL: Lazy<InternedString> = Lazy::new(|| "Some".into());
pub static ERR_RESULT_LABEL: Lazy<InternedString> = Lazy::new(|| "Err".into());
pub static NONE_OPTION_LABEL: Lazy<Int... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/steel",
"path": "/crates/steel-core/src/values/structs.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattwparas/steel path: /crates/steel-core/src/values/structs.rs
eHeapVec::Unit => None,
ImmutableMaybeHeapVec::One(v) => Some(v.clone()),
ImmutableMaybeHeapVec::Two(a) => Some(a[index].clone()),
ImmutableMaybeHeapVec::Three(a) => Some(a[index].clone()),
... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/steel",
"path": "/crates/steel-core/src/values/structs.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pad!(
GPIO_SD_B1_08,
SW_MUX_CTL_PAD_GPIO_SD_B1_08,
SW_PAD_CTL_PAD_GPIO_SD_B1_08,
[alt0, alt1, alt2, alt3, alt4, alt5, alt6]
);
pad!(
GPIO_SD_B1_09,
SW_MUX_CTL_PAD_GPIO_SD_B1_09,
SW_PAD_CTL_PAD_GPIO_SD_B1_09,
[alt0, alt1, alt2, alt3, alt4, alt5]
);<|fim_prefix|>// repo: mit... | code_fim | medium | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-hal/src/iomuxc/gpio/sd_b1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-hal/src/iomuxc/gpio/sd_b1.rs
pad!(
GPIO_SD_B1_06,
SW_MUX_CTL_PAD_GPIO_SD_B1_06,
SW_PAD_CTL_PAD_GPIO_SD_B1_06,
[alt0, alt1, alt2, alt3, alt4, alt5, alt8]
);
<|fim_suffix|>pad!(
GPIO_SD_B1_09,
SW_MUX_CTL_PAD_GPIO_SD_B1_09,
SW_PAD_CTL... | code_fim | hard | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-hal/src/iomuxc/gpio/sd_b1.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pad!(
GPIO_SD_B1_09,
SW_MUX_CTL_PAD_GPIO_SD_B1_09,
SW_PAD_CTL_PAD_GPIO_SD_B1_09,
[alt0, alt1, alt2, alt3, alt4, alt5]
);<|fim_prefix|>// repo: mitchmindtree/imxrt-rs path: /imxrt-hal/src/iomuxc/gpio/sd_b1.rs
pad!(
GPIO_SD_B1_06,
SW_MUX_CTL_PAD_GPIO_SD_B1_06,
SW_PAD_CTL_PAD_GPI... | code_fim | medium | {
"lang": "rust",
"repo": "mitchmindtree/imxrt-rs",
"path": "/imxrt-hal/src/iomuxc/gpio/sd_b1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { CStr::from_ptr(s.as_ptr()).to_string_lossy().to_string() }
}
}<|fim_prefix|>// repo: djg/adept2-rs path: /adept2/src/util.rs
use std::ffi::CStr;
use std::os::raw::c_char;
pub unsafe trait StringExt {
fn from_slice(s: &[c_char]) -> String;
}
<|fim_middle|>unsafe impl StringExt f... | code_fim | medium | {
"lang": "rust",
"repo": "djg/adept2-rs",
"path": "/adept2/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djg/adept2-rs path: /adept2/src/util.rs
use std::ffi::CStr;
use std::os::raw::c_char;
<|fim_suffix|>unsafe impl StringExt for String {
fn from_slice(s: &[c_char]) -> String {
unsafe { CStr::from_ptr(s.as_ptr()).to_string_lossy().to_string() }
}
}<|fim_middle|>pub unsafe trait St... | code_fim | medium | {
"lang": "rust",
"repo": "djg/adept2-rs",
"path": "/adept2/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl StringExt for String {
fn from_slice(s: &[c_char]) -> String {
unsafe { CStr::from_ptr(s.as_ptr()).to_string_lossy().to_string() }
}
}<|fim_prefix|>// repo: djg/adept2-rs path: /adept2/src/util.rs
use std::ffi::CStr;
use std::os::raw::c_char;
<|fim_middle|>pub unsafe trait St... | code_fim | medium | {
"lang": "rust",
"repo": "djg/adept2-rs",
"path": "/adept2/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = users.select(max(arbitrary::<types::SmallSerial>()));
let _ = users.select(max(arbitrary::<types::Serial>()));
let _ = users.select(max(arbitrary::<types::BigSerial>()));
let _ = users.select(max(arbitrary::<types::SmallInt>()));
let _ = users.select(max(arbitrary::<types::Inte... | code_fim | hard | {
"lang": "rust",
"repo": "mfpiccolo/yaqb",
"path": "/tests/expressions/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfpiccolo/yaqb path: /tests/expressions/mod.rs
mod date_and_time;
mod ops;
use schema::{connection, NewUser, setup_users_table};
use schema::users::dsl::*;
use yaqb::*;
use yaqb::query_builder::*;
use yaqb::expression::dsl::*;
#[test]
fn test_count_counts_the_rows() {
let connection = conn... | code_fim | hard | {
"lang": "rust",
"repo": "mfpiccolo/yaqb",
"path": "/tests/expressions/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn max_accepts_all_numeric_string_and_date_types() {
let _ = users.select(max(arbitrary::<types::SmallSerial>()));
let _ = users.select(max(arbitrary::<types::Serial>()));
let _ = users.select(max(arbitrary::<types::BigSerial>()));
let _ = users.select(max(arbitrary::<types::SmallI... | code_fim | hard | {
"lang": "rust",
"repo": "mfpiccolo/yaqb",
"path": "/tests/expressions/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KOBA789/zuse-core path: /src/net.rs
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Netlist {
pub relays: Vec<Relay>,
pub switches: Vec<Switch>,
}
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct Switch {
pub state: String,
... | code_fim | medium | {
"lang": "rust",
"repo": "KOBA789/zuse-core",
"path": "/src/net.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)]
pub struct Switch {
pub state: String,
pub l: String,
pub r: String,
}
pub const V_P: &str = "N0";<|fim_prefix|>// repo: KOBA789/zuse-core path: /src/net.rs
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Netl... | code_fim | medium | {
"lang": "rust",
"repo": "KOBA789/zuse-core",
"path": "/src/net.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterjoel/async-zmq path: /src/reactor/tokio_zmq/mod.rs
//! Socket type registered in tokio reactor
use crate::{
reactor::{evented, AsRawSocket},
socket::MessageBuf,
};
use mio::Ready;
use std::task::{Context, Poll};
use tokio::io::PollEvented;
use zmq::Error;
/// Poll Evented Socket
... | code_fim | hard | {
"lang": "rust",
"repo": "peterjoel/async-zmq",
"path": "/src/reactor/tokio_zmq/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.as_socket().poll(event, 100) {
Ok(_) => {}
Err(e) => return Poll::Ready(Err(e)),
};
if self.as_socket().get_events()?.contains(event) {
Poll::Ready(Ok(()))
} else {
Poll::Pending
}
}
pub(crate) fn ... | code_fim | hard | {
"lang": "rust",
"repo": "peterjoel/async-zmq",
"path": "/src/reactor/tokio_zmq/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<json::Value> for Value {
fn from(value: json::Value) -> Value {
match value {
json::Value::Null => Value::Null,
json::Value::Bool(bool) => Value::Bool(bool),
json::Value::Number(number) => {
if number.is_u64() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ahdinosaur/nest",
"path": "/nest/src/source/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut string = json::to_string_pretty(value)?;
string.push('\n');
Ok(string)
}
}
impl From<json::Value> for Value {
fn from(value: json::Value) -> Value {
match value {
json::Value::Null => Value::Null,
json::Value::Bool(bool) => Value::Bo... | code_fim | hard | {
"lang": "rust",
"repo": "ahdinosaur/nest",
"path": "/nest/src/source/json.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ahdinosaur/nest path: /nest/src/source/json.rs
use std::convert::TryFrom;
use std::iter::FromIterator;
use std::num::FpCategory;
use indexmap::IndexMap;
use serde_json as json;
use snafu::{ensure, Snafu};
use super::FileSource;
use crate::Value;
#[derive(Clone, Debug)]
pub struct Json {}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "ahdinosaur/nest",
"path": "/nest/src/source/json.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match t.item_type {
ItemType::Message => ValueType::Message(MessageRef(InternalRef(t.final_idx))),
ItemType::Enum => ValueType::Enum(EnumRef(InternalRef(t.final_idx))),
_ => unreachable!("Service as field type"),
}... | code_fim | hard | {
"lang": "rust",
"repo": "lvuk-hopsoft/protofish",
"path": "/src/context/builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvuk-hopsoft/protofish path: /src/context/builder.rs
TypeBuilder::Message(m) => TypeInfo::Message(m.build(self_data, cache)?),
ProtobufTypeBuilder::Enum(e) => TypeInfo::Enum(e.build(self_data, cache)?),
})
}
}
impl MessageBuilder
{
/// Lists types found in this messa... | code_fim | hard | {
"lang": "rust",
"repo": "lvuk-hopsoft/protofish",
"path": "/src/context/builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvuk-hopsoft/protofish path: /src/context/builder.rs
the cache
ProtobufItemBuilder::Service(..) => {
panic!("Trying to take a service as a type");
}
}
}
fn take_service(&mut self, idx: &[usize]) -> ServiceBuilder
{
match &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "lvuk-hopsoft/protofish",
"path": "/src/context/builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k82cn/Quark path: /qvisor/src/kvmlib/runc/cmd/create.rs
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of t... | code_fim | hard | {
"lang": "rust",
"repo": "k82cn/Quark",
"path": "/qvisor/src/kvmlib/runc/cmd/create.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Container::Create(
&self.id,
RunAction::Create,
spec,
gCfg,
&self.bundleDir,
&self.consoleSocket,
&self.pid,
"",
true,
self.pivot
)?;
//eprintln!("Application er... | code_fim | hard | {
"lang": "rust",
"repo": "k82cn/Quark",
"path": "/qvisor/src/kvmlib/runc/cmd/create.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn SubCommand<'a, 'b>(common: &CommonArgs<'a, 'b>) -> App<'a, 'b> {
return SubCommand::with_name("create")
.setting(AppSettings::ColoredHelp)
.arg(&common.id_arg)
.arg(&common.bundle_arg)
.arg(&common.consoleSocket_arg)
.arg(&comm... | code_fim | hard | {
"lang": "rust",
"repo": "k82cn/Quark",
"path": "/qvisor/src/kvmlib/runc/cmd/create.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matthias-Fauconneau/iced path: /glow/src/widget.rs
//! Use the widgets supported out-of-the-box.
//!
//! # Re-exports
//! For convenience, the contents of this module are available at the root
//! module. Therefore, you can directly type:
//!
//! ```
//! use iced_glow::{button, Button};
//! ```
... | code_fim | hard | {
"lang": "rust",
"repo": "Matthias-Fauconneau/iced",
"path": "/glow/src/widget.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use iced_native::{Image, Space};
/// A container that distributes its contents vertically.
pub type Column<'a, Message> = iced_native::Column<'a, Message, Renderer>;
/// A container that distributes its contents horizontally.
pub type Row<'a, Message> = iced_native::Row<'a, Message, Renderer>;
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "Matthias-Fauconneau/iced",
"path": "/glow/src/widget.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A container that distributes its contents horizontally.
pub type Row<'a, Message> = iced_native::Row<'a, Message, Renderer>;
/// A paragraph of text.
pub type Text = iced_native::Text<Renderer>;<|fim_prefix|>// repo: Matthias-Fauconneau/iced path: /glow/src/widget.rs
//! Use the widgets supported ou... | code_fim | medium | {
"lang": "rust",
"repo": "Matthias-Fauconneau/iced",
"path": "/glow/src/widget.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linkerd/linkerd2-proxy path: /linkerd/meshtls/src/server.rs
use linkerd_error::Result;
use linkerd_identity::LocalId;
use linkerd_io as io;
use linkerd_stack::{Param, Service};
use linkerd_tls::ServerTls;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
#[cfg(feature =... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/meshtls/src/server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "rustls")]
TerminateFutureProj::Rustls(f) => {
let res = futures::ready!(f.poll(cx));
Poll::Ready(res.map(|(tls, io)| (tls, ServerIo::Rustls(io))))
}
#[cfg(not(feature = "__has_any_tls_impls"))]
_ ... | code_fim | hard | {
"lang": "rust",
"repo": "linkerd/linkerd2-proxy",
"path": "/linkerd/meshtls/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> DebugPrinter<'a, T>
where
T: Iterator,
T::Item: std::fmt::Debug,
{
fn new(x: T, pretty: bool, msg: Option<Cow<'a, str>>) -> Self {
Self(x, pretty, msg)
}
}
impl<'a, T> Iterator for DebugPrinter<'a, T>
where
T: Iterator,
T::Item: std::fmt::Debug,
{
type Item... | code_fim | hard | {
"lang": "rust",
"repo": "museun/debug_iterator",
"path": "/src/lib.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create an adapter that prints out the [`std::fmt::Debug`](https://doc.rust-lang.org/std/fmt/trait.Debug.html) representation of the Item, with a Prefix
fn debug_prefix<'a, S>(self, prefix: S) -> DebugPrinter<'a, Self>
where
Self: Sized + 'a,
Self::Item: std::fmt::Debug,
... | code_fim | hard | {
"lang": "rust",
"repo": "museun/debug_iterator",
"path": "/src/lib.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: museun/debug_iterator path: /src/lib.rs
/*!
# debug_iterator
This is a simple iterator adapter thats is applicable to iterators where the Iterator::Item is std::fmt::Debug
It prints to `stderr` by default, but using the feature 'logging' prints out to the `log` crate facade.
```rust
use debug_... | code_fim | hard | {
"lang": "rust",
"repo": "museun/debug_iterator",
"path": "/src/lib.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wine-app/wine-server path: /src/routes/get_index.rs
use actix_web::{get, Error, HttpResponse};
#[get("/")]
pub async fn index() -> Result<HttpResponse, Error<|fim_suffix|>"application/json")
.body("hello there"),
)
}<|fim_middle|>> {
Ok(
HttpResponse::Ok()
.content_type( | code_fim | easy | {
"lang": "rust",
"repo": "wine-app/wine-server",
"path": "/src/routes/get_index.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"application/json")
.body("hello there"),
)
}<|fim_prefix|>// repo: wine-app/wine-server path: /src/routes/get_index.rs
use actix_web::{get, Error, HttpResponse};
#[get("/")]
pub async fn index() -> Result<HttpResponse, Error<|fim_middle|>> {
Ok(
HttpResponse::Ok()
.content_type( | code_fim | easy | {
"lang": "rust",
"repo": "wine-app/wine-server",
"path": "/src/routes/get_index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Digest of this node state
fn hash(&self) -> Hash;
}
impl TreeNode for Node {
fn keys(&self) -> Vec<Key> {
match self {
Node::Leaf(leaf) => leaf.keys.clone(),
Node::Branch(branch) => branch.keys.clone(),
}
}
fn size(&self) -> usize {
... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/ope-btree",
"path": "/server/src/ope_btree/internal/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns ''true'' if current branch is rightmost (the last) on this level of tree, ''false'' otherwise
pub fn is_rightmost(&self) -> bool {
self.children_refs.len() > self.size
}
pub fn to_proof<D: Digest>(&self, substitution_idx: Option<usize>) -> NodeProof {
NodeProof... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/ope-btree",
"path": "/server/src/ope_btree/internal/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RicoGit/ope-btree path: /server/src/ope_btree/internal/node.rs
es::<D>(&self.keys, &self.val_hashes);
self.hash = LeafNode::leaf_hash::<D>(self.kv_hashes.clone());
self
}
/// Insert new key into Leaf
pub fn insert<D: Digest>(
mut self,
key: Key,
... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/ope-btree",
"path": "/server/src/ope_btree/internal/node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Simple point struct
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct Point2D {
pub x: usize,
pub y: usize,
}
impl Point2D {
pub fn new(x: usize, y: usize) -> Point2D {
Point2D { x, y }
}
pub fn from(&self, action: Action) -> Point2D {
match action {
... | code_fim | hard | {
"lang": "rust",
"repo": "EarthenSky/rustsoko",
"path": "/src/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EarthenSky/rustsoko path: /src/types.rs
use bit_vec::BitVec;
use std::process;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Tile {
Wall,
Player,
PlayerGoal,
Crate,
CrateGoal,
Goal,
Floor,
}
impl Tile {
// for freeze deadlocks
pub fn is_freezable(&self... | code_fim | hard | {
"lang": "rust",
"repo": "EarthenSky/rustsoko",
"path": "/src/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // map string to Tile enum.
let mut line_number = 0;
let mut index = 0;
let mut tile_vec: Vec<Tile> = Vec::new();
for ch in puzzle_string.chars() {
match ch {
'#' => tile_vec.push(Tile::Wall),
'@' => tile_vec.push(Tile::Pl... | code_fim | hard | {
"lang": "rust",
"repo": "EarthenSky/rustsoko",
"path": "/src/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ntext\"`*"]
pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_SCALING_INERTIA: INTERACTION_CONFIGURATION_FLAGS = 128u32;
#[doc = "*Required features: `\"Win32_UI_InteractionContext\"`*"]
pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_RAILS_X: INTERACTION_CONFIGURATION_FLAGS = 256u32;
#[doc = "*... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/sys/src/Windows/Win32/UI/InteractionContext/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/winrt-rs path: /crates/libs/sys/src/Windows/Win32/UI/InteractionContext/mod.rs
doc = "*Required features: `\"Win32_UI_InteractionContext\"`*"]
pub fn StopInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows_sys::core::HRESULT;
}
#[doc = "*Required features: `\"W... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/sys/src/Windows/Win32/UI/InteractionContext/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/winrt-rs path: /crates/libs/sys/src/Windows/Win32/UI/InteractionContext/mod.rs
setInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows_sys::core::HRESULT;
#[doc = "*Required features: `\"Win32_UI_InteractionContext\"`*"]
pub fn SetCrossSlideParametersInterac... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/sys/src/Windows/Win32/UI/InteractionContext/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FlowFields {
pub fn new(width: usize, height: usize) -> Self {
Self {
flow_field: FlowField::new(width, height),
}
}
}
impl UnitIdGenerator {
pub fn generate(&mut self) -> u32 {
if let Some(last_id) = self.last_id {
self.last_id = Some(last... | code_fim | medium | {
"lang": "rust",
"repo": "bjrnmrtns/xp-game-engine",
"path": "/rts/src/client/resources.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bjrnmrtns/xp-game-engine path: /rts/src/client/resources.rs
use crate::client::navigation::FlowField;
use bevy::prelude::*;
#[derive(Default)]
pub struct PhysicsState {
pub steps_done: u64,
}
#[derive(Default)]
pub struct GameInfo {
pub camera: Option<Entity>,
pub camera_center: Op... | code_fim | hard | {
"lang": "rust",
"repo": "bjrnmrtns/xp-game-engine",
"path": "/rts/src/client/resources.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn render_all(con: &mut Offscreen, objects: &[Object], map: &Map) {
for object in objects {
object.draw(con);
}
for y in 0..MAP_HEIGHT {
for x in 0..MAP_WIDTH {
let wall = map[x as usize][y as usize].block_sight;
if wall {
con.set_ch... | code_fim | hard | {
"lang": "rust",
"repo": "zer0tonin/myRogueLike",
"path": "/src/Utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zer0tonin/myRogueLike path: /src/Utils.rs
extern crate tcod;
use self::tcod::console::*;
use self::tcod::input::Key;
use self::tcod::input::KeyCode::*;
use super::Object::Object;
use super::Map::Map;
use Config::MAP_HEIGHT;
use Config::MAP_WIDTH;
use Config::COLOR_DARK_GROUND;
use Config::COLOR... | code_fim | hard | {
"lang": "rust",
"repo": "zer0tonin/myRogueLike",
"path": "/src/Utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theodedeken/lambda-rs path: /src/check.rs
use ast::*;
use pest::Error;
use std::collections::HashMap;
use sym_tab::*;
impl<'a> ASTNode<'a> {
/// Performs typechecking on the abstract syntax tree and returns the resulting type or an error
/// specifying the problem encountered when type ... | code_fim | hard | {
"lang": "rust",
"repo": "theodedeken/lambda-rs",
"path": "/src/check.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> } => {
if let TypeAssignment::Record(types) = target.check_node(table)? {
if let Some(attrib_type) = types.get(attrib) {
Ok(attrib_type.clone())
} else {
Err(Error::CustomErrorSpan {
... | code_fim | hard | {
"lang": "rust",
"repo": "theodedeken/lambda-rs",
"path": "/src/check.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rrorSpan {
message: "Not all possible types in the variant are being handled"
.to_string(),
span: meta.clone(),
});
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "theodedeken/lambda-rs",
"path": "/src/check.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2.0, parser.evaluate(5.0));
}
#[test]
fn evaluate_concatenation() {
// x + 2 - 3 * 4 / 5
let mut parser = Parser {
stack: vec![Subtraction(Box::new(Addition(Box::new(Variable), Box::new(Digit(2.0)))), Box::new(Division(Box::new(Multiplication(Box... | code_fim | hard | {
"lang": "rust",
"repo": "ni851ste/cl_plotter",
"path": "/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ni851ste/cl_plotter path: /src/parser/mod.rs
use std::borrow::{Borrow, BorrowMut};
use tokenizer::*;
use tokenizer::Token::*;
pub mod tokenizer;
/// Used for parsing expressions to be evaluated
pub struct Parser {
pub stack: Vec<Token>,
}
impl Parser {
/// Instantiates parser with em... | code_fim | hard | {
"lang": "rust",
"repo": "ni851ste/cl_plotter",
"path": "/src/parser/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match TIFF::open("resources/large_tif/DEM_ZH.tif") {
Ok(x) => {
assert_eq!(x.image_data.len(), 366);
assert_eq!(x.image_data[0].len(), 399);
assert_eq!(x.get_value_at(0, 0), 551);
assert_eq!(x.get_value_at(45, 67), 530);
assert_eq!(x... | code_fim | hard | {
"lang": "rust",
"repo": "ajunlonglive/geotiff",
"path": "/tests/integration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajunlonglive/geotiff path: /tests/integration.rs
extern crate geotiff as tiff;
use tiff::TIFF;
//#[test]
fn test_load() {
match TIFF::open("resources/marbles.tif") {
Ok(x) => println!("Read tiff {}", x),
Err(e) => println!("File I/O Error: {:?}", e),
}
}
<|fim_suffix|>... | code_fim | medium | {
"lang": "rust",
"repo": "ajunlonglive/geotiff",
"path": "/tests/integration.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Patcher {
fn patch<'p, T: Copy + Datum + num_traits::Zero>(
&self,
geo: &'p ConcreteGeometry,
input: &TensorView,
pack: &'p mut TensorView,
g: usize,
pad_value: Option<&Tensor>,
) -> TractResult<()> {
match self {
Patcher::Va... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/core/src/ops/cnn/conv/im2col.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /core/src/ops/cnn/conv/im2col.rs
rive(Debug, Clone, Hash, PartialEq, Eq)]
struct ConcreteGeometry {
pool: ConcretePoolGeometry,
pub n: usize,
k: usize,
pub b_pack: Packer,
pub ci_per_group: usize,
patcher: Patcher,
input_shape_with_n: DataShape,
... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/core/src/ops/cnn/conv/im2col.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/tract path: /core/src/ops/cnn/conv/im2col.rs
;
use crate::ops::cnn::{GeometryBound, PoolSpec, ResolveTo};
use crate::ops::nn::{BaseDataShape, DataFormat, DataShape};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Im2Col {
pub pool_spec: PoolSpec,
pub group: usize,
geo... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/tract",
"path": "/core/src/ops/cnn/conv/im2col.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adriandelgado/pyweekend-rust path: /build.rs
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::path::Path;
fn main() {
let response = ureq::get("http://standards-oui.ieee.org/oui.txt")
.call()
... | code_fim | hard | {
"lang": "rust",
"repo": "adriandelgado/pyweekend-rust",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("map_oui.rs");
let handle = File::create(dest_path).unwrap();
let mut writer = BufWriter::new(handle);
writeln!(
&mut writer,
"const MAP_MACS: [([u8; 6], &str); {}] = [",
dat... | code_fim | hard | {
"lang": "rust",
"repo": "adriandelgado/pyweekend-rust",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yang-33/learn-rust path: /syntax_semantics/src/4-17.rs
// 4-17
// string
fn mode001() {
let greeting = "Hello there.";
println!("{}", greeting);
let s = "foo\
bar";
println!("{}", s);
let s = "foo
bar";
println!("{}", s);
let mut a = "Hello"... | code_fim | hard | {
"lang": "rust",
"repo": "Yang-33/learn-rust",
"path": "/syntax_semantics/src/4-17.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mode003() {
use std::net::TcpStream;
TcpStream::connect("192.168.0.1:3000");
let addr_string = "192.168.0.1:3000".to_string();
TcpStream::connect(&*addr_string);
}
// indexing
fn mode004() {
let s = "hello";
// indexingをサポートしてない
// println!("The first letter o... | code_fim | hard | {
"lang": "rust",
"repo": "Yang-33/learn-rust",
"path": "/syntax_semantics/src/4-17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mode002() {
fn takes_slice(slice: &str) {
println!("Got: {}", slice);
}
let s = "Hello".to_string();
takes_slice(&s);
}
fn mode003() {
use std::net::TcpStream;
TcpStream::connect("192.168.0.1:3000");
let addr_string = "192.168.0.1:3000".to_string();
... | code_fim | hard | {
"lang": "rust",
"repo": "Yang-33/learn-rust",
"path": "/syntax_semantics/src/4-17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: negrel/guessing_game path: /src/main.rs
use rand::{thread_rng, Rng};
use std::cmp::Ordering;
use std::io;
use std::mem::drop;
use std::process::exit;
fn main() {
// Use to read user input.
let mut reader = String::new();
// Game variable.
let mut guess: u32; // User input (is guess for myst... | code_fim | hard | {
"lang": "rust",
"repo": "negrel/guessing_game",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Return a random number from the given range.
fn get_random(min: u32, max: u32) -> u32 {
return thread_rng().gen_range(min, max);
}
// Parse the given string to u32.
fn parse_to_u32(str: &mut String) -> u32 {
// Parse the string to u32;
let parsed = match str.trim().parse::<u32>() {
Ok(num) => num... | code_fim | hard | {
"lang": "rust",
"repo": "negrel/guessing_game",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.handler.handle(req)
.map(|mut res| { self.add_cors_header(&mut res.headers); res })
.map_err(|mut err| { self.add_cors_header(&mut err.response.headers); err })
}
}
/// The handler that acts as an AroundMiddleware.
///
/// It first checks an incoming request for a... | code_fim | hard | {
"lang": "rust",
"repo": "Vrixyz/iron-cors-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vrixyz/iron-cors-rs path: /src/lib.rs
//! A CORS middleware for [Iron](http://ironframework.io/) with preflight support.
//!
//! See https://www.html5rocks.com/static/images/cors_server_flowchart.png for
//! reference.
//!
//! # Usage
//!
//! There are two modes available:
//!
//! ## Mode 1: Whi... | code_fim | hard | {
"lang": "rust",
"repo": "Vrixyz/iron-cors-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_cors_preflight_headers(&self,
headers: &mut headers::Headers,
origin: &headers::Origin,
acrm: &headers::AccessControlRequestMethod,
acrh: Option<&headers::Acce... | code_fim | hard | {
"lang": "rust",
"repo": "Vrixyz/iron-cors-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(items) = completion_items_from_path(completion_path, schema) {
send_completion_response(items, request_id, &self.connection);
}
}
}
LSPBridgeMessage::DidOpenTextDocument(params) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "naacho20/relay",
"path": "/compiler/crates/relay-lsp/src/lsp_compiler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: naacho20/relay path: /compiler/crates/relay-lsp/src/lsp_compiler.rs
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
//! An LSP-specific Compiler interface
... | code_fim | hard | {
"lang": "rust",
"repo": "naacho20/relay",
"path": "/compiler/crates/relay-lsp/src/lsp_compiler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const QUIT: Keycode = Keycode::Escape;
pub const UP: Keycode = Keycode::W;
pub const DOWN: Keycode = Keycode::S;
pub const LEFT: Keycode = Keycode::A;
pub const RIGHT: Keycode = Keycode::D;
}
pub mod entity {
pub mod player {
use ::color::Color;
use ::geo::{
Size,
... | code_fim | medium | {
"lang": "rust",
"repo": "Noah2610/snake-ggez.rs",
"path": "/src/settings.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/snake-ggez.rs path: /src/settings.rs
pub mod meta {
use ::geo::Size;
pub const WINDOW_SIZE: Size = Size { w: 600.0, h: 600.0 };
pub const TITLE: &str = "Snake";
pub const AUTHOR: &str = "Noah R";
pub const WINDOW_TITLE: &str = "Snake!";
}
<|fim_suffix|> pub co... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/snake-ggez.rs",
"path": "/src/settings.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const SIZE_SQ: f32 = super::super::game::CELL_SIZE_SQ;
pub const SIZE: Size = super::super::game::CELL_SIZE;
pub const ORIGIN: Origin = Origin::TopLeft;
pub const COLOR: Color = [0.25, 0.75, 0.5, 1.0];
pub const BODY_COLOR: Color = [0.1,... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/snake-ggez.rs",
"path": "/src/settings.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kettle11/kwasm path: /src/js_object.rs
use std::{borrow::Borrow, cell::Cell, ffi::c_void, ops::Deref, rc::Rc};
#[cfg(feature = "wasm_bindgen_support")]
use wasm_bindgen::prelude::*;
#[cfg_attr(
feature = "wasm_bindgen_support",
wasm_bindgen(module = "/js/kwasm.js")
)]
extern "C" {
... | code_fim | hard | {
"lang": "rust",
"repo": "kettle11/kwasm",
"path": "/src/js_object.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drop for JSObjectDynamicInner {
fn drop(&mut self) {
unsafe { kwasm_free_js_object(self.0.index()) }
}
}
pub struct JSString {
// string: &'a str,
js_object: JSObjectDynamic,
}
impl JSString {
pub fn new(string: &str) -> Self {
let js_object =
unsafe ... | code_fim | hard | {
"lang": "rust",
"repo": "kettle11/kwasm",
"path": "/src/js_object.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bench_brsettlement_cached(bench: &mut Bencher) {
let cal = bdays::calendars::brazil::BRSettlement;
let d0 = chrono::NaiveDate::from_ymd(2015, 06, 29);
let d1 = chrono::NaiveDate::from_ymd(2100, 12, 20);
let cached_cal = bdays::HolidayCalendarCache::new(
cal,
chrono::Nai... | code_fim | hard | {
"lang": "rust",
"repo": "felipenoris/bdays",
"path": "/benches/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bench.iter(|| {
cal.bdays(d0, d1);
})
}
fn bench_brsettlement(bench: &mut Bencher) {
let cal = bdays::calendars::brazil::BRSettlement;
let d0 = chrono::NaiveDate::from_ymd(2015, 06, 29);
let d1 = chrono::NaiveDate::from_ymd(2100, 12, 20);
bench.iter(|| {
cal.bdays... | code_fim | hard | {
"lang": "rust",
"repo": "felipenoris/bdays",
"path": "/benches/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felipenoris/bdays path: /benches/bench.rs
#[macro_use]
extern crate bencher;
extern crate bdays;
extern crate chrono;
use bdays::HolidayCalendar;
use bencher::Bencher;
fn bench_weekendsonly(bench: &mut Bencher) {
let cal = bdays::calendars::WeekendsOnly;
let d0 = chrono::NaiveDate::fro... | code_fim | hard | {
"lang": "rust",
"repo": "felipenoris/bdays",
"path": "/benches/bench.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SpecializedRenderPipeline for BlitPipeline {
type Key = BlitPipelineKey;
fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor {
RenderPipelineDescriptor {
label: Some("blit pipeline".into()),
layout: vec![self.texture_bind_group.clone()],
... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_core_pipeline/src/blit/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /crates/bevy_core_pipeline/src/blit/mod.rs
use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_reflect::TypeUuid;
use bevy_render::{render_resource::*, renderer::RenderDevice, RenderApp};
use crate::fullscre... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_core_pipeline/src/blit/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twitter/pelikan path: /src/config/src/server.rs
// Copyright 2020 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use serde::{Deserialize, Serialize};
use std::net::{AddrParseError, SocketAddr};
// constants to define default value... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/src/config/src/server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The poll timeout in milliseconds
pub fn timeout(&self) -> usize {
self.timeout
}
/// Maximum events to accept in one poll
pub fn nevent(&self) -> usize {
self.nevent
}
}
// trait implementations
impl Default for Server {
fn default() -> Self {
Self... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/src/config/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// trait implementations
impl Default for Server {
fn default() -> Self {
Self {
host: host(),
port: port(),
timeout: timeout(),
nevent: nevent(),
}
}
}
// trait definitions
pub trait ServerConfig {
fn server(&self) -> &Server;
}... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/src/config/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rogday/micro_platformer path: /livesplit-hotkey/src/windows/mod.rs
mod key_code;
pub use self::key_code::KeyCode;
use std::cell::RefCell;
use std::collections::hash_map::{Entry, HashMap};
use std::sync::mpsc::{channel, Sender};
use std::sync::Arc;
use std::{mem, ptr, thread};
use parking_lot::... | code_fim | hard | {
"lang": "rust",
"repo": "rogday/micro_platformer",
"path": "/livesplit-hotkey/src/windows/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(move || {
while let Ok(key) = events_rx.recv() {
if let Some(callback) = hotkey_map.lock().get_mut(&key) {
callback();
}
}
});
let thread_id = initialized_rx.recv().map_err(|_| Error::ThreadS... | code_fim | hard | {
"lang": "rust",
"repo": "rogday/micro_platformer",
"path": "/livesplit-hotkey/src/windows/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: softdevteam/yksom path: /src/lib/vm/objects/double.rs
#![allow(clippy::new_ret_no_self)]
use std::{collections::hash_map::DefaultHasher, hash::Hasher};
use num_bigint::BigInt;
use num_traits::{FromPrimitive, ToPrimitive, Zero};
use smartstring::alias::String as SmartString;
use std::gc::Gc;
u... | code_fim | hard | {
"lang": "rust",
"repo": "softdevteam/yksom",
"path": "/src/lib/vm/objects/double.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b = if let Ok(rhs) = other.as_isize(vm) {
self.val < (rhs as f64)
} else if let Some(rhs) = other.try_downcast::<Double>(vm) {
self.val < rhs.double()
} else if let Some(rhs) = other.try_downcast::<ArbInt>(vm) {
match rhs.bigint().to_f64() {
... | code_fim | hard | {
"lang": "rust",
"repo": "softdevteam/yksom",
"path": "/src/lib/vm/objects/double.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dandels/dmodman path: /src/ui/component/focused_widget.rs
use super::*;
use super::{Highlight, Select};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use tokio::sync::RwLock;
#[derive(Clone)]
pub enum FocusedWidget<'a> {
DownloadTable(Arc<RwLock<DownloadTable<'a>>>),
FileTable(... | code_fim | hard | {
"lang": "rust",
"repo": "dandels/dmodman",
"path": "/src/ui/component/focused_widget.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn focus(&mut self) {
match self {
FocusedWidget::DownloadTable(current) => {
current.write().await.focus().await;
}
FocusedWidget::FileTable(current) => {
current.write().await.focus().await;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dandels/dmodman",
"path": "/src/ui/component/focused_widget.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn test_u32_read() {
assert_eq!(
super::as_u32_be(&[0xDE as u8, 0xAD as u8, 0xBE as u8, 0xEF as u8]),
0xDEADBEEF
);
assert_eq!(
super::as_u32_le(&[0xEF as u8, 0xBE as u8, 0xAD as u8, 0xDE as u8]),
... | code_fim | hard | {
"lang": "rust",
"repo": "richinfante/ibackuptool2",
"path": "/src/lib/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richinfante/ibackuptool2 path: /src/lib/util.rs
pub fn pack_u64(val: u64) -> [u8; 8] {
return [
((val & 0xFF00000000000000) >> (4 * 14)) as u8,
((val & 0x00FF000000000000) >> (4 * 12)) as u8,
((val & 0x0000FF0000000000) >> (4 * 10)) as u8,
((val & 0x000000FF00... | code_fim | medium | {
"lang": "rust",
"repo": "richinfante/ibackuptool2",
"path": "/src/lib/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// From "sass-spec/spec/non_conformant/sass/semicolon/import.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/include.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/return.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/variable.hrx"
// From "sass-spec/spec/non_conform... | code_fim | hard | {
"lang": "rust",
"repo": "ejmg/rsass",
"path": "/tests/spec/non_conformant/sass/semicolon/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// From "sass-spec/spec/non_conformant/sass/semicolon/debug.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/declaration.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/error.hrx"
// From "sass-spec/spec/non_conformant/sass/semicolon/import.hrx"
// From "sass-spec/spec/non_conform... | code_fim | medium | {
"lang": "rust",
"repo": "ejmg/rsass",
"path": "/tests/spec/non_conformant/sass/semicolon/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ejmg/rsass path: /tests/spec/non_conformant/sass/semicolon/mod.rs
//! Tests auto-converted from "sass-spec/spec/non_conformant/sass/semicolon"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/non_conformant/sass/semicolon/at_rule.hrx"
// From "sass-spec/spec/non_conformant/sass/semic... | code_fim | medium | {
"lang": "rust",
"repo": "ejmg/rsass",
"path": "/tests/spec/non_conformant/sass/semicolon/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zdnscloud/r53 path: /src/rdata_naptr.rs
use crate::message_render::MessageRender;
use crate::name::Name;
use crate::rdatafield_string_parser::Parser;
use crate::util::{InputBuffer, OutputBuffer};
use failure::Result;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct NAPTR {
pub order: u16,
... | code_fim | hard | {
"lang": "rust",
"repo": "zdnscloud/r53",
"path": "/src/rdata_naptr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_str<'a>(iter: &mut Parser<'a>) -> Result<Self> {
let order = iter.next_field::<u16>("NAPTR", "order")?;
let preference = iter.next_field::<u16>("NAPTR", "preference")?;
let flags = iter.next_field::<u16>("NAPTR", "flags")?;
let services = iter.next_field::<u... | code_fim | hard | {
"lang": "rust",
"repo": "zdnscloud/r53",
"path": "/src/rdata_naptr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfarrugi/cargo-raze-example-stdx path: /cargo/vendor/rayon-0.9.0/src/lib.rs
#![doc(html_root_url = "https://docs.rs/rayon/0.9")]
#![allow(non_camel_case_types)] // I prefer to use ALL_CAPS for type parameters
#![deny(missing_debug_implementations)]
#![cfg_attr(test, feature(conservative_impl_tra... | code_fim | hard | {
"lang": "rust",
"repo": "mfarrugi/cargo-raze-example-stdx",
"path": "/cargo/vendor/rayon-0.9.0/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod split_producer;
pub mod collections;
pub mod iter;
pub mod option;
pub mod prelude;
pub mod range;
pub mod result;
pub mod slice;
pub mod str;
pub mod vec;
mod par_either;
mod test;
pub use rayon_core::current_num_threads;
pub use rayon_core::Configuration;
pub use rayon_core::initialize;
pub use r... | code_fim | hard | {
"lang": "rust",
"repo": "mfarrugi/cargo-raze-example-stdx",
"path": "/cargo/vendor/rayon-0.9.0/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut scenario = Scenario::empty(map, name);
// Include all buses/trains
scenario.only_seed_buses = None;
scenario.people = ExternalPerson::import(map, people, false).unwrap();
scenario.save();
}
// TODO Dedupe the many copies of these
fn rand_duration(rng: &mut XorShiftRng, low: Du... | code_fim | hard | {
"lang": "rust",
"repo": "yenwel/abstreet",
"path": "/importer/src/actdev.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Arbitrary but fixed seed
let mut rng = XorShiftRng::seed_from_u64(42);
let mut people = Vec::new();
for od in input {
for _ in 0..od.count {
let leave_time = rand_time(&mut rng, Duration::hours(7), Duration::hours(9));
let return_time = rand_time(&mut rn... | code_fim | hard | {
"lang": "rust",
"repo": "yenwel/abstreet",
"path": "/importer/src/actdev.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yenwel/abstreet path: /importer/src/actdev.rs
//! This module is used for all cities associated with the https://github.com/cyipt/actdev project.
use anyhow::Result;
use geojson::{Feature, GeoJson, Value};
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use geom::{Duration, LonLa... | code_fim | hard | {
"lang": "rust",
"repo": "yenwel/abstreet",
"path": "/importer/src/actdev.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.