text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> req.state()
.db
.send(QueryRun {
project_key: project_key.to_string(),
workflow_name: workflow_name.to_string(),
branch,
})
.from_err()
.and_then(|res| {
let run = res?;
let color = match StatusEnum::fr... | code_fim | hard | {
"lang": "rust",
"repo": "raylee/cds",
"path": "/contrib/uservices/badge/src/badge/handlers.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: extrawurst/gitui path: /asyncgit/src/sync/utils.rs
//! sync git api (various methods)
use super::{
repository::repo, CommitId, RepoPath, ShowUntrackedFilesConfig,
};
use crate::{
error::{Error, Result},
sync::config::untracked_files_config_repo,
};
use git2::{IndexAddOption, Repository, Repo... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/gitui",
"path": "/asyncgit/src/sync/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Make sure that now we have 1 file staged
assert_eq!(get_statuses(repo_path), (0, 1));
// And that file is test.txt
let diff =
get_diff(repo_path, "test.txt", true, None).unwrap();
assert_eq!(&*diff.hunks[0].lines[0].content, "@@ -1 +1 @@");
}
#[test]
fn test_not_staging_untracked_fold... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/gitui",
"path": "/asyncgit/src/sync/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(matcher.match_route("/").is_none());
assert!(matcher.match_route("/f").is_none());
assert!(matcher.match_route("/foo").is_none());
assert!(matcher.match_route("/foo/bar/").is_none());
assert!(matcher.match_route("/foo/bar/baz").is_none());
}
#[test]... | code_fim | hard | {
"lang": "rust",
"repo": "mayah/zircon.rs",
"path": "/src/handlers/router/matcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mayah/zircon.rs path: /src/handlers/router/matcher.rs
use regex::{Captures, Regex};
static VAR_SEQ: &'static str = "[,.a-zA-Z0-9_-]*";
static VAR_SEQ_WITH_SLASH: &'static str = "[,./a-zA-Z0-9_-]*";
pub struct RouteResult {
params: Vec<(String, String)>,
}
impl RouteResult {
pub fn par... | code_fim | hard | {
"lang": "rust",
"repo": "mayah/zircon.rs",
"path": "/src/handlers/router/matcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: falcosecurity/client-rs path: /src/config.rs
use serde_derive::{Deserialize, Serialize};
use std::default::Default;
use std::path::PathBuf;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AuthConfig {
pub(crate) ca: PathBuf,
pub(crate) cert: PathBuf,
pub(crate)... | code_fim | hard | {
"lang": "rust",
"repo": "falcosecurity/client-rs",
"path": "/src/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Config {
endpoint: "localhost:5060".to_owned(),
auth: Some(AuthConfig {
ca: PathBuf::from("/tmp/certs/ca.crt"),
cert: PathBuf::from("/etc/certs/client.crt"),
key: PathBuf::from("/etc/certs/client.key"),
}),
... | code_fim | medium | {
"lang": "rust",
"repo": "falcosecurity/client-rs",
"path": "/src/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sum_vector, _) =
input
.lines()
.fold((VecDeque::new(), false), |(mut sum_vector, found), line| {
if found {
return (sum_vector, found);
}
let number = line.parse::<i32>().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "phantomion/rust_aoc",
"path": "/src/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phantomion/rust_aoc path: /src/day9.rs
use std::collections::VecDeque;
pub fn day9_part1(input: &str) -> i32 {
let mut preamble = input
.lines()
.take(25)
.map(|line| line.parse::<i32>().unwrap())
.collect::<VecDeque<i32>>();
let improper_number =
... | code_fim | hard | {
"lang": "rust",
"repo": "phantomion/rust_aoc",
"path": "/src/day9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geo-engine/datatypes path: /tests/example-arrow.rs
els::filter::filter;
use arrow::datatypes::{DataType, DateUnit, Field, Schema, ToByteSlice};
use geoengine_datatypes::primitives::{Coordinate2D, TimeInterval};
use ocl::ProQue;
use std::{mem, slice};
#[test]
fn simple() {
let mut primitive_... | code_fim | hard | {
"lang": "rust",
"repo": "geo-engine/datatypes",
"path": "/tests/example-arrow.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for &t in &[
TimeInterval::new(0, 1).unwrap(),
TimeInterval::new(1, 2).unwrap(),
TimeInterval::new(2, 3).unwrap(),
] {
let t_bytes: [u8; 16] = unsafe { mem::transmute(t) };
builder.append_value(&t_bytes).unwrap();
}
... | code_fim | hard | {
"lang": "rust",
"repo": "geo-engine/datatypes",
"path": "/tests/example-arrow.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geo-engine/datatypes path: /tests/example-arrow.rs
TimeInterval};
use ocl::ProQue;
use std::{mem, slice};
#[test]
fn simple() {
let mut primitive_array_builder = Int32Builder::new(5);
primitive_array_builder.append_value(1).unwrap();
primitive_array_builder.append_value(2).unwrap()... | code_fim | hard | {
"lang": "rust",
"repo": "geo-engine/datatypes",
"path": "/tests/example-arrow.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astro/rust-lpc43xx path: /src/sct/regmode/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::REGMODE {
#[doc = r" Modifies the contents of the register"]
#[inline]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/sct/regmode/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t OFFSET: u8 = 16;
((self.bits >> OFFSET) & MASK as u32) as u16
};
REGMOD_HR { bits }
}
}
impl W {
#[doc = r" Reset value of the register"]
#[inline]
pub fn reset_value() -> W {
W { bits: 0 }
}
#[doc = r" Writes raw bits to the register"]
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "astro/rust-lpc43xx",
"path": "/src/sct/regmode/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsatka/couchbase-rs path: /couchbase/integration/util/standalone.rs
use super::{ConfigAware, TestConfig};
use crate::util::config::StandaloneConfig;
use crate::util::features::TestFeature;
use couchbase::Cluster;
use lazy_static::lazy_static;
use std::sync::Arc;
<|fim_suffix|>pub struct Standal... | code_fim | hard | {
"lang": "rust",
"repo": "jsatka/couchbase-rs",
"path": "/couchbase/integration/util/standalone.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl StandaloneCluster {
pub fn start(c: StandaloneConfig) -> Self {
let cluster = Cluster::connect(c.conn_string(), c.username(), c.password());
let bucket = cluster.bucket(c.default_bucket().unwrap_or_else(|| "default".into()));
let scope = bucket.scope(c.default_scope().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "jsatka/couchbase-rs",
"path": "/couchbase/integration/util/standalone.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Clone for Box<Header> {
fn clone(&self) -> Box<Header> {
self.clone_boxed()
}
}
impl Header for Box<Header> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
}
}
impl Header for &'static Header {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt... | code_fim | hard | {
"lang": "rust",
"repo": "chris-morgan/teepee",
"path": "/src/headers/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chris-morgan/teepee path: /src/headers/mod.rs
on<Self> {
panic!("******* YOUR CODE IS BUGGY. *******\n<Vec<_> as ToHeader>.parse() was called; \
Vec<T> only implements ToHeader to work around type system deficiencies.")
}
}
/// A header marker, providing the glue bet... | code_fim | hard | {
"lang": "rust",
"repo": "chris-morgan/teepee",
"path": "/src/headers/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(
)
)
;
dst
.
put_slice
(
&
self
.
bytes
(
)
[
.
.
n
]
)
;
self
.
pos
+
=
n
;
if
self
.
pos
=
=
self
.
buf
.
len
(
)
{
self
.
buf
.
truncate
(
0
)
;
self
.
pos
=
0
;
}
n
}
pub
(
crate
)
fn
copy_from
(
&
mut
self
src
:
&
[
u8
]
)
-
>
usize
{
assert
!
(
self
.
is_empty
(
)
)
;
let
n
=
cmp
:
:
min
(
src
.
l... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/src/io/blocking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/src/io/blocking.rs
use
crate
:
:
io
:
:
sys
;
use
crate
:
:
io
:
:
{
AsyncRead
AsyncWrite
ReadBuf
}
;
use
std
:
:
cmp
;
use
std
:
:
future
:
:
Future
;
use
std
:
:
io
;
use
std
:
:
io
:
:
prelude
:
:
*
;
use
std
:
:
pin
:
:
Pin
;
use
std
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/src/io/blocking.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
enum Weekday {
Mon = 0,
Tue = 1,
Wed = 2,
Thu = 3,
Fri = 4,
Sat = 5,
Sun = 6,
}
fn weekday_calc(dow: Weekday, offset: i8, mut weekshift: i8) -> ParsedDate {
let today = Local::today();
let today_dow = today.weekday() as i8;
let diff = match (dow as... | code_fim | hard | {
"lang": "rust",
"repo": "snark/whenever",
"path": "/src/parser/deictics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snark/whenever path: /src/parser/deictics.rs
use super::super::ParsedDate;
use chrono::prelude::{Datelike, Local};
use time::Duration;
use super::helper_macros::periods;
named!(indexical_unit <&[u8], ParsedDate>,
alt_complete!(
alt!(tag_no_case!("today") | tag_no_case!("now")) => { ... | code_fim | hard | {
"lang": "rust",
"repo": "snark/whenever",
"path": "/src/parser/deictics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bxcrs/IronRDP path: /ironrdp/src/gcc/multi_transport_channel_data/test.rs
use lazy_static::lazy_static;
use super::*;
pub const SERVER_GCC_MULTI_TRANSPORT_CHANNEL_BLOCK_BUFFER: [u8; 4] = [0x01, 0x03, 0x00, 0x00];
lazy_static! {
pub static ref SERVER_GCC_MULTI_TRANSPORT_CHANNEL_BLOCK: Mult... | code_fim | medium | {
"lang": "rust",
"repo": "bxcrs/IronRDP",
"path": "/ironrdp/src/gcc/multi_transport_channel_data/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data = SERVER_GCC_MULTI_TRANSPORT_CHANNEL_BLOCK.clone();
let expected_buffer_len = SERVER_GCC_MULTI_TRANSPORT_CHANNEL_BLOCK_BUFFER.len();
let len = data.buffer_length();
assert_eq!(expected_buffer_len, len);
}<|fim_prefix|>// repo: bxcrs/IronRDP path: /ironrdp/src/gcc/multi_transpor... | code_fim | medium | {
"lang": "rust",
"repo": "bxcrs/IronRDP",
"path": "/ironrdp/src/gcc/multi_transport_channel_data/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AntonAderum/aderum-game-engine path: /game_engine/src/GameEngine/game_engine/rectf64.rs
use GameEngine::game_engine::pointf::Pointf;
use GameEngine::game_engine::circle::Circle;
pub struct Rectf64 {
pub left: f64,
pub top: f64,
pub right: f64,
pub bottom: f64,
pub width: f64... | code_fim | hard | {
"lang": "rust",
"repo": "AntonAderum/aderum-game-engine",
"path": "/game_engine/src/GameEngine/game_engine/rectf64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cx > x_dist {
return false;
}
let cy = (other.middle_point.y - self.top - half_height).abs();
let y_dist = half_height + other.radius;
if cy > y_dist {
return false;
}
if cx <= half_width || cy <= half_height {
... | code_fim | hard | {
"lang": "rust",
"repo": "AntonAderum/aderum-game-engine",
"path": "/game_engine/src/GameEngine/game_engine/rectf64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdeconinck/rsweeper path: /src/gameboard.rs
//! Game board logic.
use std::cmp::min;
use graphics::types::Color;
use rand::{self, Rng};
/// The different values of a cell from the user.
#[derive(Clone, Copy, Debug)]
pub enum PlayerCell {
/// Not determined yet, the default value.
NotD... | code_fim | hard | {
"lang": "rust",
"repo": "qdeconinck/rsweeper",
"path": "/src/gameboard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The state is only updatable when being alive.
if let GameState::Alive = self.state {
let cell = self.get_cell(ind[0], ind[1]);
// Did the player lost?
if let PlayerCell::Revealed = cell.player {
if let CellContent::Bomb = cell.content... | code_fim | hard | {
"lang": "rust",
"repo": "qdeconinck/rsweeper",
"path": "/src/gameboard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustSucT4ever/BP path: /RustSucT4ever_lib/tests/rmm_tests.rs
extern crate RustSucT4ever_lib;
extern crate bv;
use RustSucT4ever_lib::range_min_max;
use bv::{BitVec};
#[test]
fn test_rank_0(){
let test_tree = create_rmm_test_tree();
let result = test_tree.rmm_rank_zero(12);
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "RustSucT4ever/BP",
"path": "/RustSucT4ever_lib/tests/rmm_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_tree = create_rmm_test_tree();
assert_eq!(test_tree.rmm_select_zero(1), 3);
assert_eq!(test_tree.rmm_select_zero(2), 5);
assert_eq!(test_tree.rmm_select_zero(3), 6);
assert_eq!(test_tree.rmm_select_zero(4), 10);
assert_eq!(test_tree.rmm_select_zero(5), 11);
assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "RustSucT4ever/BP",
"path": "/RustSucT4ever_lib/tests/rmm_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: max-heller/rust-smt-ir path: /amzn-smt-string-transformer/src/lib.rs
//! This is a tool for canonicalizing the strings in SMT string constraints, while
//! maintaining equisatisfiability of the queries.
//!
//! ### High-level overview
//! There are many reasons that users might want to transform... | code_fim | hard | {
"lang": "rust",
"repo": "max-heller/rust-smt-ir",
"path": "/amzn-smt-string-transformer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// extension to Sort; adds a member function that gets the corresponding IdentType
/// (basically, converting the Sort into my custom types)
trait SortExt {
/// get the IdentType corresponding to the Sort
fn get_type(&self) -> IdentType;
}
/// implement the SortExt trait for Sort; this adds acce... | code_fim | hard | {
"lang": "rust",
"repo": "max-heller/rust-smt-ir",
"path": "/amzn-smt-string-transformer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 1..4 {
let c = c.apply_move(Move(Face::U, i));
assert_eq!(0, EOCoord::get_coord(&c));
}
let c = Cube::new(
[URF, UFL, ULB, UBR, DFR, DLF, DBL, DRB],
[0; NUM_CORNERS],
[UR, UF, UL, UB, DR, DF, DL, DB, FR, FL, BL, BR],
[1; NUM_EDGES],
);
asse... | code_fim | hard | {
"lang": "rust",
"repo": "jgouly/tmp-delete",
"path": "/kociemba/src/transition_table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgouly/tmp-delete path: /kociemba/src/transition_table.rs
use cube::{Cube, Edge, Face, Move};
pub(crate) enum Group {
G0,
G1,
}
pub(crate) trait Coord {
/// Number of elements in `Coord`'s transition table.
const NUM_ELEMS: usize;
/// Which `Group` this `Coord` is defined for.
cons... | code_fim | hard | {
"lang": "rust",
"repo": "jgouly/tmp-delete",
"path": "/kociemba/src/transition_table.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /turbine/src/lib.rs
#![allow(clippy::arithmetic_side_effects)]
<|fim_suffix|>#[cfg(test)]
#[macro_use]
extern crate matches;<|fim_middle|>pub mod broadcast_stage;
pub mod cluster_nodes;
pub mod quic_endpoint;
pub mod retransmit_stage;
pub mod sigverify_shreds;
#[macro_... | code_fim | medium | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/turbine/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
#[macro_use]
extern crate matches;<|fim_prefix|>// repo: solana-labs/solana path: /turbine/src/lib.rs
#![allow(clippy::arithmetic_side_effects)]
<|fim_middle|>pub mod broadcast_stage;
pub mod cluster_nodes;
pub mod quic_endpoint;
pub mod retransmit_stage;
pub mod sigverify_shreds;
#[macro_... | code_fim | medium | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/turbine/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deciduously/music path: /src/theory/semitone.rs
//! A Semitone divides an octave into 12 equal parts
use super::interval::Interval;
<|fim_suffix|> s.0
}
}
impl From<Interval> for Semitones {
fn from(i: Interval) -> Self {
Semitones(i as i8)
}
}<|fim_middle|>#[derive(Debug, Default, Clon... | code_fim | hard | {
"lang": "rust",
"repo": "deciduously/music",
"path": "/src/theory/semitone.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Semitones> for i8 {
fn from(s: Semitones) -> Self {
s.0
}
}
impl From<Interval> for Semitones {
fn from(i: Interval) -> Self {
Semitones(i as i8)
}
}<|fim_prefix|>// repo: deciduously/music path: /src/theory/semitone.rs
//! A Semitone divides an octave into 12 equal parts
use super::i... | code_fim | medium | {
"lang": "rust",
"repo": "deciduously/music",
"path": "/src/theory/semitone.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let decoded = HashEncoding::new(HashType::BlockHash).string_to_bytes("BKyQ9EofHrgaZKENioHyP4FZNsTmiSEcVmcghgzCC9cGhE7oCET")?;
let decoded = hex::encode(&decoded);
let expected = "2253698f0c94788689fb95ca35eb1535ec3a8b7c613a97e6683f8007d7959e4b";
assert_eq!(expected, decoded... | code_fim | hard | {
"lang": "rust",
"repo": "baitcenter/tezos-rs",
"path": "/tezos_encoding/src/hash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baitcenter/tezos-rs path: /tezos_encoding/src/hash.rs
use std::sync::Arc;
use crypto::base58::{FromBase58Check, FromBase58CheckError, ToBase58Check};
mod prefix_bytes {
pub const CHAIN_ID: [u8; 3] = [87, 82, 0];
pub const BLOCK_HASH: [u8; 2] = [1, 52];
pub const CONTEXT_HASH: [u8; ... | code_fim | hard | {
"lang": "rust",
"repo": "baitcenter/tezos-rs",
"path": "/tezos_encoding/src/hash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dialtone/hwloc-rs path: /examples/walk_tree.rs
extern crate hwloc;
use hwloc::{Topology, TopologyObject};
<|fim_suffix|>fn print_children(topo: &Topology, obj: &TopologyObject, depth: usize) {
let padding = std::iter::repeat(" ").take(depth).collect::<String>();
println!("{}{}: #{}", p... | code_fim | medium | {
"lang": "rust",
"repo": "dialtone/hwloc-rs",
"path": "/examples/walk_tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let padding = std::iter::repeat(" ").take(depth).collect::<String>();
println!("{}{}: #{}", padding, obj, obj.os_index());
for i in 0..obj.arity() {
print_children(topo, obj.children()[i as usize], depth + 1);
}
}<|fim_prefix|>// repo: dialtone/hwloc-rs path: /examples/walk_tree.... | code_fim | medium | {
"lang": "rust",
"repo": "dialtone/hwloc-rs",
"path": "/examples/walk_tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rb(addr);
z80.set_register_clock(4);
}<|fim_prefix|>// repo: CryZe/42-GBmu path: /src/z80/ops/ld.rs
use z80::Z80;
pub fn lda_mm(z80: &mut Z8<|fim_middle|>0) {
let addr = z80.mmu.rw(z80.r.pc);
z80.r.pc += 2;
z80.r.a = z80.mmu. | code_fim | medium | {
"lang": "rust",
"repo": "CryZe/42-GBmu",
"path": "/src/z80/ops/ld.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CryZe/42-GBmu path: /src/z80/ops/ld.rs
use z80::Z80;
pub fn lda_mm(z80: &mut Z8<|fim_suffix|> z80.r.pc += 2;
z80.r.a = z80.mmu.rb(addr);
z80.set_register_clock(4);
}<|fim_middle|>0) {
let addr = z80.mmu.rw(z80.r.pc);
| code_fim | easy | {
"lang": "rust",
"repo": "CryZe/42-GBmu",
"path": "/src/z80/ops/ld.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kory33/home-intercom-esp8266-broker-rs path: /examples/home-intercom-esp8266-broker-rs.rs
#![no_std]
#![no_main]
use core::fmt::Write;
use esp8266_hal::prelude::*;
use esp8266_hal::target::Peripherals;
use panic_halt as _;
<|fim_suffix|> loop {
let byte = nb::block!(serial.read()).u... | code_fim | hard | {
"lang": "rust",
"repo": "kory33/home-intercom-esp8266-broker-rs",
"path": "/examples/home-intercom-esp8266-broker-rs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let byte = nb::block!(serial.read()).unwrap();
serial.write(byte + 3).unwrap();
}
}<|fim_prefix|>// repo: kory33/home-intercom-esp8266-broker-rs path: /examples/home-intercom-esp8266-broker-rs.rs
#![no_std]
#![no_main]
use core::fmt::Write;
use esp8266_hal::prelude::*;
use... | code_fim | medium | {
"lang": "rust",
"repo": "kory33/home-intercom-esp8266-broker-rs",
"path": "/examples/home-intercom-esp8266-broker-rs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hanhossain/esp-at path: /src/wifi.rs
use crate::ATClient;
pub struct ATWifi<'a> {
client: &'a mut ATClient,
}
impl<'a> ATWifi<'a> {
pub fn new(client: &'a mut ATClient) -> Self {
ATWifi { client }
}
pub fn get_current_mode(&mut self) -> String {
self.client.sen... | code_fim | hard | {
"lang": "rust",
"repo": "hanhossain/esp-at",
"path": "/src/wifi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let message = format!("AT+CWMODE_CUR={}", mode);
self.client.send(message.as_str())
}
pub fn get_available_access_points(&mut self) -> String {
self.client.send("AT+CWLAP")
}
pub fn connect_to_access_point(&mut self, ssid: &str, password: &str) -> String {
... | code_fim | hard | {
"lang": "rust",
"repo": "hanhossain/esp-at",
"path": "/src/wifi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_current_mode(&mut self, mode: WifiMode) -> String {
let mode = match mode {
WifiMode::Station => 1,
WifiMode::SoftAccessPoint => 2,
WifiMode::SoftAccessPointAndStation => 3,
};
let message = format!("AT+CWMODE_CUR={}", mode);
... | code_fim | medium | {
"lang": "rust",
"repo": "hanhossain/esp-at",
"path": "/src/wifi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # [wasm_bindgen (method , structural , js_class = "StorageEvent" , js_name = initStorageEvent)]
#[doc = "The `initStorageEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent/initStorageEvent)"]
#[doc = ""]
#[doc = ... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_StorageEvent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_StorageEvent.rs
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = StorageEvent , t... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_StorageEvent.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= "StorageEvent" , js_name = initStorageEvent)]
#[doc = "The `initStorageEvent()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent/initStorageEvent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_StorageEvent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kallydev/shadowsocks-rust-patch path: /bin/common/mod.rs
//! Shadowsocks service command line utilities
<|fim_suffix|>pub const EXIT_CODE_SERVER_EXIT_UNEXPECTLY: i32 = exitcode::SOFTWARE;
pub const EXIT_CODE_SERVER_ABORTED: i32 = exitcode::SOFTWARE;
pub const EXIT_CODE_LOAD_CONFIG_FAILURE: i32 ... | code_fim | medium | {
"lang": "rust",
"repo": "kallydev/shadowsocks-rust-patch",
"path": "/bin/common/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const EXIT_CODE_SERVER_EXIT_UNEXPECTLY: i32 = exitcode::SOFTWARE;
pub const EXIT_CODE_SERVER_ABORTED: i32 = exitcode::SOFTWARE;
pub const EXIT_CODE_LOAD_CONFIG_FAILURE: i32 = exitcode::CONFIG;
pub const EXIT_CODE_LOAD_ACL_FAILURE: i32 = exitcode::CONFIG;<|fim_prefix|>// repo: kallydev/shadowsocks-rust... | code_fim | medium | {
"lang": "rust",
"repo": "kallydev/shadowsocks-rust-patch",
"path": "/bin/common/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uklotzde/bs58-rs path: /src/encode.rs
//! Functions for encoding into Base58 encoded strings.
use CHECKSUM_LEN;
/// A builder for setting up the alphabet and output of a base58 encode.
#[allow(missing_debug_implementations)]
pub struct EncodeBuilder<'a, I: AsRef<[u8]>> {
input: I,
alph... | code_fim | hard | {
"lang": "rust",
"repo": "uklotzde/bs58-rs",
"path": "/src/encode.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> output.clear();
let output = unsafe {
// Writing directly to the bytes of this string is safe as above we have
// verified that we are only going to be writing ASCII bytes, which is a
// valid subset of UTF-8.
//
// We will also be temporarily pushing values... | code_fim | hard | {
"lang": "rust",
"repo": "uklotzde/bs58-rs",
"path": "/src/encode.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pool = new_pool();
let conn = get_conn(&pool).unwrap();
for body in &[
"First to expand",
"First to scout a building",
"First to max supply, or highest supply",
"Who to win",
] {
diesel::insert_into(questions::table)
.values(question... | code_fim | medium | {
"lang": "rust",
"repo": "agmcleod/sc-predictions-server",
"path": "/seeds/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agmcleod/sc-predictions-server path: /seeds/src/main.rs
use diesel::{self, ExpressionMethods, RunQueryDsl};
use dotenv::dotenv;
<|fim_suffix|> let pool = new_pool();
let conn = get_conn(&pool).unwrap();
for body in &[
"First to expand",
"First to scout a building",
... | code_fim | medium | {
"lang": "rust",
"repo": "agmcleod/sc-predictions-server",
"path": "/seeds/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for body in &[
"First to expand",
"First to scout a building",
"First to max supply, or highest supply",
"Who to win",
] {
diesel::insert_into(questions::table)
.values(questions::dsl::body.eq(body))
.execute(&conn)
.unwra... | code_fim | medium | {
"lang": "rust",
"repo": "agmcleod/sc-predictions-server",
"path": "/seeds/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut abundant_sums = [false; UPPER_BOUND as usize];
for i in &abundant_nums {
for j in &abundant_nums {
let sum = i + j;
if sum < UPPER_BOUND {
abundant_sums[sum as usize] = true;
}
}
}
abundant_sums
.iter()
... | code_fim | medium | {
"lang": "rust",
"repo": "clementlee/euler-rs",
"path": "/src/problems/p23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> abundant_sums
.iter()
.enumerate()
.filter(|(_i, x)| !**x)
.map(|(i, _x)| i as u32)
.sum()
}<|fim_prefix|>// repo: clementlee/euler-rs path: /src/problems/p23.rs
use crate::lib::sum_divisors;
const UPPER_BOUND: u32 = 28123;
<|fim_middle|>pub fn solution() -> u... | code_fim | hard | {
"lang": "rust",
"repo": "clementlee/euler-rs",
"path": "/src/problems/p23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clementlee/euler-rs path: /src/problems/p23.rs
use crate::lib::sum_divisors;
const UPPER_BOUND: u32 = 28123;
<|fim_suffix|> abundant_sums
.iter()
.enumerate()
.filter(|(_i, x)| !**x)
.map(|(i, _x)| i as u32)
.sum()
}<|fim_middle|>pub fn solution() -> u... | code_fim | hard | {
"lang": "rust",
"repo": "clementlee/euler-rs",
"path": "/src/problems/p23.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angelcam/arrow-client path: /src/net/arrow/session.rs
Mut::with_capacity(BUFFER_CAPACITY),
input_capacity: window_size,
output_capacity: window_size,
output_written: 0,
session_manager_task: None,
session_transport_task: None,
... | code_fim | hard | {
"lang": "rust",
"repo": "angelcam/arrow-client",
"path": "/src/net/arrow/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angelcam/arrow-client path: /src/net/arrow/session.rs
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KI... | code_fim | hard | {
"lang": "rust",
"repo": "angelcam/arrow-client",
"path": "/src/net/arrow/session.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let transport = Self { context, stream };
Ok(transport)
}
}
impl Future for SessionTransport {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// just to make the borrow checker happy
let ctx = self.context.cl... | code_fim | hard | {
"lang": "rust",
"repo": "angelcam/arrow-client",
"path": "/src/net/arrow/session.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the set of tags contained in the object.
pub fn tags(&self) -> &HashMap<String, String> {
&self.tags
}
/// Returns the selector describing the object.
pub fn selector(&self) -> &Selector {
&self.selector
}
/// Returns the estimated memory size used... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/sailor",
"path": "/src/lib/object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/sailor path: /src/lib/object.rs
use super::*;
use lyon::math::Point;
use std::collections::HashMap;
/// Classifies an object as one of three possible types.
#[derive(Debug, Clone)]
pub enum ObjectType {
Polygon,
Line,
Point,
}
/// Represents any object on the map.
#[derive(... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/sailor",
"path": "/src/lib/object.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the estimated memory size used by the object.
pub fn size(&self) -> usize {
use parity_util_mem::MallocSizeOfExt;
self.selector.size()
+ self.tags.malloc_size_of()
+ std::mem::size_of_val(&self.tags)
+ self
.tags
... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/sailor",
"path": "/src/lib/object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjhbw/background-modelling path: /benches/benchmarks.rs
#[macro_use]
extern crate criterion;
extern crate image;
extern crate image_manipulation;
extern crate rand;
use criterion::Criterion;
use image::Rgb;
use image::RgbImage;
use image_manipulation::bg_model::gmm::*;
use image_manipulation::b... | code_fim | hard | {
"lang": "rust",
"repo": "jjhbw/background-modelling",
"path": "/benches/benchmarks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("model_predict_single_pixel", move |b| {
b.iter(|| model.predict(&testimage))
});
}
fn bench_model_predict_vs_image_size(c: &mut Criterion) {
let settings = default_model_hyperparameters();
c.bench_function_over_inputs(
"model_predict_vs_image_size",
... | code_fim | hard | {
"lang": "rust",
"repo": "jjhbw/background-modelling",
"path": "/benches/benchmarks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tweoss/econ path: /server/src/game_folder/game.rs
sh_list[index] = Some(vec![(p.0.clone(), hash.clone())])
}
if p.2 {
if let Some(addr) = &self.consumers.read().unwrap().get(&p.0).unwrap().addr
{
addr.do_send(game_to_participant::Winner {
hash,
place:... | code_fim | hard | {
"lang": "rust",
"repo": "Tweoss/econ",
"path": "/server/src/game_folder/game.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<producer_to_game::RegisterAddressGetInfo> for Game {
type Result = ();
fn handle(
&mut self,
msg: producer_to_game::RegisterAddressGetInfo,
_: &mut Context<Self>,
) -> Self::Result {
if let Some(mut addr_value) = self.producers.write().unwrap().get_mut(&msg.name) {
addr_value.ad... | code_fim | hard | {
"lang": "rust",
"repo": "Tweoss/econ",
"path": "/server/src/game_folder/game.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tweoss/econ path: /server/src/game_folder/game.rs
IsGameOpen, _: &mut Context<Self>) -> Self::Result {
self.is_open
}
}
/// Register an additional director
impl Handler<NewDirector> for Game {
type Result = ();
fn handle(&mut self, msg: NewDirector, _: &mut Context<Self>) -> Self::Result ... | code_fim | hard | {
"lang": "rust",
"repo": "Tweoss/econ",
"path": "/server/src/game_folder/game.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn run<S: 'static>(&mut self, server_logic: S)
where
S: FnOnce(Router) + Sync + Send + Copy
{
for stream in self.listener.incoming() {
let tcp = stream.expect("Error binding");
self.pool.execute(tcp, move |router| {
server_logic(rout... | code_fim | hard | {
"lang": "rust",
"repo": "nicolasjhampton/rust-server-framework",
"path": "/network/src/server/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicolasjhampton/rust-server-framework path: /network/src/server/mod.rs
mod utils;
use utils::ThreadPool;
use retry::{delay::Fixed, retry_with_index};
use std::net::{TcpListener, TcpStream};
use router::Router;
<|fim_suffix|> return retry_with_index(Fixed::from_millis(100), |index| {
... | code_fim | medium | {
"lang": "rust",
"repo": "nicolasjhampton/rust-server-framework",
"path": "/network/src/server/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itarato/Yet-Another-Gameboy-Emulator path: /src/serial.rs
#[derive(Debug, Default)]
pub struct Serial;
<|fim_suffix|> if w != 0x81 {
print!("{}", w as char);
}
}
}<|fim_middle|>impl Serial {
pub fn write_word(&self, addr: u16, w: u8) {
// @TODO Implement.
// p... | code_fim | hard | {
"lang": "rust",
"repo": "itarato/Yet-Another-Gameboy-Emulator",
"path": "/src/serial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if w != 0x81 {
print!("{}", w as char);
}
}
}<|fim_prefix|>// repo: itarato/Yet-Another-Gameboy-Emulator path: /src/serial.rs
#[derive(Debug, Default)]
pub struct Serial;
<|fim_middle|>impl Serial {
pub fn write_word(&self, addr: u16, w: u8) {
// @TODO Implement.
// p... | code_fim | hard | {
"lang": "rust",
"repo": "itarato/Yet-Another-Gameboy-Emulator",
"path": "/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay/async-trait path: /tests/ui/bare-trait-object.rs
#![deny(bare_trait_objects)]
<|fim_suffix|>#[async_trait]
trait Trait {
async fn f(&self);
}
#[async_trait]
impl Trait for Send + Sync {
async fn f(&self) {}
}
fn main() {}<|fim_middle|>use async_trait::async_trait;
| code_fim | easy | {
"lang": "rust",
"repo": "dtolnay/async-trait",
"path": "/tests/ui/bare-trait-object.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay/async-trait path: /tests/ui/bare-trait-object.rs
#![deny(bare_trait_objects)]
use async_trait::async_trait;
<|fim_suffix|>#[async_trait]
impl Trait for Send + Sync {
async fn f(&self) {}
}
fn main() {}<|fim_middle|>#[async_trait]
trait Trait {
async fn f(&self);
}
| code_fim | easy | {
"lang": "rust",
"repo": "dtolnay/async-trait",
"path": "/tests/ui/bare-trait-object.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl Trait for Send + Sync {
async fn f(&self) {}
}
fn main() {}<|fim_prefix|>// repo: dtolnay/async-trait path: /tests/ui/bare-trait-object.rs
#![deny(bare_trait_objects)]
use async_trait::async_trait;
<|fim_middle|>#[async_trait]
trait Trait {
async fn f(&self);
}
| code_fim | easy | {
"lang": "rust",
"repo": "dtolnay/async-trait",
"path": "/tests/ui/bare-trait-object.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkartaltepe/vainfo-bis path: /src/main.rs
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[macro_use]
extern crate error_chain;
mod errors {
error_chain! {
foreign_links {
I... | code_fim | hard | {
"lang": "rust",
"repo": "kkartaltepe/vainfo-bis",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>static VASURFACEATTRIB_STR: &'static [(u32, &'static str)] = &[
et!(VASurfaceAttribPixelFormat),
et!(VASurfaceAttribMinWidth),
et!(VASurfaceAttribMaxWidth),
et!(VASurfaceAttribMinHeight),
et!(VASurfaceAttribMaxHeight),
et!(VASurfaceAttribMemoryType),
et!(VASurfaceAttribExternal... | code_fim | hard | {
"lang": "rust",
"repo": "kkartaltepe/vainfo-bis",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 38/constat path: /src/options.rs
use chrono::{Date, NaiveDate, TimeZone, Utc};
use clap::{load_yaml, value_t_or_exit, values_t_or_exit, App, ArgMatches};
use glob::Pattern;
use std::path::{Path, PathBuf};
use tempfile::{tempdir, TempDir};
pub struct ConstatOptions {
pub repo_path: PathBuf,
... | code_fim | hard | {
"lang": "rust",
"repo": "38/constat",
"path": "/src/options.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(path) = std::fs::canonicalize(parsed.value_of("repository").unwrap_or(".")) {
return (path, None);
}
let url = parsed.value_of("repository").unwrap();
let name = AsRef::<Path>::as_ref(url.split("/").last().unwrap())
.file_stem()
.unwrap();
let temp =... | code_fim | hard | {
"lang": "rust",
"repo": "38/constat",
"path": "/src/options.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: async-raft/async-raft path: /async-raft/src/raft.rs
hangeConfigError, ClientReadError, ClientWriteError, InitializeError, RaftError, RaftResult};
use crate::metrics::RaftMetrics;
use crate::{AppData, AppDataResponse, NodeId, RaftNetwork, RaftStorage};
struct RaftInner<D: AppData, R: AppDataResp... | code_fim | hard | {
"lang": "rust",
"repo": "async-raft/async-raft",
"path": "/async-raft/src/raft.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Synchronize a new Raft node, bringing it up-to-speed (§6).
///
/// Applications built on top of Raft will typically have some peer discovery mechanism for
/// detecting when new nodes come online and need to be added to the cluster. This API
/// facilitates the ability to request t... | code_fim | hard | {
"lang": "rust",
"repo": "async-raft/async-raft",
"path": "/async-raft/src/raft.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A model of the membership configuration of the cluster.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MembershipConfig {
/// All members of the Raft cluster.
pub members: HashSet<NodeId>,
/// All members of the Raft cluster after joint consensus is finalized.
... | code_fim | hard | {
"lang": "rust",
"repo": "async-raft/async-raft",
"path": "/async-raft/src/raft.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl EventStreamProvider {
pub fn new(registry: Weak<EventRegistry>, execution_mode: ExecutionMode) -> Self {
Self { registry, streams: Arc::new(Mutex::new(HashMap::new())), execution_mode }
}
pub fn hooks(self: &Arc<Self>) -> Vec<HooksRegistration> {
vec![HooksRegistration::n... | code_fim | hard | {
"lang": "rust",
"repo": "shangzuoyan/fuchsia",
"path": "/src/sys/component_manager/src/model/events/stream_provider.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Creates EventStreams on component resolution according to statically declared
/// event_streams, and passes them along to components on start.
pub struct EventStreamProvider {
/// A shared reference to the event registry used to subscribe and dispatch events.
registry: Weak<EventRegistry>,
... | code_fim | hard | {
"lang": "rust",
"repo": "shangzuoyan/fuchsia",
"path": "/src/sys/component_manager/src/model/events/stream_provider.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shangzuoyan/fuchsia path: /src/sys/component_manager/src/model/events/stream_provider.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::model::{
error::M... | code_fim | hard | {
"lang": "rust",
"repo": "shangzuoyan/fuchsia",
"path": "/src/sys/component_manager/src/model/events/stream_provider.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyrylu/feel-the-streets path: /osm_api/src/utils.rs
use crate::object::OSMObject;
use geo_types::{Coord, Geometry, LineString};
use once_cell::sync::Lazy;
use std::collections::HashMap;
const POLYGON_CRITERIA_STR: &str = include_str!("polygon_criteria.json");
static POLYGON_CRITERIA: Lazy<Vec<P... | code_fim | hard | {
"lang": "rust",
"repo": "tyrylu/feel-the-streets",
"path": "/osm_api/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let last_coord_idx = merge_from.0.len() - 1;
if merge_from[last_coord_idx] == merge_to[0] {
// We have the merge_to coords, and then the merge_from ones, except for the last one.
merge_to
.0
.splice(0..0, merge_from.0[0..last_coord_idx].iter().copied());
... | code_fim | hard | {
"lang": "rust",
"repo": "tyrylu/feel-the-streets",
"path": "/osm_api/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn unnest_geometry_to_parts(geom: Geometry<f64>) -> Vec<Geometry<f64>> {
let mut parts = vec![];
match geom {
Geometry::Point(p) => parts.push(p.into()),
Geometry::Polygon(p) => parts.push(p.into()),
Geometry::LineString(l) => parts.push(l.into()),
Geometry::MultiLi... | code_fim | hard | {
"lang": "rust",
"repo": "tyrylu/feel-the-streets",
"path": "/osm_api/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use builtin::*;
pub use data::*;
pub use errors::*;
pub use executor::*;<|fim_prefix|>// repo: ClementNerma/Peggy path: /peggy/src/runtime/mod.rs
//! # Peggy's Runtime Engine
//!
//! This module contains a small and fast [runtime](executor::execute) to executed [already-parsed grammars](crate::compil... | code_fim | easy | {
"lang": "rust",
"repo": "ClementNerma/Peggy",
"path": "/peggy/src/runtime/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ClementNerma/Peggy path: /peggy/src/runtime/mod.rs
//! # Peggy's Runtime Engine
//!
//! This module contains a small and fast [runtime](executor::execute) to executed [already-parsed grammars](crate::compiler::parse_peg).
<|fim_suffix|>pub use builtin::*;
pub use data::*;
pub use errors::*;
pub... | code_fim | easy | {
"lang": "rust",
"repo": "ClementNerma/Peggy",
"path": "/peggy/src/runtime/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Cart {
fn new(x: usize, y: usize, facing: Direction) -> Self {
Self { x, y, facing, mem: 0, killed: false }
}
fn turn(&mut self) {
match self.mem {
0 => self.facing.turn(Turn::Left),
1 => self.facing.turn(Turn::None),
2 => self.facing.t... | code_fim | hard | {
"lang": "rust",
"repo": "darksv/AdventOfCode2018",
"path": "/src/bin/aoc13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: darksv/AdventOfCode2018 path: /src/bin/aoc13.rs
const WIDTH: usize = 150;
const HEIGHT: usize = 150;
struct Map {
tiles: [[Tile; WIDTH]; HEIGHT],
width: usize,
height: usize,
}
fn main() {
let input = std::fs::read_to_string("inputs/input13.txt").unwrap();
let (map, mut car... | code_fim | hard | {
"lang": "rust",
"repo": "darksv/AdventOfCode2018",
"path": "/src/bin/aoc13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reitermarkus/msp432p401r-pac path: /src/adc14.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Control 0 Register"]
pub adc14ctl0: ADC14CTL0,
#[doc = "0x04 - Control 1 Register"]
pub adc14ctl1: ADC14CTL1,
#[doc = "0x08 - Window Comparator Lo... | code_fim | hard | {
"lang": "rust",
"repo": "reitermarkus/msp432p401r-pac",
"path": "/src/adc14.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ify--write-api).\n\nFor information about available fields see [adc14ifgr0](adc14ifgr0) module"]
pub type ADC14IFGR0 = crate::Reg<u32, _ADC14IFGR0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _ADC14IFGR0;
#[doc = "`read()` method returns [adc14ifgr0::R](adc14ifgr0::R) reader structure"]
impl crate::... | code_fim | hard | {
"lang": "rust",
"repo": "reitermarkus/msp432p401r-pac",
"path": "/src/adc14.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgraef/rustorio path: /rustorio-core/src/prototypes/prototypes/dont_craft_manually_achievement.rs
use serde::{Deserialize, Serialize};
use crate::prototypes::{Prototype, Visitor};
use crate::types::*; // TODO: Import only specific types
<|fim_suffix|>impl Prototype for DontCraftManuallyAchieve... | code_fim | medium | {
"lang": "rust",
"repo": "jgraef/rustorio",
"path": "/rustorio-core/src/prototypes/prototypes/dont_craft_manually_achievement.rs",
"mode": "psm",
"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.