text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: euclio/ips path: /src/lib.rs
//! Parser for the IPS patch format.
//!
//! Handles run-length encoded hunks as well as the truncation extension.
//!
//! # Example
//!
//! Patching a ROM from an IPS file:
//!
//! ```no_run
//! use std::fs::{self, File};
//! use std::io::{Seek, SeekFrom, Write};
//... | code_fim | hard | {
"lang": "rust",
"repo": "euclio/ips",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (input, truncation) = opt(be_int(3))(input)?;
Ok((input, Patch { hunks, truncation }))
}
fn hunk(input: &[u8]) -> IResult<&[u8], Hunk> {
let (input, offset) = be_int(3)(input)?;
let (input, len) = be_int(2)(input)?;
let (input, payload) = if len == 0 {
// Run-length enco... | code_fim | hard | {
"lang": "rust",
"repo": "euclio/ips",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs
use ruff_text_size::TextRange;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use crate::rules::pycodestyle::helpers::is_ambiguous_name;
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// E741
pub(crate) fn ambiguous_variable_name(name: &str, range: TextRange) -> Option<Diagnostic> {
if is_ambiguous_name(name) {
Some(Diagnostic::new(
AmbiguousVariableName(name.to_string()),
range,
))
} else {
None
}
}<|fim_prefix|>// repo: ast... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let AmbiguousVariableName(name) = self;
format!("Ambiguous variable name: `{name}`")
}
}
/// E741
pub(crate) fn ambiguous_variable_name(name: &str, range: TextRange) -> Option<Diagnostic> {
if is_ambiguous_name(name) {
Some(Diagnostic::new(
AmbiguousVariableNam... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
static INPUT: &'static [u8] = b"theanswertolifetheuniverseandeverythingis42theanswertolifetheuniverseandeverythingis4theanswertolifetheuniverseandeverythingis2";
#[test]
fn null_compress_and_decompress() {
let codec =... | code_fim | hard | {
"lang": "rust",
"repo": "snow01/avro-rs",
"path": "/src/codec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snow01/avro-rs path: /src/codec.rs
//! Logic for all supported compression codecs in Avro.
use std::io::{Read, Write};
use std::str::FromStr;
#[cfg(feature = "snappy")]
use byteorder;
#[cfg(feature = "snappy")]
use crc;
use failure::Error;
use libflate::deflate::{Decoder, Encoder};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "snow01/avro-rs",
"path": "/src/codec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fulara/mki-rust path: /src/mouse.rs
use serde::{Deserialize, Serialize};
use std::fmt;
#[cfg(target_os = "windows")] // Not sure how to detect double on linux
#[derive(Copy, Clone, Ord, PartialOrd, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub enum Mouse {
Left,
DoubleLeft,
... | code_fim | hard | {
"lang": "rust",
"repo": "fulara/mki-rust",
"path": "/src/mouse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Mouse {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("{:?}", self))
}
}<|fim_prefix|>// repo: fulara/mki-rust path: /src/mouse.rs
use serde::{Deserialize, Serialize};
use std::fmt;
#[cfg(target_os = "windows")] // Not sure how ... | code_fim | hard | {
"lang": "rust",
"repo": "fulara/mki-rust",
"path": "/src/mouse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_transform() {
let mut s = parse("12345678");
transform_signal(&mut s, 0);
assert_eq!(s, parse("48226158"));
transform_signal(&mut s, 0);
assert_eq!(s, parse("34040438"));
transform_signal(&mut s, 0);
assert_eq!(s, parse("03415... | code_fim | hard | {
"lang": "rust",
"repo": "macph/aoc19",
"path": "/src/days/d16.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: macph/aoc19 path: /src/days/d16.rs
/// Advent of Code 2019, day 16
/// https://adventofcode.com/2019/day/16
use std::str::from_utf8;
use itertools::Itertools;
type S = i32;
const CYCLES: usize = 100;
const MULTIPLIER: usize = 10_000;
const OFFSET: usize = 7;
fn optimised_transform(signal: &m... | code_fim | hard | {
"lang": "rust",
"repo": "macph/aoc19",
"path": "/src/days/d16.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out_path = PathBuf::from(env::var("OUT_DIR")?);
bindings.write_to_file(out_path.join("gamemode_bindings.rs"))?;
}
#[cfg(not(target_os = "linux"))]
fn main() {
}<|fim_prefix|>// repo: burtonageo/gamemode path: /gamemode_sys/build.rs
#[cfg(target_os = "linux")]
fn main() {
cc::Build::new()... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/gamemode",
"path": "/gamemode_sys/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burtonageo/gamemode path: /gamemode_sys/build.rs
#[cfg(target_os = "linux")]
fn main() {
cc::Build::new()
.file("./c_src/wrapper.c")
.compile("gamemode_client");
<|fim_suffix|> let out_path = PathBuf::from(env::var("OUT_DIR")?);
bindings.write_to_file(out_path.join("g... | code_fim | hard | {
"lang": "rust",
"repo": "burtonageo/gamemode",
"path": "/gamemode_sys/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // do not export min and max
_ => None,
}
}
// send application metrics to aggregator
AtomicBucket::default_drain(Stream::write_to_stderr());
AtomicBucket::default_stats(custom_statistics);
let app_metrics = AtomicBucket::new();
// schedule aggreg... | code_fim | hard | {
"lang": "rust",
"repo": "fralalonde/dipstick",
"path": "/examples/custom_publish.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fralalonde/dipstick path: /examples/custom_publish.rs
//! A demonstration of customization of exported aggregated metrics.
//! Using match on origin metric kind or score type to alter publication output.
use dipstick::*;
use std::time::Duration;
<|fim_suffix|> // send application metrics to... | code_fim | hard | {
"lang": "rust",
"repo": "fralalonde/dipstick",
"path": "/examples/custom_publish.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let app_metrics = AtomicBucket::new();
// schedule aggregated metrics to be printed every 3 seconds
app_metrics.flush_every(Duration::from_secs(3));
let counter = app_metrics.counter("counter_a");
let timer = app_metrics.timer("timer_b");
let gauge = app_metrics.gauge("gauge_c");... | code_fim | hard | {
"lang": "rust",
"repo": "fralalonde/dipstick",
"path": "/examples/custom_publish.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alice/advent_2018 path: /src/day6.rs
use grid::Grid;
use regex::Regex;
use std::fmt;
use std::str::FromStr;
use std::string::ParseError;
struct Location {
pub x: usize,
pub y: usize,
pub id: Option<String>,
pub num_closest: u32,
pub infinite: bool,
}
static mut NEXT_ID: usize = 0;
st... | code_fim | hard | {
"lang": "rust",
"repo": "alice/advent_2018",
"path": "/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let closest_coords_option = self.compute_closest_coords(col, row);
if closest_coords_option.is_none() {
return None;
}
let (x, y) = closest_coords_option.unwrap();
return self.get_mut(x, y);
}
fn compute_closest(&self, col: usize, row: usize) -> Option<&T> {
let closest_... | code_fim | hard | {
"lang": "rust",
"repo": "alice/advent_2018",
"path": "/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yhnu/RustLearn path: /4.3Slice/src/main.rs
#[allow(unused)]
fn main() {
println!("Hello, world!");
let s = String::from("hello world");
let hello = &s[0..5];
let world = &s[6..11];
println!("{} {}", hello, world);
// 语法糖1
let s = String::from("hello");
let slice ... | code_fim | medium | {
"lang": "rust",
"repo": "yhnu/RustLearn",
"path": "/4.3Slice/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let len = s.len();
let slice = &s[0..len];
let slice = &s[..];
}<|fim_prefix|>// repo: yhnu/RustLearn path: /4.3Slice/src/main.rs
#[allow(unused)]
fn main() {
println!("Hello, world!");
let s = String::from("hello world");
let hello = &s[0..5];
let world = &s[6..11];
pri... | code_fim | medium | {
"lang": "rust",
"repo": "yhnu/RustLearn",
"path": "/4.3Slice/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ry/tokio path: /tokio-async-await/src/compat/backward.rs
use futures::{Future, Poll};
use std::pin::Pin;
use std::future::{
Future as StdFuture,
};
use std::ptr::NonNull;
use std::task::{
LocalWaker,
Poll as StdPoll,
UnsafeWake,
Waker,
};
<|fim_suffix|>impl<T> Compat<T> {
... | code_fim | hard | {
"lang": "rust",
"repo": "ry/tokio",
"path": "/tokio-async-await/src/compat/backward.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct NoopWaker;
fn noop_local_waker() -> LocalWaker {
let w: NonNull<NoopWaker> = NonNull::dangling();
unsafe { LocalWaker::new(w) }
}
fn noop_waker() -> Waker {
let w: NonNull<NoopWaker> = NonNull::dangling();
unsafe { Waker::new(w) }
}
unsafe impl UnsafeWake for NoopWaker {
unsa... | code_fim | hard | {
"lang": "rust",
"repo": "ry/tokio",
"path": "/tokio-async-await/src/compat/backward.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/mismatched_types/normalize-fn-sig.rs
trait Foo {
type Bar;
}
impl<T> Foo for T {
type Bar = i32;
}
fn foo<T>(_: <T as Foo>::Bar, _: &'static <T as Foo>::Bar) {}
<|fim_suffix|>
fn main() {
needs_i32_ref_fn(foo::<()>);
//~^ ERROR mismatched types
}... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/mismatched_types/normalize-fn-sig.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
needs_i32_ref_fn(foo::<()>);
//~^ ERROR mismatched types
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/mismatched_types/normalize-fn-sig.rs
trait Foo {
type Bar;
}
<|fim_middle|>impl<T> Foo for T {
type Bar = i32;
}
fn foo<T>(_: <T as Foo>::Bar, _: &'static <T as Fo... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/mismatched_types/normalize-fn-sig.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> needs_i32_ref_fn(foo::<()>);
//~^ ERROR mismatched types
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/mismatched_types/normalize-fn-sig.rs
trait Foo {
type Bar;
}
impl<T> Foo for T {
type Bar = i32;
}
fn foo<T>(_: <T as Foo>::Bar, _: &'static <T as Foo>::Bar) {}
fn needs_i32_... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/mismatched_types/normalize-fn-sig.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.deps.clone()
}
}
pub fn create_test_sandbox(uses: Vec<String>) -> ComponentV1Manifest {
ComponentV1Manifest {
dev: None,
services: Some(uses),
system: None,
pkgfs: None,
features: None,
}
}
/// Create component manifest v1 (cmx) entries.
p... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/core/package/test_utils.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/security/lib/scrutiny/plugins/src/core/package/test_utils.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::core::{
package::... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/security/lib/scrutiny/plugins/src/core/package/test_utils.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wonism/Rocket path: /lib/src/handler.rs
//! The types of request and error handlers and their return values.
use data::Data;
use request::Request;
use response::{self, Response, Responder};
use error::Error;
use http::Status;
use outcome;
<|fim_suffix|> #[inline(always)]
pub fn failure(... | code_fim | hard | {
"lang": "rust",
"repo": "wonism/Rocket",
"path": "/lib/src/handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The type of an error handler.
pub type ErrorHandler = for<'r> fn(Error, &'r Request) -> response::Result<'r>;<|fim_prefix|>// repo: wonism/Rocket path: /lib/src/handler.rs
//! The types of request and error handlers and their return values.
use data::Data;
use request::Request;
use response::{self, ... | code_fim | hard | {
"lang": "rust",
"repo": "wonism/Rocket",
"path": "/lib/src/handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO(bryce): See what changes need to be done to Priority
pub fn get_global_queue(identifier: Priority, flags: isize) -> Queue {
unsafe {
dispatch_get_global_queue(identifier, flags)
}
}
}
}<|fim_prefix|>// repo: Bryce-MW/SMTA path: /... | code_fim | medium | {
"lang": "rust",
"repo": "Bryce-MW/SMTA",
"path": "/src/platform/macos/frameworks/adapters/system.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bryce-MW/SMTA path: /src/platform/macos/frameworks/adapters/system.rs
pub mod dispatch {
use super::super::super::system::dispatch;
use dispatch::DispatchObject;
pub mod queue {
use super::*;
use dispatch::queue::*;
<|fim_suffix|> // TODO(bryce): See what chan... | code_fim | medium | {
"lang": "rust",
"repo": "Bryce-MW/SMTA",
"path": "/src/platform/macos/frameworks/adapters/system.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Istar-Eldritch/courses path: /algorithmic_toolbox/week3_greedy_algorithms/3_maximum_advertisement_revenue/src/main.rs
fn parse(input: &String) -> Vec<i64> {
input
.split_whitespace()
.map(|c| c.parse().unwrap())
.collect()
}
<|fim_suffix|> println!("{}", max_permu... | code_fim | hard | {
"lang": "rust",
"repo": "Istar-Eldritch/courses",
"path": "/algorithmic_toolbox/week3_greedy_algorithms/3_maximum_advertisement_revenue/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn exercise_examples() {
assert_eq!(max_permutation(1, &mut vec![23], &mut vec![39]), 897);
assert_eq!(
max_permutation(3, &mut vec![1, 3, -5], &mut vec![-2, 4, 1]),
23
)
}
}<|fim_prefix|>// repo: Istar-Eldritch/courses path: /algorithmi... | code_fim | hard | {
"lang": "rust",
"repo": "Istar-Eldritch/courses",
"path": "/algorithmic_toolbox/week3_greedy_algorithms/3_maximum_advertisement_revenue/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: joseluis/soloud-rs path: /soloud-sys/src/lib.rs
#![no_std]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
<|fim_middle|>pub mod soloud;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
| code_fim | medium | {
"lang": "rust",
"repo": "joseluis/soloud-rs",
"path": "/soloud-sys/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joseluis/soloud-rs path: /soloud-sys/src/lib.rs
#![no_std]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
pub mod soloud;
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_middle|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "joseluis/soloud-rs",
"path": "/soloud-sys/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matthiasn/sled path: /tests/test_log.rs
#![cfg(test)]
#![allow(unused)]
extern crate quickcheck;
extern crate rand;
extern crate sled;
use std::fs;
use std::thread;
use std::sync::Arc;
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
use quickcheck::{Arbitrary, Gen, QuickChe... | code_fim | hard | {
"lang": "rust",
"repo": "matthiasn/sled",
"path": "/tests/test_log.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> static COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
let mut incr =
|| vec![COUNTER.fetch_add(1, Ordering::Relaxed) as u8; thread_rng().gen_range(0, 2)];
let choice = g.gen_range(0, 5);
match choice {
0 => Op::Write(incr()),
1 => Op::Write... | code_fim | hard | {
"lang": "rust",
"repo": "matthiasn/sled",
"path": "/tests/test_log.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 335g/rustiff path: /src/lib.rs
extern crate byteorder;
extern crate lzw;
#[macro_use] extern crate failure;
<|fim_suffix|>pub use decode::Decoder;
pub use ifd::IFD;
pub use error::{
DecodeError,
DecodeErrorKind,
DecodeResult,
};
pub use image::{
Image,
ImageData,
ImageH... | code_fim | medium | {
"lang": "rust",
"repo": "335g/rustiff",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use decode::Decoder;
pub use ifd::IFD;
pub use error::{
DecodeError,
DecodeErrorKind,
DecodeResult,
};
pub use image::{
Image,
ImageData,
ImageHeader,
ImageHeaderError,
Compression,
BitsPerSample,
BitsPerSampleError,
PhotometricInterpretation,
};<|fim_prefix... | code_fim | medium | {
"lang": "rust",
"repo": "335g/rustiff",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yishn/adventofcode path: /2019/08.rs
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashMap;
type Layer = HashMap<(usize, usize), u8>;
struct LayerIter<T: Iterator<Item = u8>> {
pixels: T,
width: usize,
height: usize
}
impl<T: Iterator<Item = u8>> Iterator for LayerIt... | code_fim | hard | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2019/08.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = get_input().unwrap();
let width = 25;
let height = 6;
let (_, ones, twos) = parse_layers(&input, width, height)
.map(|layer| {
layer.iter()
.filter_map(|(_, &pixel)| match pixel {
0 => Some((1, 0, 0)),
1 => Some((0, 1, 0)),
2 => Some((0, 0, 1)),... | code_fim | hard | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2019/08.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samlet/bluecc path: /sectors/hello-world/client.rs
use crate::hello_world_capnp::hello_world;
use capnp_rpc::{rpc_twoparty_capnp, twoparty, RpcSystem};
use std::net::ToSocketAddrs;
use futures::AsyncReadExt;
use futures::FutureExt;
pub async fn main() -> Result<(), Box<dyn std::error::Error>>... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/sectors/hello-world/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::task::LocalSet::new().run_until(async move {
let stream = tokio::net::TcpStream::connect(&addr).await?;
stream.set_nodelay(true)?;
let (reader, writer) = tokio_util::compat::TokioAsyncReadCompatExt::compat(stream).split();
let rpc_network = Box::new(twoparty::Vat... | code_fim | medium | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/sectors/hello-world/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//Equality by address
impl<T> PartialEq for WRCell<T> {
fn eq(&self, other: &Self) -> bool {
Rc::ptr_eq(&self.w.upgrade().unwrap(), &other.w.upgrade().unwrap())
}
}
impl<T> Eq for WRCell<T> {}
//Hash by address
impl<T: Hash + 'static> Hash for WRCell<T> {
fn hash<H: Hasher>(&self, st... | code_fim | hard | {
"lang": "rust",
"repo": "tajmone/pomelo",
"path": "/pomelo-impl/src/parser/wrc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let w = RCell::downgrade(&rc);
WRCell { w }
}
}
impl<T> WRCell<T> {
pub fn upgrade(&self) -> RCell<T> {
self.w.upgrade().unwrap()
}
pub fn borrow(&self) -> RCellRef<T> {
let p = self.w.upgrade().unwrap();
let raw = &*p as *const RefCell<T>;
... | code_fim | hard | {
"lang": "rust",
"repo": "tajmone/pomelo",
"path": "/pomelo-impl/src/parser/wrc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tajmone/pomelo path: /pomelo-impl/src/parser/wrc.rs
use std::rc::{Rc, Weak};
use std::cell::{RefCell, Ref, RefMut};
use std::hash::{Hash, Hasher};
//A reference-counted RefCell
pub type RCell<T> = Rc<RefCell<T>>;
//Like Weak<RefCell>, but cannot be null
#[derive(Debug)]
pub struct WRCell<T> {
... | code_fim | hard | {
"lang": "rust",
"repo": "tajmone/pomelo",
"path": "/pomelo-impl/src/parser/wrc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
reflector: &mut TSerializationReflector,
) -> std::io::Result<()> {
reflector.reflect_i32(&mut self.complication_level)?;
reflector.reflect_i32(&mut self.mana_cost)?;
reflector.reflect_i32(&mut self.sphere)?;
reflector.reflect_i32(&mut self.it... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rom-loaders-rs",
"path": "/src/data_bin/spell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rom-loaders-rs path: /src/data_bin/spell.rs
use crate::data_bin::section::{SectionDefinition};
use std::io::{Seek, Read};
use crate::shared_types::CP866String;
use bin_serialization_rs::{Reflectable, SerializationReflector, Endianness};
use crate::stream_utils::read_corrected_entry_count... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rom-loaders-rs",
"path": "/src/data_bin/spell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kstep/rust-scripts path: /src/bin/lostfilm-check.rs.in
#[derive(Deserialize)]
struct Config {
include: Vec<String>,
<|fim_suffix|> download_dir: Option<String>,
}
#[derive(Deserialize)]
struct PbConfig {
access_token: String,
device_iden: Option<String>,
}<|fim_middle|> exclude... | code_fim | medium | {
"lang": "rust",
"repo": "kstep/rust-scripts",
"path": "/src/bin/lostfilm-check.rs.in",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Config {
access_token: String,
device_iden: Option<String>,
}<|fim_prefix|>// repo: kstep/rust-scripts path: /src/bin/lostfilm-check.rs.in
#[derive(Deserialize)]
struct Config {
include: Vec<String>,
<|fim_middle|> exclude: Vec<String>,
username: String,
password: String,
downl... | code_fim | medium | {
"lang": "rust",
"repo": "kstep/rust-scripts",
"path": "/src/bin/lostfilm-check.rs.in",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twe4ked/rustdoc-cli path: /src/main.rs
//! Top level docs.
use std::error::Error;
use std::fmt::{self, Write};
use std::fs;
use std::io::Read;
use proc_macro2::TokenTree;
use pulldown_cmark::{Event, Options, Parser, Tag};
use syn::visit::{self, Visit};
use syn::{AttrStyle, Attribute, ItemFn, I... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/rustdoc-cli",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> visit::visit_item_mod(self, node);
}
}
/// This is just a test module to use for formatting!
mod foo {
#[allow(dead_code)]
/// BAR is the answer to the universe and everything.
///
/// ## Examples
///
/// Fenced block example:
///
/// ```should_panic
/// f... | code_fim | hard | {
"lang": "rust",
"repo": "twe4ked/rustdoc-cli",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/packed_simd_2/src/api/reductions/mask.rs
/
/
!
Implements
portable
horizontal
mask
reductions
.
macro_rules
!
impl_reduction_mask
{
(
[
elem_ty
:
ident
;
elem_count
:
expr
]
:
id
:
ident
|
test_tt
:
tt
)
=
>
{
impl
id
{
/
/
/
Are
all
vector
lan... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/packed_simd_2/src/api/reductions/mask.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sert
!
(
a
.
any
(
)
)
;
}
}
}
#
[
cfg_attr
(
not
(
target_arch
=
"
wasm32
"
)
test
)
]
#
[
cfg_attr
(
target_arch
=
"
wasm32
"
wasm_bindgen_test
)
]
fn
none
(
)
{
let
a
=
id
:
:
splat
(
true
)
;
assert
!
(
!
a
.
none
(
)
)
;
let
a
=
id
:
:
splat
(
false
)
;
assert
!
(
a
.
none
(
)
)
;
if
id
:
:
lanes
(
)... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/packed_simd_2/src/api/reductions/mask.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Bump::try_with_capacity(isize::MAX as usize + 1);
}<|fim_prefix|>// repo: fitzgen/bumpalo path: /tests/all/capacity.rs
use bumpalo::Bump;
#[test]
fn try_with_capacity_t<|fim_middle|>oo_large() {
// Shouldn't panic even though the capacity is too large for a `Layout`.
let _ = | code_fim | medium | {
"lang": "rust",
"repo": "fitzgen/bumpalo",
"path": "/tests/all/capacity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fitzgen/bumpalo path: /tests/all/capacity.rs
use bumpalo::Bump;
#[test]
fn try_with_capacity_too_large() {
// Shouldn't panic even though the<|fim_suffix|>Bump::try_with_capacity(isize::MAX as usize + 1);
}<|fim_middle|> capacity is too large for a `Layout`.
let _ = | code_fim | easy | {
"lang": "rust",
"repo": "fitzgen/bumpalo",
"path": "/tests/all/capacity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> capacity is too large for a `Layout`.
let _ = Bump::try_with_capacity(isize::MAX as usize + 1);
}<|fim_prefix|>// repo: fitzgen/bumpalo path: /tests/all/capacity.rs
use bumpalo::Bump;
#[test]
fn try_with_capacity_t<|fim_middle|>oo_large() {
// Shouldn't panic even though the | code_fim | easy | {
"lang": "rust",
"repo": "fitzgen/bumpalo",
"path": "/tests/all/capacity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let val = self.insts[self.pc as usize + param];
let param_mode = (operation as u32) / (10_u32.pow(param as u32 + 1)) % 10;
if addr {
return match param_mode {
0 => val,
2 => val + self.relative_base,
_ => panic!("Weird parameter in addr mode: {}", param_mode),
... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/intcode/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dhedegaard/adventofcode2019 path: /aoc2019/src/intcode/mod.rs
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum IntcodeState {
Halt,
Running,
NeedInput,
Output(i64),
}
#[derive(Debug)]
pub struct Intcode {
pub insts: Vec<i64>,
pc: i64,
pub state: IntcodeState,
pub inpu... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/intcode/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn execute(&mut self) -> IntcodeState {
loop {
let operation = self.insts[self.pc as usize];
let opcode = operation % 100;
match opcode {
1 => {
// Addition
let a = self.get_registry(operation, 1, false);
let b = self.get_registry(operation... | code_fim | hard | {
"lang": "rust",
"repo": "dhedegaard/adventofcode2019",
"path": "/aoc2019/src/intcode/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dreamykass/chilimak path: /common/src/parser/mod.rs
use crate::ast::Definition;
use crate::lexer::token::Token;
use lalrpop_util::lalrpop_mod;
<|fim_suffix|>pub fn parse(tokens: &[Token]) -> Result<Vec<Definition>, ParserError> {
let tokens: Vec<(usize, Token, usize)> = tokens
.iter... | code_fim | medium | {
"lang": "rust",
"repo": "Dreamykass/chilimak",
"path": "/common/src/parser/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn parse(tokens: &[Token]) -> Result<Vec<Definition>, ParserError> {
let tokens: Vec<(usize, Token, usize)> = tokens
.iter()
.cloned()
.map(|t| (0usize, t, 0usize))
.collect();
grammar::DefinitionListParser::new().parse(tokens)
}<|fim_prefix|>// repo: Dreamykass... | code_fim | medium | {
"lang": "rust",
"repo": "Dreamykass/chilimak",
"path": "/common/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if id.is_empty() {
Err(syn::Error::new(
lit.span(),
"Expected package name to not be empty.",
))
} else {
Ok(Self { id })
}
}
}
impl ToTokens for IncludeProto {
fn to_tokens(&self, tokens: &mut TokenStream... | code_fim | medium | {
"lang": "rust",
"repo": "googleforgames/quilkin",
"path": "/macros/src/include.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: googleforgames/quilkin path: /macros/src/include.rs
/*
* Copyright 2021 Google LLC
*
* 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 the License at
*
* http://www.apache.org... | code_fim | hard | {
"lang": "rust",
"repo": "googleforgames/quilkin",
"path": "/macros/src/include.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lit = input.parse::<syn::LitStr>()?;
let id = lit.value();
if id.is_empty() {
Err(syn::Error::new(
lit.span(),
"Expected package name to not be empty.",
))
} else {
Ok(Self { id })
}
}
}
i... | code_fim | medium | {
"lang": "rust",
"repo": "googleforgames/quilkin",
"path": "/macros/src/include.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/703_kth_largest_el.rs
use std::collections::BinaryHeap;
struct KthLargest {
k: usize,
heap: BinaryHeap<i32>,
}
/**
* `&self` means the method takes an immutable reference.
* If you need a mutable reference, change it to `&mut self` instead.
*... | code_fim | medium | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/703_kth_largest_el.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut heap: BinaryHeap<i32> = BinaryHeap::new();
let k = k as usize;
let mut s = Self {
k, heap,
};
for i in nums {
s.push(i);
}
s
}
fn push(&mut self, val: i32) {
let mut heap = &mut self.heap;
if he... | code_fim | medium | {
"lang": "rust",
"repo": "HerringtonDarkholme/leetcode",
"path": "/src/703_kth_largest_el.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let future = previous_frame_end
.join(acquire_future)
.then_execute(self.queue.clone(), command_buffer)
.unwrap()
.then_swapchain_present(self.queue.clone(), self.swapchain.clone(), image_num)
.then_signal_fence_an... | code_fim | hard | {
"lang": "rust",
"repo": "awoimbee/fractol_rust",
"path": "/src/vk_render/loop_render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awoimbee/fractol_rust path: /src/vk_render/loop_render.rs
use crate::vk_render::*;
use std::sync::{Arc, Mutex};
use vulkano::command_buffer::AutoCommandBufferBuilder;
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::swapchain;
use vulkano::swapchain::AcquireError;
u... | code_fim | hard | {
"lang": "rust",
"repo": "awoimbee/fractol_rust",
"path": "/src/vk_render/loop_render.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yangshifu1024/learning-rust path: /examples/array.rs
#![feature(inclusive_range_syntax)]
pub fn main() {
let arr1: [i32; 3] = [0; 3]<|fim_suffix|>!("arr2: {:?} arr2[1..]: {:?} arr2[1..2]: {:?} arr2[1...2]: {:?}",
arr2,
&arr2[1..],
&arr2[1..2],
... | code_fim | medium | {
"lang": "rust",
"repo": "Yangshifu1024/learning-rust",
"path": "/examples/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>!("arr2: {:?} arr2[1..]: {:?} arr2[1..2]: {:?} arr2[1...2]: {:?}",
arr2,
&arr2[1..],
&arr2[1..2],
&arr2[1...2]);
}<|fim_prefix|>// repo: Yangshifu1024/learning-rust path: /examples/array.rs
#![feature(inclusive_range_syntax)]
pub fn main() {
let arr... | code_fim | medium | {
"lang": "rust",
"repo": "Yangshifu1024/learning-rust",
"path": "/examples/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>2,
&arr2[1..],
&arr2[1..2],
&arr2[1...2]);
}<|fim_prefix|>// repo: Yangshifu1024/learning-rust path: /examples/array.rs
#![feature(inclusive_range_syntax)]
pub fn main() {
let arr1: [i32; 3] = [0; 3]<|fim_middle|>;
println!("arr1: {:?}", arr1);
let arr2:... | code_fim | medium | {
"lang": "rust",
"repo": "Yangshifu1024/learning-rust",
"path": "/examples/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn error(&mut self, reason: impl AsRef<str>) {
let offset = self.original_len - self.remaining.len();
self.errors.borrow_mut().push(format!("offset 0x{:x}: {}", offset, reason.as_ref()));
}
pub(crate) fn skip(&mut self, n: usize) {
self.remaining = self.rema... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/yet-another-bad-wasm-interpreter",
"path": "/src/decoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaulingMonkey/yet-another-bad-wasm-interpreter path: /src/decoder.rs
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone)]
pub struct Decoder<'b> {
pub(crate) original_len: usize,
pub(crate) remaining: &'b [u8],
pub(crate) errors: Rc<RefCell<Vec<String>>>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/yet-another-bad-wasm-interpreter",
"path": "/src/decoder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arthamys/rust-json-api path: /src/unit_tests.rs
use diesel::PgConnection;
use std::sync::Mutex;
use crate::rocket;
use rocket::local::Client;
use rocket::http::{Status, ContentType};
// we use a mutex to synchronize the tests, so that they don't
// override the correct state of the database dur... | code_fim | hard | {
"lang": "rust",
"repo": "Arthamys/rust-json-api",
"path": "/src/unit_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client = Client::new(rocket()).expect("valid rocket instance");
let _lock = DB_LOCK.lock();
let db_conn = super::repository::DbConn::get_one(&rocket()).expect("could not connect to database");
clear_documents(&db_conn.0);
let response = client.post("/documents/new_document")
... | code_fim | hard | {
"lang": "rust",
"repo": "Arthamys/rust-json-api",
"path": "/src/unit_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmijatovic/rust-api-bench path: /actix-gql/src/graphql/mod.rs
use crate::db::Pool;
use juniper::RootNode;
<|fim_suffix|>pub use model::{NewTodoItem, TodoItem, TodoList};
pub type Schema = RootNode<'static, QueryRoot, MutationRoot>;
pub fn create_schema() -> Schema {
Schema::new(QueryRoot {}... | code_fim | hard | {
"lang": "rust",
"repo": "dmijatovic/rust-api-bench",
"path": "/actix-gql/src/graphql/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use model::{NewTodoItem, TodoItem, TodoList};
pub type Schema = RootNode<'static, QueryRoot, MutationRoot>;
pub fn create_schema() -> Schema {
Schema::new(QueryRoot {}, MutationRoot {})
}<|fim_prefix|>// repo: dmijatovic/rust-api-bench path: /actix-gql/src/graphql/mod.rs
use crate::db::Pool;
use ... | code_fim | medium | {
"lang": "rust",
"repo": "dmijatovic/rust-api-bench",
"path": "/actix-gql/src/graphql/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biluohc/app path: /src/elesref.rs
#[derive(Debug)]
struct ElesRef<'e, T: 'e> {
raw: &'e [T],
start: usize,
end: usize,
is_reverse: bool,
}
impl<'e, T: Clone + std::fmt::Debug> ElesRef<'e, T> {
fn new<'l: 'e>(slice: &'l [T]) -> Self {
ElesRef {
raw: slice,
... | code_fim | hard | {
"lang": "rust",
"repo": "biluohc/app",
"path": "/src/elesref.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (rg0, rg1) = rg.into().into_range(self.start, self.end, self.is_reverse);
self.check(&rg0, &rg1);
self.start = rg0;
self.end = rg1;
}
#[inline]
fn check(&self, rg0: &usize, rg1: &usize) {
if rg0 > rg1 {
panic!("slice index starts at {} bu... | code_fim | hard | {
"lang": "rust",
"repo": "biluohc/app",
"path": "/src/elesref.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: warpforge/warpgrapher path: /tests/node_scalar_resolver_test.rs
mod setup;
use assert_approx_eq::assert_approx_eq;
use serde_json::json;
#[cfg(feature = "cypher")]
use setup::cypher_test_client;
#[cfg(feature = "gremlin")]
use setup::gremlin_test_client;
#[cfg(any(feature = "gremlin", feature =... | code_fim | hard | {
"lang": "rust",
"repo": "warpforge/warpgrapher",
"path": "/tests/node_scalar_resolver_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(client
.create_node(
"TestType",
"float_list",
&json!({
"float_list": [0.0, 1.1, 2.2, 3.3],
}),
None
)
.await
.is_err());
}
#[cfg(feature = "gremlin")]
#[tokio::test]
async fn scalar_no... | code_fim | hard | {
"lang": "rust",
"repo": "warpforge/warpgrapher",
"path": "/tests/node_scalar_resolver_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: igncp/environment path: /src/common_provision/general/taskwarrior.rs
use std::path::Path;
use crate::base::{system::System, Context};
pub fn setup_taskwarrior(context: &mut Context) {
context
.system
.install_system_package("taskwarrior", Some("task"));
let task_file =... | code_fim | hard | {
"lang": "rust",
"repo": "igncp/environment",
"path": "/src/common_provision/general/taskwarrior.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context.files.append(
&context.system.get_home_path(".zshrc"),
r###"
source "$HOME"/.oh-my-zsh/plugins/taskwarrior/taskwarrior.plugin.zsh
"###,
);
}<|fim_prefix|>// repo: igncp/environment path: /src/common_provision/general/taskwarrior.rs
use std::path::Path;
use crate::base::{s... | code_fim | hard | {
"lang": "rust",
"repo": "igncp/environment",
"path": "/src/common_provision/general/taskwarrior.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daylight1019/darkwebb-substrate path: /primitives/src/types.rs
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use frame_support::pallet_prelude::*;
use scale_info::TypeInfo;
// Deposit details used in hasher / verifier pallets for
// tracking the reserved deposits of ma... | code_fim | hard | {
"lang": "rust",
"repo": "daylight1019/darkwebb-substrate",
"path": "/primitives/src/types.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, Encode, Decode, PartialEq, TypeInfo)]
pub struct Setup {
pub hasher: HashFunction,
pub backend: Backend,
}<|fim_prefix|>// repo: daylight1019/darkwebb-substrate path: /primitives/src/types.rs
#![cfg_attr(not(feature = "std"), no_std)]
use cod... | code_fim | hard | {
"lang": "rust",
"repo": "daylight1019/darkwebb-substrate",
"path": "/primitives/src/types.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suren-m/azure-sdk-for-rust path: /services/mgmt/workloadmonitor/src/package_2020_01_13_preview/models.rs
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize... | code_fim | hard | {
"lang": "rust",
"repo": "suren-m/azure-sdk-for-rust",
"path": "/services/mgmt/workloadmonitor/src/package_2020_01_13_preview/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[serde(skip_serializing_if = "Vec::is_empty")]
pub value: Vec<Operation>,
#[serde(rename = "nextLink", skip_serializing_if = "Option::is_none")]
pub next_link: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Operation {
pub name: String,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "suren-m/azure-sdk-for-rust",
"path": "/services/mgmt/workloadmonitor/src/package_2020_01_13_preview/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
IT'S TIME FOR SOME LOOPS
*/
let mut counter = 0;
let result = loop {
counter += 1;
if counter == 10 {
break counter * 3;
}
};
println!("\nResult is: {}", result);
// While loop
let mut countdown = 3;
while countdown != ... | code_fim | hard | {
"lang": "rust",
"repo": "creativeJoe007/my_rusty",
"path": "/control_flow/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: creativeJoe007/my_rusty path: /control_flow/src/main.rs
fn main() {
let number = 8;
let condition = true;
let y = if condition { 4 } else { 7 };
println!("Hello, world! see y {}", y);
// if operations
if number % 5 == 0 {
println!("number is divisible by 5");
... | code_fim | medium | {
"lang": "rust",
"repo": "creativeJoe007/my_rusty",
"path": "/control_flow/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while index < collection.len() {
println!("{}! ", collection[index]);
index += 1;
}
// Making use of For loop
for number in collection.iter() {
println!("The value is: {}", number);
}
// Using For loop to loop a range
for number in (1..4).rev() {
... | code_fim | hard | {
"lang": "rust",
"repo": "creativeJoe007/my_rusty",
"path": "/control_flow/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut seen = vec![false; n];
let mut cur = x - 1;
seen[cur] = true;
loop {
cur = a[cur] - 1;
if seen[cur] {
break;
}
seen[cur] = true;
}
let mut ans = 0;
for i in 0..n {
if seen[i] {
ans += 1;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc228/src/bin/b/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ia7ck/competitive-programming path: /AtCoder/abc228/src/bin/b/main.rs
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
<|fim_suffix|> let (n, x) = scan!((usize, usize));
let a = scan!(usize; n);
... | code_fim | hard | {
"lang": "rust",
"repo": "ia7ck/competitive-programming",
"path": "/AtCoder/abc228/src/bin/b/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl TypeInfo for #name {
const TYPENAME : &'static str = stringify!(#name);
}
};
TokenStream::from(tokens)
}<|fim_prefix|>// repo: karimElmougi/Simumo path: /simulator/extern/typeinfo_derive/src/lib.rs
extern crate proc_macro;
extern crate quote;
extern crate syn;
<|... | code_fim | hard | {
"lang": "rust",
"repo": "karimElmougi/Simumo",
"path": "/simulator/extern/typeinfo_derive/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: karimElmougi/Simumo path: /simulator/extern/typeinfo_derive/src/lib.rs
extern crate proc_macro;
extern crate quote;
extern crate syn;
<|fim_suffix|> impl TypeInfo for #name {
const TYPENAME : &'static str = stringify!(#name);
}
};
TokenStream::from(tokens)
}<|... | code_fim | hard | {
"lang": "rust",
"repo": "karimElmougi/Simumo",
"path": "/simulator/extern/typeinfo_derive/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msimms/LibMath path: /rust/src/statistics.rs
// MIT License
//
// Copyright © 2018 Michael J Simms. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the ... | code_fim | hard | {
"lang": "rust",
"repo": "msimms/LibMath",
"path": "/rust/src/statistics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn standard_deviation_f64(data: &Vec<f64>, mean: f64) -> f64 {
let var = variance_f64(data, mean);
let std_dev = var.sqrt();
std_dev
}
pub fn max_f32(data: &Vec<f32>) -> f32 {
let mut result = data[0];
for item in data {
if *item > result {
result = *item;... | code_fim | hard | {
"lang": "rust",
"repo": "msimms/LibMath",
"path": "/rust/src/statistics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kofmatsugen/fight_game path: /src/bundle.rs
mod collision;
mod paramater;
mod transfo<|fim_suffix|>le;
pub use paramater::FightParamaterBundle;
pub use transform::FightTransformBundle;<|fim_middle|>rm;
pub use collision::FightCollisionBund | code_fim | easy | {
"lang": "rust",
"repo": "kofmatsugen/fight_game",
"path": "/src/bundle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kofmatsugen/fight_game path: /src/bundle.rs
mod collision;
mod paramater;
mod transform;
pub use collision::FightCollisionBund<|fim_suffix|>e;
pub use transform::FightTransformBundle;<|fim_middle|>le;
pub use paramater::FightParamaterBundl | code_fim | easy | {
"lang": "rust",
"repo": "kofmatsugen/fight_game",
"path": "/src/bundle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e;
pub use transform::FightTransformBundle;<|fim_prefix|>// repo: kofmatsugen/fight_game path: /src/bundle.rs
mod collision;
mod paramater;
mod transfo<|fim_middle|>rm;
pub use collision::FightCollisionBundle;
pub use paramater::FightParamaterBundl | code_fim | medium | {
"lang": "rust",
"repo": "kofmatsugen/fight_game",
"path": "/src/bundle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.