text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: synthVerity/Cricket path: /src/lib.rs
{
// score += view.score_stats();
// }
// score
// }
/// Returns a vector of optional worker scores. Scores are None when the worker could not
/// be reached
pub fn get_worker_scores(&self) -> Vec<Option<u64>> {
... | code_fim | hard | {
"lang": "rust",
"repo": "synthVerity/Cricket",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AFL {
/// Constructs a new AFL struct
/// # Example
/// ```rust
/// let opts = AFLOpts::new(..Default::default());
/// let afl = AFL::new(opts);
/// ```
pub fn new(opts: AFLOpts) -> AFL {
AFL {
instances: Vec::with_capacity(opts.instance_count),
... | code_fim | hard | {
"lang": "rust",
"repo": "synthVerity/Cricket",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> () {
app::main()
}<|fim_prefix|>// repo: libcala/cargo-cala path: /cargo-gsp/src/cargo/res/main.rs
// bin/res/main.rs
// Graphical Software Packager
// Copyright 2017 (c) Aldaron's Tech
// Copyright 2017 (c) Jeron Lau
// Licensed under the MIT LICENSE
#[macro_use]
extern crate window;
<|f... | code_fim | easy | {
"lang": "rust",
"repo": "libcala/cargo-cala",
"path": "/cargo-gsp/src/cargo/res/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libcala/cargo-cala path: /cargo-gsp/src/cargo/res/main.rs
// bin/res/main.rs
// Graphical Software Packager
// Copyright 2017 (c) Aldaron's Tech
// Copyright 2017 (c) Jeron Lau
// Licensed under the MIT LICENSE
<|fim_suffix|>pub use app::*;
fn main() -> () {
app::main()
}<|fim_middle|>#[macro... | code_fim | easy | {
"lang": "rust",
"repo": "libcala/cargo-cala",
"path": "/cargo-gsp/src/cargo/res/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn single_element_min_formatting() {
use flexpiler::Deserialize;
use flexpiler::common::reader;
let mut reader = reader::String::from(
"[AutomaticTestStruct{a_string:\"Hello\",a_i32:-34,a_usize:50,a_sub:AutomaticSubTestStruct{a_usize:67}}]"
);
let test_vec_automatic_te... | code_fim | hard | {
"lang": "rust",
"repo": "ErlanDumah/flexpiler",
"path": "/flexpiler_test/src/tests/automatic/test_struct/vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ErlanDumah/flexpiler path: /flexpiler_test/src/tests/automatic/test_struct/vec.rs
use super::AutomaticTestStruct;
#[test]
fn empty_min_formatting() {
use flexpiler::Deserialize;
use flexpiler::common::reader;
let mut reader = reader::String::from(
"[]"
);
let test_... | code_fim | hard | {
"lang": "rust",
"repo": "ErlanDumah/flexpiler",
"path": "/flexpiler_test/src/tests/automatic/test_struct/vec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parquette/arcolyte path: /src/ffi.rs
// //! The foreign function interface which exposes this library to non-Rust
// //! languages.
use std::ptr;
use std::slice;
use std::error::Error as StdError;
use std::cell::RefCell;
use libc::{c_char, c_int}; // , size_t};
//use std::ffi::CStr;
//use crat... | code_fim | hard | {
"lang": "rust",
"repo": "parquette/arcolyte",
"path": "/src/ffi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Write the most recent error message into a caller-provided buffer as a UTF-8
/// string, returning the number of bytes written.
///
/// # Note
///
/// This writes a **UTF-8** string into the buffer. Windows users may need to
/// convert it to a UTF-16 "unicode" afterwards.
///
/// If there are no rece... | code_fim | hard | {
"lang": "rust",
"repo": "parquette/arcolyte",
"path": "/src/ffi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in reader.lines() {
match line
{
Ok(s) => mc.feed_string(s),
Err(e) => return Err(e.into())
}
}
let boxed_mc = Box::new(mc);
Ok(boxed_mc)
}
}<|fim_prefix|>// repo: skrotnisse/smarkov path... | code_fim | hard | {
"lang": "rust",
"repo": "skrotnisse/smarkov",
"path": "/src/markovchainreader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skrotnisse/smarkov path: /src/markovchainreader.rs
use std::io;
use std::io::{prelude::*, BufReader};
use std::fs::File;
use super::markovchain::MarkovChain;
<|fim_suffix|> pub fn from_file(filepath: &String) -> Result<Box<MarkovChain>, io::Error>
{
let mut mc = MarkovChain::ne... | code_fim | hard | {
"lang": "rust",
"repo": "skrotnisse/smarkov",
"path": "/src/markovchainreader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use addr::Addr;
pub use async_trait::async_trait;
pub use body::Body;
pub use endpoint::{Endpoint, EndpointExt, IntoEndpoint};
pub use error::{Error, Result};
pub use middleware::Middleware;
pub use poem_derive::handler;
pub use request::{OnUpgrade, Request, RequestBuilder, RequestParts, Upgraded};
pu... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/poem/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: happysalada/poem path: /poem/src/lib.rs
//! Poem is a full-featured and easy-to-use web framework with the Rust
//! programming language.
//!
//! # Usage
//!
//! Depend on poem in Cargo.toml:
//!
//! ```toml
//! poem = "*"
//! ```
//!
//! # Example
//!
//! ```no_run
//! use poem::{get, handler, ... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/poem/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check if `cargo run` is able to execute the binary
p.cargo("run")
.masquerade_as_nightly_cargo(&["different-binary-name"])
.with_stdout("Hello, crabs!")
.run();
p.cargo("install")
.masquerade_as_nightly_cargo(&["different-binary-name"])
.run();
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/binary_name.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> [package]
name = "foo"
version = "0.0.1"
[[bin]]
name = "foo"
filename = "007bar"
path = "src/main.rs"
"#,
)
.file("src/main.rs", "fn main() { assert!(true) }")
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/binary_name.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/cargo path: /tests/testsuite/binary_name.rs
use cargo_test_support::install::{
assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
};
use cargo_test_support::project;
#[cargo_test]
fn gated() {
let p = project()
.file(
"Cargo.toml",
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/tests/testsuite/binary_name.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn xcb_record_get_context_intercepted_clients_length (R : *mut get_context_reply) -> c_int;
pub fn xcb_record_get_context_intercepted_clients_iterator (R : *mut get_context_reply) -> client_info_iterator;
/**
* Return the reply
* @param c The connection
* @param cookie The cookie
* @param e... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/record.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmiyaguchi/rust-xcb path: /src/ffi/record.rs
pub minor_opcode : u8,
pub length : u16,
pub context : context,
pub num_client_specs : u32
}
pub struct get_context_cookie {
sequence : c_uint
}
pub struct get_context_request {
pub maj... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/record.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmiyaguchi/rust-xcb path: /src/ffi/record.rs
amel_case_types)]
use std;
use libc::*;
use ffi;
pub static RECORD_MAJOR_VERSION : c_uint = 1;
pub static RECORD_MINOR_VERSION : c_uint = 13;
pub type context = u32;
/**
* @brief context_iterator
**/
pub struct context_iterator {
pub data : *... | code_fim | hard | {
"lang": "rust",
"repo": "acmiyaguchi/rust-xcb",
"path": "/src/ffi/record.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitermayer/rsocket-rust path: /rsocket/src/frame/utils.rs
use super::FLAG_METADATA;
use crate::utils::U24;
use bytes::{Buf, BufMut, Bytes, BytesMut};
pub(crate) struct PayloadSupport {}
<|fim_suffix|> pub fn write(bf: &mut BytesMut, metadata: &Option<Bytes>, data: &Option<Bytes>) {
... | code_fim | hard | {
"lang": "rust",
"repo": "mitermayer/rsocket-rust",
"path": "/rsocket/src/frame/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write(bf: &mut BytesMut, metadata: &Option<Bytes>, data: &Option<Bytes>) {
if let Some(v) = metadata {
let n = v.len() as u32;
U24::write(n, bf);
bf.put(v.bytes());
}
if let Some(v) = data {
bf.put(v.bytes())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mitermayer/rsocket-rust",
"path": "/rsocket/src/frame/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..INLINE_STRING_CAPACITY {
s.insert(0, 'a');
}
s.insert(0, 'a');
assert_eq!(
s,
String::from_iter((0..INLINE_STRING_CAPACITY + 1).map(|_| 'a'))
);
}
#[test]
fn test_insert_str() {
let mut s = Inlina... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/inlinable_string",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = <InlinableString as StringExt>::new();
StringExt::reserve_exact(&mut s, 100);
assert!(InlinableString::capacity(&s) >= 100);
}
#[test]
fn test_shrink_to_fit() {
let mut s = <InlinableString as StringExt>::with_capacity(100);
StringExt::push_... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/inlinable_string",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fitzgen/inlinable_string path: /src/lib.rs
core::iter;
use core::mem;
use core::ops;
use core::str::FromStr;
/// An owned, grow-able UTF-8 string that allocates short strings inline on the
/// stack.
///
/// See the [module level documentation](./index.html) for more.
#[derive(Clone, Eq)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "fitzgen/inlinable_string",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> $factor
}
}
};
}
planet!(Mercury, 0.2408467);
planet!(Venus, 0.61519726);
planet!(Earth, 1.0);
planet!(Mars, 1.8808158);
planet!(Jupiter, 11.862615);
planet!(Saturn, 29.447498);
planet!(Uranus, 84.016846);
planet!(Neptune, 164.79132);<|fim_prefix|>// repo: mhetrera... | code_fim | hard | {
"lang": "rust",
"repo": "mhetrerajat/ds-challenge",
"path": "/exercism/rust/space-age/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mhetrerajat/ds-challenge path: /exercism/rust/space-age/src/lib.rs
// The code below is a stub. Just enough to satisfy the compiler.
// In order to pass the tests you can add-to or change any of this code.
#[derive(Debug)]
pub struct Duration {
years_on_earth: f64,
}
impl From<u64> for Dur... | code_fim | medium | {
"lang": "rust",
"repo": "mhetrerajat/ds-challenge",
"path": "/exercism/rust/space-age/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! planet {
($planet_name:ident, $factor:expr) => {
pub struct $planet_name;
impl Planet for $planet_name {
fn period_factor() -> f64 {
$factor
}
}
};
}
planet!(Mercury, 0.2408467);
planet!(Venus, 0.61519726);
planet!(Earth... | code_fim | hard | {
"lang": "rust",
"repo": "mhetrerajat/ds-challenge",
"path": "/exercism/rust/space-age/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imccoy/advent-of-code-2019 path: /src/day12a.rs
use std::io::{self, BufRead};
#[derive(Clone,Debug)]
struct Velocity { x : i32, y : i32, z : i32 }
#[derive(Clone,Debug)]
struct Position { x : i32, y : i32, z : i32 }
#[derive(Clone,Debug)]
struct Moon { position: Position, velocity: Velocity }
... | code_fim | medium | {
"lang": "rust",
"repo": "imccoy/advent-of-code-2019",
"path": "/src/day12a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> moon_a.velocity.z += z_velocity;
moon_b.velocity.z -= z_velocity;
moons[moon_a_index] = moon_a;
moons[moon_b_index] = moon_b;
}
}
println!("After {:?} steps: ", step+1);
for mut moon in &mut moons {
... | code_fim | hard | {
"lang": "rust",
"repo": "imccoy/advent-of-code-2019",
"path": "/src/day12a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for step in (0..1000) {
for moon_a_index in (0..moons.len()) {
for moon_b_index in ((moon_a_index+1)..moons.len()) {
let mut moon_a = moons[moon_a_index].clone();
let mut moon_b = moons[moon_b_index].clone();
let x_velocity = velocity... | code_fim | hard | {
"lang": "rust",
"repo": "imccoy/advent-of-code-2019",
"path": "/src/day12a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ref_type: reference_type::ReferenceType = parts[0].parse()?;
Ok(ExternalReference(ref_type, parts[1].to_string()))
}
}
impl From<ExternalReference> for String {
fn from(raw: ExternalReference) -> String {
format!("{}:{}", raw.0, raw.1)
}
}<|fim_prefix|>// repo: RNA... | code_fim | medium | {
"lang": "rust",
"repo": "RNAcentral/rnacentral-import-pipeline",
"path": "/utils/rnc-core/src/publications/external_reference.rs",
"mode": "spm",
"license": "GPL-1.0-or-later",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RNAcentral/rnacentral-import-pipeline path: /utils/rnc-core/src/publications/external_reference.rs
use std::str::FromStr;
use thiserror::Error;
use crate::publications::reference_type;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ExternalReference(reference_type::ReferenceType, Str... | code_fim | hard | {
"lang": "rust",
"repo": "RNAcentral/rnacentral-import-pipeline",
"path": "/utils/rnc-core/src/publications/external_reference.rs",
"mode": "psm",
"license": "GPL-1.0-or-later",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jorendorff/cell-gc path: /tests/compile-fail/private_fields.rs
// Derived accessors that access private fields are private.
extern crate cell_gc;
#[macro_use] extern crate cell_gc_derive;
<|fim_suffix|> cell_gc::with_heap(|hs| {
let clade = flowers::Clade::new(hs, None, "Angiosperma... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/cell-gc",
"path": "/tests/compile-fail/private_fields.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cell_gc::with_heap(|hs| {
let clade = flowers::Clade::new(hs, None, "Angiospermae".to_string());
let parent = clade.supertype(); // error
//~^ ERROR: method `supertype` is private
clade.set_supertype(None); // error
//~^ ERROR: method `set_supertype` is privat... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/cell-gc",
"path": "/tests/compile-fail/private_fields.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Got a request: {:?}", request);
let mut tmp_items = Vec::new();
let reply = ListContainerStatsResponse {
stats: tmp_items
};
return reply;
}<|fim_prefix|>// repo: ruilkqun/masterwind path: /saodiseng/src/bin/server/v1alpha2/rpc_list_container_... | code_fim | medium | {
"lang": "rust",
"repo": "ruilkqun/masterwind",
"path": "/saodiseng/src/bin/server/v1alpha2/rpc_list_container_stats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruilkqun/masterwind path: /saodiseng/src/bin/server/v1alpha2/rpc_list_container_stats.rs
use tonic::Request;
use crate::v1alpha2::impl_struct::k8s_v1alpha2;
use k8s_v1alpha2::{ ListContainerStatsRequest,ListContainerStatsResponse };
<|fim_suffix|> println!("Got a request: {:?}", request... | code_fim | medium | {
"lang": "rust",
"repo": "ruilkqun/masterwind",
"path": "/saodiseng/src/bin/server/v1alpha2/rpc_list_container_stats.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbesraa/cracking-the-coding-interview path: /src/strings/index.rs
//Strings
// Q1
// Implement an algorithm to determine if a string has all unique chars.
use itertools::Itertools;
#[allow(dead_code)]
fn is_all_chars_unique(s: &str) -> bool {
let mut cpy: String = "".to_owned();
for c in s.... | code_fim | hard | {
"lang": "rust",
"repo": "jbesraa/cracking-the-coding-interview",
"path": "/src/strings/index.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn compressed_string() {
let s1 = "accbCdd";
assert_eq!(compress_string(s1), "a1c2b1C1d2");
}
#[test]
fn compressed_string2() {
let s1 = "aaa";
assert_eq!(compress_string(s1), "a3");
}
#[test]
fn compressed_string3() {
let s1 = "aacccbC";
assert_eq!(compress_string(s1), "a2c3b1... | code_fim | hard | {
"lang": "rust",
"repo": "jbesraa/cracking-the-coding-interview",
"path": "/src/strings/index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let word_length = char_vec.len();
for elm in char_vec.iter().take(word_length) {
if current_char == *elm {
current_count += 1;
continue;
}
result.push_str(&format!("{}{}", current_char, current_count));
current_char = *elm;
current_count = 1;
}
result.push_str(&format!("{}{}", current... | code_fim | hard | {
"lang": "rust",
"repo": "jbesraa/cracking-the-coding-interview",
"path": "/src/strings/index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TateKennington/AoC-2020 path: /Day 13/src/main.rs
use std::io::Read;
fn main() {
let mut stdin = std::io::stdin();
let mut input = String::default();
stdin.read_to_string(&mut input).unwrap();
let mut lines = input.lines();
let time: u64 = lines.next().unwrap().trim().parse... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/AoC-2020",
"path": "/Day 13/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mes {
if *curr == 0 {
continue;
}
if curr - (time % curr) < ans {
ans = curr - (time % curr);
id = *curr;
}
}
println!("{}", ans * id);
let mut curr = 1;
let mut ans: u64 = 0;
for i in 0..times.len() {
let time... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/AoC-2020",
"path": "/Day 13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec!["network", "parse"]
}
fn run(
&self,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(Value::String {
val: get_full_he... | code_fim | hard | {
"lang": "rust",
"repo": "CBenoit/nushell",
"path": "/crates/nu-command/src/network/url/url_.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CBenoit/nushell path: /crates/nu-command/src/network/url/url_.rs
use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Value,
};
#[derive(Clone)]
pub struct Url;
<|fim_suffix|> fn s... | code_fim | hard | {
"lang": "rust",
"repo": "CBenoit/nushell",
"path": "/crates/nu-command/src/network/url/url_.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/vendor/miniscript/src/miniscript/types/extra_props.rs
+ 6,
has_free_verify: true,
ops: OpLimits::new(4, Some(0), Some(0)),
stack_elem_count_sat: Some(1),
stack_elem_count_dissat: Some(1),
... | code_fim | hard | {
"lang": "rust",
"repo": "digitalbitbox/bitbox02-firmware",
"path": "/src/rust/vendor/miniscript/src/miniscript/types/extra_props.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn from_hash256() -> Self {
ExtData {
pk_cost: 33 + 6,
has_free_verify: true,
ops: OpLimits::new(4, Some(0), Some(0)),
stack_elem_count_sat: Some(1),
stack_elem_count_dissat: Some(1),
max_sat_size: Some((33, 33)),
... | code_fim | hard | {
"lang": "rust",
"repo": "digitalbitbox/bitbox02-firmware",
"path": "/src/rust/vendor/miniscript/src/miniscript/types/extra_props.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: g-s-k/bzz path: /src/error.rs
use std::any::Any;
use std::io;
#[derive(Debug)]
pub enum Error {
IO(io::Error),
Thread(Box<Any + Send>),
}
<|fim_suffix|>impl From<Box<dyn Any + Send>> for Error {
fn from(err: Box<dyn Any + Send>) -> Self {
Error::Thread(err)
}
}<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "g-s-k/bzz",
"path": "/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::IO(err)
}
}
impl From<Box<dyn Any + Send>> for Error {
fn from(err: Box<dyn Any + Send>) -> Self {
Error::Thread(err)
}
}<|fim_prefix|>// repo: g-s-k/bzz path: /src/error.rs
use std::any::Any;
use std::io;
#[derive(Debug)]
pub enum Error {
IO(io::Error),
Threa... | code_fim | medium | {
"lang": "rust",
"repo": "g-s-k/bzz",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/prisma-engines path: /libs/native-types/src/mssql.rs
use serde::*;
use serde_json::Value;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Copy)]
pub enum DataLength {
Limited(u16),
Max,
}
impl fmt::Display for DataLength {
fn fmt(&self, f: &mut fmt:... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/prisma-engines",
"path": "/libs/native-types/src/mssql.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum MssqlType {
TinyInt,
SmallInt,
Int,
BigInt,
Decimal(u8, u8),
Numeric(u8, u8),
Money,
SmallMoney,
Bit,
Float(u8),
Real,
Date,
Time,
Datetime,
Datetime2,
DatetimeOffset,
Sm... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/prisma-engines",
"path": "/libs/native-types/src/mssql.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Calculates the Spherical Phi (φ) from a **normalised** `Vector3f`.
#[inline(always)]
pub fn spherical_phi(v: Vector3f) -> Float {
let p = v.y.atan2(v.x);
if p < 0.0 { p + float(2.0) * Float::pi() } else { p }
}<|fim_prefix|>// repo: callym/pbrst path: /pbrt/src/math/radiometry.rs
use num;
use... | code_fim | medium | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/src/math/radiometry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: callym/pbrst path: /pbrt/src/math/radiometry.rs
use num;
use crate::prelude::*;
#[inline(always)]
pub fn spherical_direction(sin: Float, cos: Float, phi: Float) -> Vector3f {
Vector3f::new(sin * phi.cos() , sin * phi.sin(), cos)
}
<|fim_suffix|>/// Calculates the Spherical Theta (θ) from a... | code_fim | hard | {
"lang": "rust",
"repo": "callym/pbrst",
"path": "/pbrt/src/math/radiometry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parsed_timezone: Tz = timezone.parse().ok()?;
let role_id_num: u64 = role_id.parse().ok()?;
Some(LocationRole {
role_id: RoleId(role_id_num),
timezone: parsed_timezone,
})
}
pub fn role_id(&self) -> RoleId {
self.role_id
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ecthros/discord-server-manager",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn location_roles(&self) -> &HashSet<LocationRole> {
&self.location_roles
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LocationRole {
role_id: RoleId,
timezone: Tz,
}
impl LocationRole {
fn new(role_id: &str, timezone: &str) -> Option<LocationRole> {
... | code_fim | hard | {
"lang": "rust",
"repo": "ecthros/discord-server-manager",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecthros/discord-server-manager path: /src/config.rs
use std::{collections::HashSet, env};
use chrono_tz::Tz;
use log::debug;
use serenity::model::id::RoleId;
#[derive(Debug, Clone)]
pub struct Config {
bot_token: String,
location_roles: HashSet<LocationRole>,
}
impl Config {
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "ecthros/discord-server-manager",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danclive/sincere path: /src/http/mod.rs
pub use self::request::Request;
pub use self::response::Response;
pub use hyper::{header, HeaderMap, Method};
pub use hyper::body::Bytes;
<|fim_suffix|>pub mod mime {
pub use mime::*;
}<|fim_middle|>pub mod plus;
mod request;
mod response;
mod status_... | code_fim | easy | {
"lang": "rust",
"repo": "danclive/sincere",
"path": "/src/http/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod mime {
pub use mime::*;
}<|fim_prefix|>// repo: danclive/sincere path: /src/http/mod.rs
pub use self::request::Request;
pub use self::response::Response;
pub use hyper::{header, HeaderMap, Method};
pub use hyper::body::Bytes;
<|fim_middle|>pub mod plus;
mod request;
mod response;
mod status_... | code_fim | easy | {
"lang": "rust",
"repo": "danclive/sincere",
"path": "/src/http/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os/zCore path: /zCore/src/main.rs
#![cfg_attr(not(feature = "libos"), no_std)]
#![deny(warnings)]
#![no_main]
#![feature(naked_functions, asm_sym, asm_const)]
#![feature(default_alloc_error_handler)]
use core::sync::atomic::{AtomicBool, Ordering};
extern crate alloc;
#[macro_use]
extern ... | code_fim | hard | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/zCore/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(any(feature = "libos", target_arch = "aarch64")))]
fn secondary_main() -> ! {
while !STARTED.load(Ordering::SeqCst) {
core::hint::spin_loop();
}
kernel_hal::secondary_init();
info!("hart{} inited", kernel_hal::cpu::cpu_id());
#[cfg(feature = "mock-disk")]
{
... | code_fim | hard | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/zCore/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akubera/bigdecimal-rs path: /src/lib.tests.double.rs
// Test BigDecimal::double
macro_rules! impl_case {
($name:ident : $a:literal => $ex:literal ) => {
paste! {
#[test]
fn $name() {
<|fim_suffix|>impl_case!(case_zero : "0" => "0");
impl_case!(case_1 : "1" =>... | code_fim | hard | {
"lang": "rust",
"repo": "akubera/bigdecimal-rs",
"path": "/src/lib.tests.double.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl_case!(case_zero : "0" => "0");
impl_case!(case_1 : "1" => "2");
impl_case!(case_100Em2 : "1.00" => "2.00");
impl_case!(case_150Em2 : "1.50" => "3.00");
impl_case!(case_neg150Em2 : "-1.50" => "-3.00");
impl_case!(case_32909E4 : "32909E4" => "6.5818E+8");
impl_case!(case_1_1156024145937225657484 : "1.1... | code_fim | hard | {
"lang": "rust",
"repo": "akubera/bigdecimal-rs",
"path": "/src/lib.tests.double.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SnakeSolid/rust-database-monitor path: /src/search/query.rs
use super::SEPARATORS;
#[derive(Debug)]
pub struct Query {
tokens: Vec<String>,
}
<|fim_suffix|>impl From<String> for Query {
fn from(text: String) -> Query {
Query::new(&[&text])
}
}<|fim_middle|>impl Query {
... | code_fim | hard | {
"lang": "rust",
"repo": "SnakeSolid/rust-database-monitor",
"path": "/src/search/query.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokens.extend(
word.split(|c| SEPARATORS.contains(c))
.filter(|token| !token.is_empty())
.map(|token| token.into()),
);
}
Query { tokens }
}
pub fn tokens(&self) -> &Vec<String> {
&self.tokens... | code_fim | medium | {
"lang": "rust",
"repo": "SnakeSolid/rust-database-monitor",
"path": "/src/search/query.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsmartel/druid path: /druid/src/debug_state.rs
//! A data structure for representing widget trees.
use std::collections::HashMap;
/// A description widget and its children, clonable and comparable, meant
/// for testing and debugging. This is extremely not optimized.
#[derive(Default, Clone,... | code_fim | medium | {
"lang": "rust",
"repo": "nilsmartel/druid",
"path": "/druid/src/debug_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.other_values.is_empty() && self.children.is_empty() && self.main_value.is_empty() {
f.write_str(&self.display_name)
} else if self.other_values.is_empty() && self.children.is_empty() {
f.debug_tuple(&self.display_name)
.field(&self.main_value... | code_fim | medium | {
"lang": "rust",
"repo": "nilsmartel/druid",
"path": "/druid/src/debug_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svenstaro/genact path: /src/modules/cryptomining.rs
//! Pretend to mine a cryptocurrency
use async_trait::async_trait;
use chrono::prelude::*;
use chrono::Duration;
use instant::Instant;
use rand::{thread_rng, Rng};
use rand_distr::{Distribution, Normal};
use yansi::Paint;
use crate::args::AppC... | code_fim | hard | {
"lang": "rust",
"repo": "svenstaro/genact",
"path": "/src/modules/cryptomining.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(format!("{info:>3} {time}{separator}{source:<13}Received new job #{jobhex} seed: #{seedhex} target: #{targethex}",
info=info,
time=time,
separator=Paint::black("|"),
source=Paint::blue("stratum"),
... | code_fim | hard | {
"lang": "rust",
"repo": "svenstaro/genact",
"path": "/src/modules/cryptomining.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn send(&self, key: K, value: V) {
self.inner.lock().insert(key, value);
unsafe { self.condition.notify(); }
}
pub fn receive(&self, key: &K) -> V {
loop {
if let Some(value) = self.inner.lock().remove(key) {
return value;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "kaizensoze/redox",
"path": "/kernel/sync/wait_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaizensoze/redox path: /kernel/sync/wait_map.rs
use collections::BTreeMap;
use super::Intex;
use super::WaitCondition;
pub struct WaitMap<K, V> {
pub inner: Intex<BTreeMap<K, V>>,
pub condition: WaitCondition
}
<|fim_suffix|> pub fn send(&self, key: K, value: V) {
self.inne... | code_fim | hard | {
"lang": "rust",
"repo": "kaizensoze/redox",
"path": "/kernel/sync/wait_map.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn receive(&self, key: &K) -> V {
loop {
if let Some(value) = self.inner.lock().remove(key) {
return value;
}
unsafe { self.condition.wait(); }
}
}
}<|fim_prefix|>// repo: kaizensoze/redox path: /kernel/sync/wait_map.rs
use c... | code_fim | hard | {
"lang": "rust",
"repo": "kaizensoze/redox",
"path": "/kernel/sync/wait_map.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elang89/servicebot path: /src/errors.rs
use actix_web::{error::ResponseError, HttpResponse};
use derive_more::Display;
<|fim_suffix|>impl ResponseError for ServiceError {
fn error_response(&self) -> HttpResponse {
match *self {
ServiceError::InternalServerError => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Elang89/servicebot",
"path": "/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ResponseError for ServiceError {
fn error_response(&self) -> HttpResponse {
match *self {
ServiceError::InternalServerError => {
HttpResponse::InternalServerError().json("Internal Server Error")
}
ServiceError::BadRequest(ref message) =>... | code_fim | hard | {
"lang": "rust",
"repo": "Elang89/servicebot",
"path": "/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
ServiceError::InternalServerError => {
HttpResponse::InternalServerError().json("Internal Server Error")
}
ServiceError::BadRequest(ref message) => HttpResponse::BadRequest().json(message),
}
}
}<|fim_prefix|>// repo: El... | code_fim | medium | {
"lang": "rust",
"repo": "Elang89/servicebot",
"path": "/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agmcleod/adventofcode-2019 path: /18/src/main.rs
use std::cmp::{Eq, Ord, Ordering};
use std::collections::{BinaryHeap, HashMap, HashSet};
use std::env;
use std::io::Result;
use read_input;
#[derive(Clone, PartialEq)]
enum Tile {
Wall,
Open,
Key(String),
Door(String),
}
type Po... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/adventofcode-2019",
"path": "/18/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> count
}
fn main() -> Result<()> {
let args: Vec<String> = env::args().collect();
let mut input_path = "18/input.txt";
let mut is_p2 = false;
if args.len() >= 2 && args[1] == "p2" {
input_path = "18/inputp2.txt";
is_p2 = true;
}
let input = read_input::read_text... | code_fim | hard | {
"lang": "rust",
"repo": "agmcleod/adventofcode-2019",
"path": "/18/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0..power).fold(1usize, |p, _| (p * self.base) % self.prime)
}
fn hash(&self, strin: &[u8]) -> usize {
strin.iter()
.map(|&c| c as usize)
.fold(0usize, |p, u| (self.base * p + u) % self.prime)
}
pub fn find_first(&self, text: &[u8], pattern: &[u8])... | code_fim | medium | {
"lang": "rust",
"repo": "2lx/algo_rust",
"path": "/src/string/search_rabin_karp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2lx/algo_rust path: /src/string/search_rabin_karp.rs
// https://neerc.ifmo.ru/wiki/index.php?title=Поиск_подстроки_в_строке_с_использованием_хеширования._Алгоритм_Рабина-Карпа
pub struct RKSearch {
base: usize,
prime: usize,
}
impl RKSearch {
pub fn new(base: usize, prime: usize) -... | code_fim | hard | {
"lang": "rust",
"repo": "2lx/algo_rust",
"path": "/src/string/search_rabin_karp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut self,
sched_ctx: &mut SchedContext<E>,
snapshot: E::Snap,
task: Task,
) -> Statistics {
fail_point!("txn_before_process_read");
debug!("process read cmd in worker pool"; "cid" => task.cid);
let tag = task.tag;
let cid = task.cid;
... | code_fim | hard | {
"lang": "rust",
"repo": "wujunze/tikv",
"path": "/src/storage/txn/process.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wujunze/tikv path: /src/storage/txn/process.rs
b(Err(err)),
_ => panic!("process result mismatch"),
},
StorageCb::Locks(cb) => match pr {
ProcessResult::Locks { locks } => cb(Ok(locks)),
ProcessResult::Failed { err } => cb(Err(err)),
... | code_fim | hard | {
"lang": "rust",
"repo": "wujunze/tikv",
"path": "/src/storage/txn/process.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = sched_ctx.engine.async_write(&ctx, to_be_write, engine_cb) {
SCHED_STAGE_COUNTER_VEC
.with_label_values(&[tag, "async_write_err"])
.inc();
error!("engine async_write... | code_fim | hard | {
"lang": "rust",
"repo": "wujunze/tikv",
"path": "/src/storage/txn/process.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 処理が削除されないように output を使うフリをする。
let t = output.as_bytes();
println!("{}", t[3] + t[t.len() - 3]);
}<|fim_prefix|>// repo: ryota-sakamoto/pretable path: /examples/large_case.rs
extern crate pretable;
use pretable::PreTable;
pub fn main() {
let n = 1_000_000;
let numbers = (0..n).ma... | code_fim | easy | {
"lang": "rust",
"repo": "ryota-sakamoto/pretable",
"path": "/examples/large_case.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut table = PreTable::new();
table.set_header(vec!["i"]);
for n in numbers.iter() {
table.add_body(vec![n]);
}
let output = table.output();
// 処理が削除されないように output を使うフリをする。
let t = output.as_bytes();
println!("{}", t[3] + t[t.len() - 3]);
}<|fim_prefix|>// rep... | code_fim | medium | {
"lang": "rust",
"repo": "ryota-sakamoto/pretable",
"path": "/examples/large_case.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryota-sakamoto/pretable path: /examples/large_case.rs
extern crate pretable;
use pretable::PreTable;
<|fim_suffix|> let mut table = PreTable::new();
table.set_header(vec!["i"]);
for n in numbers.iter() {
table.add_body(vec![n]);
}
let output = table.output();
/... | code_fim | medium | {
"lang": "rust",
"repo": "ryota-sakamoto/pretable",
"path": "/examples/large_case.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if moves.len() == 0 {
return None;
}
while counter < N {
if let Some( (steps, winner) ) = Self::play_random_game( board, player_no, moves[ iter ].clone() ) {
counter += steps;
*cache.entry( moves[ iter ].clone() )
... | code_fim | hard | {
"lang": "rust",
"repo": "MarWit/University",
"path": "/ArtificialIntelligence/assignment4/jungle/src/player/montecarlo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarWit/University path: /ArtificialIntelligence/assignment4/jungle/src/player/montecarlo.rs
use std::collections::HashMap;
use player::Player;
use player::random::RandomPlayer;
use game::Game;
use board::{Board, Move};
pub struct MontecarloPlayer;
impl MontecarloPlayer {
fn play_random_ga... | code_fim | hard | {
"lang": "rust",
"repo": "MarWit/University",
"path": "/ArtificialIntelligence/assignment4/jungle/src/player/montecarlo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabijaczleweli/tweetr path: /src/ops/queue_tweet.rs
//! This module contains the functions used only by the `queue-tweet` subsystem.
//!
//! The flow of the `queue-tweet` subsystem is as follows:
//!
//! ```plaintext
//! Options::parse()
//! |> ops::queue_tweet::tweets_path()
//! |> ops::queue_t... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/tweetr",
"path": "/src/ops/queue_tweet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Get the path to the file containing the global tweet queue.
///
/// # Examples
///
/// ```
/// # use tweetr::ops::queue_tweet;
/// # use std::env::temp_dir;
/// let tf = temp_dir().join("tweetr-doctest").join("ops-queue_tweets-tweets_path-0");
/// assert_eq!(queue_tweet::tweets_path(&tf), tf.join("twe... | code_fim | hard | {
"lang": "rust",
"repo": "nabijaczleweli/tweetr",
"path": "/src/ops/queue_tweet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmagnuson/tokio-watchdog path: /examples/interval.rs
extern crate tokio;
extern crate tokio_watchdog;
use tokio::runtime;
use tokio::prelude::{Future, Stream, future};
use tokio::timer::Interval;
use std::time::{Instant, Duration};
fn main() {
<|fim_suffix|> r.spawn(task1.map_err(|_|()));
... | code_fim | hard | {
"lang": "rust",
"repo": "jmagnuson/tokio-watchdog",
"path": "/examples/interval.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let task1 = watch.and_then(|_| {
println!("BLAM!");
::std::process::exit(0);
#[allow(unreachable_code)]
future::ok(())
});
let intvl = Interval::new(Instant::now(), Duration::new(0, 100_000_000));
let lazy_time = Instant::now() + Duration::fro... | code_fim | hard | {
"lang": "rust",
"repo": "jmagnuson/tokio-watchdog",
"path": "/examples/interval.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let watch = tokio_watchdog::Watchdog::new(Duration::from_secs(1));
let p = watch.handle();
let task1 = watch.and_then(|_| {
println!("BLAM!");
::std::process::exit(0);
#[allow(unreachable_code)]
future::ok(())
});
let intvl = Int... | code_fim | medium | {
"lang": "rust",
"repo": "jmagnuson/tokio-watchdog",
"path": "/examples/interval.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iamNarcisse/my-rust path: /src/types/casting.rs
// Suppress all warnings from casts which overflow.
#![allow(overflowing_literals)]
<|fim_suffix|> let character = integer as char;
println!("Casting: {} -> {} -> {}", decimal, integer, character);
// 1000 already fits in a u16
pr... | code_fim | medium | {
"lang": "rust",
"repo": "iamNarcisse/my-rust",
"path": "/src/types/casting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let integer = decimal as u8;
let character = integer as char;
println!("Casting: {} -> {} -> {}", decimal, integer, character);
// 1000 already fits in a u16
println!("1000 as a u16 is: {}", 1000 as u16);
println!("1000 as a u8 is : {}", 1000 as u8);
// For positive number... | code_fim | medium | {
"lang": "rust",
"repo": "iamNarcisse/my-rust",
"path": "/src/types/casting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kjempelodott/adventofcode path: /aoc2017/src/bin/day14.rs
// Keywords: ascii, xor, binary, adjacent tiles, regions, dfs
extern crate itertools;
use itertools::Itertools;
use std::collections::{BinaryHeap, BTreeSet};
const N: usize = 256;
fn next(list: &Vec<u32>, cursor: usize, len: usize) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "kjempelodott/adventofcode",
"path": "/aoc2017/src/bin/day14.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut regions: Vec<BTreeSet<(usize, usize)>> = vec![];
let mut seen: BTreeSet<(usize, usize)> = BTreeSet::new();
for i in 0..128 {
for j in 0..128 {
if seen.contains(&(i, j)) || grid[i][j] == '0' {
continue
}
let mut queue: BinaryHe... | code_fim | hard | {
"lang": "rust",
"repo": "kjempelodott/adventofcode",
"path": "/aoc2017/src/bin/day14.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skycandyzhe/rustStudy path: /src/demo/enum/main.rs
#[derive(Debug)]
enum Book {
Papery(u32),
Electronic(String),
}
enum Book2 {
// 将struct当为枚举对象
Index(u32),
Papery {index: u32},
Electronic {url: String},
}
fn main() {
let book = Book::Papery(1001);
let ebook = Bo... | code_fim | hard | {
"lang": "rust",
"repo": "skycandyzhe/rustStudy",
"path": "/src/demo/enum/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
// let book = Book2::Electronic{url:String::from("url")};
// 不好用
if let 12= 12 {
println!("Papery {}", "url");
} else {
println!("Not papery book");
}
}<|fim_prefix|>// repo: skycandyzhe/rustStudy path: /src/demo/enum/main.rs
#[derive(Debug)]
enum Book {
Pape... | code_fim | hard | {
"lang": "rust",
"repo": "skycandyzhe/rustStudy",
"path": "/src/demo/enum/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tauri path: /core/tauri/src/updater/mod.rs
need to use [`RunEvent::Updater`](crate::RunEvent) in [`App::run`](crate::App#method.run).
//!
//! ```no_run
//! let app = tauri::Builder::default()
//! // on an actual app, remove the string argument
//! .build(tauri::generate_context!... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/updater/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, serde::Serialize)]
#[serde(rename_all = "camelCase")]
struct DownloadProgressEvent {
chunk_length: usize,
content_length: Option<u64>,
}
#[derive(Clone, serde::Serialize)]
struct UpdateManifest {
version: String,
date: Option<String>,
body: String,
}
/// An update check builder... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/updater/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tauri path: /core/tauri/src/updater/mod.rs
#method.run).
//!
//! ```no_run
//! let app = tauri::Builder::default()
//! // on an actual app, remove the string argument
//! .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
//! .expect("error while buildin... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tauri",
"path": "/core/tauri/src/updater/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Akulen/awesome-wayland path: /src/lua/callbacks/screen.rs
//! Callbacks for the `screen` object in the Lua libraries
use ::lua::Lua;
use super::default;
use libc::c_int;
pub trait Screen {
// Class Methods
fn screen_add_signal(&mut self, lua: Lua) -> c_int;
fn screen_connect_signal... | code_fim | hard | {
"lang": "rust",
"repo": "Akulen/awesome-wayland",
"path": "/src/lua/callbacks/screen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn screen_set_newindex_miss_handler(&mut self, lua: Lua) -> c_int;
// Methods
fn screen_count(&mut self, lua: Lua) -> c_int;
fn screen___index(&mut self, lua: Lua) -> c_int;
fn screen___newindex(&mut self, lua: Lua) -> c_int;
fn screen___call(&mut self, lua: Lua) -> c_int;
fn s... | code_fim | medium | {
"lang": "rust",
"repo": "Akulen/awesome-wayland",
"path": "/src/lua/callbacks/screen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jekahome/Robart path: /sound/src/parse_sound.rs
7,83,104,112,140,155,188,185,188,187,199,202,187,188,191,179,171,163,159,139,125,119,104,86,83,59,51,45,38,32,27,31,35,42,47,66,72,83,91,96,108,107,119,130,135,136,147,150,146,165,171,177,178,175,178,168,161,149,134,120,112,94,82,71,64,61,50,51,56,... | code_fim | hard | {
"lang": "rust",
"repo": "Jekahome/Robart",
"path": "/sound/src/parse_sound.rs",
"mode": "psm",
"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.