text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> Ok(row)
}
async fn delete_others(conn: &PgPool) -> Result<()> {
sqlx::query(
r#"
DELETE FROM sqlx.type_test
WHERE x_bigserial <> (SELECT min(x_bigserial) FROM sqlx.type_test)
"#,
)
.execute(conn)
.await?;
Ok(())
}
async fn count(conn: &PgPool) -> Result<i64> {
let c... | code_fim | hard | {
"lang": "rust",
"repo": "cutsea110/sqlx-types-test",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cutsea110/sqlx-types-test path: /src/main.rs
use anyhow::Result;
use chrono::naive::{NaiveDate, NaiveDateTime, NaiveTime};
use chrono::{DateTime, Utc};
use futures::TryStreamExt; // try_next()
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use sqlx::postgres::types::{Pg... | code_fim | hard | {
"lang": "rust",
"repo": "cutsea110/sqlx-types-test",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> DEFMSTR_TYPE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: DEFMSTR_TYPE_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "No Default Master-At the end of the current slave access, if no other master request is... | code_fim | hard | {
"lang": "rust",
"repo": "ju6ge/atsame70q21",
"path": "/src/matrix/matrix_scfg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ju6ge/atsame70q21 path: /src/matrix/matrix_scfg.rs
#[doc = "Reader of register MATRIX_SCFG[%s]"]
pub type R = crate::R<u32, super::MATRIX_SCFG>;
#[doc = "Writer for register MATRIX_SCFG[%s]"]
pub type W = crate::W<u32, super::MATRIX_SCFG>;
#[doc = "Register MATRIX_SCFG[%s] `reset()`'s with value... | code_fim | hard | {
"lang": "rust",
"repo": "ju6ge/atsame70q21",
"path": "/src/matrix/matrix_scfg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
#[test]
fn test_try_cast_decimal_to_numeric() -> Result<()> {
// TODO we should add function to create Decimal128Array with value and metadata
// https://github.com/apache/arrow-rs/issues/1009
let array: Vec<i128> = vec![1, 2, 3, 4, 5];
let dec... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/physical-expr/src/expressions/try_cast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/physical-expr/src/expressions/try_cast.rs
/ with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under th... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/physical-expr/src/expressions/try_cast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // float64
generic_test_cast!(
Float64Array,
DataType::Float64,
vec![1.5, 2.5, 3.0, 1.123_456_8, 5.50],
Decimal128Array,
DataType::Decimal128(20, 4),
vec![
Some(15000),
Some(25000),
... | code_fim | hard | {
"lang": "rust",
"repo": "biaoma-ty/arrow-datafusion",
"path": "/datafusion/physical-expr/src/expressions/try_cast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// 把 reqwest 的流也封装一下,转换需要的错误类型
///
/// ## Example
///
/// ```rust
/// let res = builder.send().await;
/// let stream = res.bytes_stream();
/// let mut resp = HttpResponse::build(res.status());
/// // 这种方式默认会使用 chunked 传输方式
/// return Ok(resp.streaming(reqwest_actix_stream::ResponseStream{ stream: stream... | code_fim | hard | {
"lang": "rust",
"repo": "clia/reqwest-actix-stream",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clia/reqwest-actix-stream path: /src/lib.rs
use std::io;
use actix_web::web;
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::Stream;
use actix_http::error::PayloadError;
/// 把Actix-web 的 Payload 强行改成可发送的
/// 这样才能支持reqwest的流分发方式
///
/// 注意:此物最好不要跨线程使用,否则就真的不安全了
///
/// ## Exa... | code_fim | hard | {
"lang": "rust",
"repo": "clia/reqwest-actix-stream",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn random_id() -> String {
thread_rng()
.sample_iter(&Alphanumeric)
.take(16)
.map(char::from)
.collect()
}<|fim_prefix|>// repo: kkmagician/dating_questions_bot path: /src/tools.rs
use std::collections::HashMap;
use std::env;
use std::str::FromStr;
use std::time::... | code_fim | hard | {
"lang": "rust",
"repo": "kkmagician/dating_questions_bot",
"path": "/src/tools.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkmagician/dating_questions_bot path: /src/tools.rs
use std::collections::HashMap;
use std::env;
use std::str::FromStr;
use std::time::SystemTime;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
<|fim_suffix|>pub fn get_parse_string_value<T: FromStr>(
hm: &HashMap<Strin... | code_fim | hard | {
"lang": "rust",
"repo": "kkmagician/dating_questions_bot",
"path": "/src/tools.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn current_time() -> u64 {
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
}
pub fn random_id() -> String {
thread_rng()
.sample_iter(&Alphanumeric)
.take(16)
.map(char::from)
.collect()
}<|fim_prefix|>// r... | code_fim | medium | {
"lang": "rust",
"repo": "kkmagician/dating_questions_bot",
"path": "/src/tools.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>splay
for
MapError
{
fn
fmt
(
&
self
fmt
:
&
mut
fmt
:
:
Formatter
<
'
_
>
)
-
>
fmt
:
:
Result
{
match
self
{
MapError
:
:
OutOfDeviceMemory
=
>
fmt
.
write_str
(
"
Device
memory
exhausted
"
)
MapError
:
:
OutOfHostMemory
=
>
fmt
.
write_str
(
"
Host
memory
exhausted
"
)
MapError
:
:
MapFailed
=
>
fmt
.
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/gpu-alloc/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/gpu-alloc/src/error.rs
use
{
core
:
:
fmt
:
:
{
self
Display
}
gpu_alloc_types
:
:
{
DeviceMapError
OutOfMemory
}
}
;
#
[
derive
(
Clone
Copy
Debug
PartialEq
Eq
Hash
)
]
pub
enum
AllocationError
{
OutOfDeviceMemory
OutOfHos... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/gpu-alloc/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[async_trait]
impl RequestSender for RequestSender {
async fn send_request(&self, id: RunId) -> FaultyServerResponse;
}
}<|fim_prefix|>// repo: prok20/faulty-server-poller path: /src/polling/request_sender/mod.rs
#[cfg(test)]
use mockall::mock;
use crate::polling::dto::{FaultyServer... | code_fim | medium | {
"lang": "rust",
"repo": "prok20/faulty-server-poller",
"path": "/src/polling/request_sender/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prok20/faulty-server-poller path: /src/polling/request_sender/mod.rs
#[cfg(test)]
use mockall::mock;
use crate::polling::dto::{FaultyServerResponse, RunId};
use async_trait::async_trait;
mod reqwest_request_sender;
pub use reqwest_request_sender::ReqwestRequestSender;
#[async_trait]
pub trait... | code_fim | medium | {
"lang": "rust",
"repo": "prok20/faulty-server-poller",
"path": "/src/polling/request_sender/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JadeGeek/isomorphicdb path: /node_engine/src/query_engine_old/tests/mod.rs
// Copyright 2020 - 2021 Alex Dukhno
//
// 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
//
... | code_fim | hard | {
"lang": "rust",
"repo": "JadeGeek/isomorphicdb",
"path": "/node_engine/src/query_engine_old/tests/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut actual = self.0.lock().expect("locked");
assert_eq!(actual.deref_mut().pop(), Some(QueryEvent::QueryComplete.into()));
}
}
#[rstest::fixture]
fn empty_database() -> (InMemory, ResultCollector) {
setup_logger();
let collector = Collector::new();
(InMemory::new(colle... | code_fim | hard | {
"lang": "rust",
"repo": "JadeGeek/isomorphicdb",
"path": "/node_engine/src/query_engine_old/tests/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nou4r/modernwarfare-internal-rs path: /src/decryption.rs
use std::time::{Duration, Instant};
use crate::util::{Global, is_bad_ptr};
use crate::memory::MEMORY;
use crate::sdk;
pub struct Decryption {
pub client_info: Option<u64>,
pub client_base: Option<u64>,
pub bone_base: Option<u... | code_fim | hard | {
"lang": "rust",
"repo": "Nou4r/modernwarfare-internal-rs",
"path": "/src/decryption.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unsafe fn bone_index(index: u32) -> u64 {
get_bone_index(index, MEMORY.image_base)
}
pub fn valid(&self) -> bool {
self.client_info.is_some() && self.client_base.is_some()
}
pub fn valid_bone(&self) -> bool {
self.valid() && self.bone_base.is_some()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Nou4r/modernwarfare-internal-rs",
"path": "/src/decryption.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(PartialEq, Clone, Default)]
pub struct Trace_HTTP_Values {
// message fields
pub value: ::protobuf::RepeatedField<::std::string::String>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Defau... | code_fim | hard | {
"lang": "rust",
"repo": "Miaxos/apollo-tracing-protobuf-rs",
"path": "/generated/tracing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Miaxos/apollo-tracing-protobuf-rs path: /generated/tracing.rs
_ => {
::protobuf::rt::read_unknown_or_skip_group(
field_number,
wire_type,
is,
self.mut_unknown_fields(),... | code_fim | hard | {
"lang": "rust",
"repo": "Miaxos/apollo-tracing-protobuf-rs",
"path": "/generated/tracing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Miaxos/apollo-tracing-protobuf-rs path: /generated/tracing.rs
= ::std::option::Option::None;
}
pub fn has_flatten(&self) -> bool {
match self.node {
::std::option::Option::Some(Trace_QueryPlanNode_oneof_node::flatten(..)) => true,
_ => false,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Miaxos/apollo-tracing-protobuf-rs",
"path": "/generated/tracing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roguelazer/rust_trie path: /src/lib.rs
/// Generic Trie implementation
///
/// Doesn't feature any Patricia optimizations (each node has only a single key)
///
/// # Examples
///
/// ```
/// use trie;
///
/// let mut t: trie::Trie<char, String> = trie::Trie::new_empty();
/// t.insert("abc".chars... | code_fim | hard | {
"lang": "rust",
"repo": "Roguelazer/rust_trie",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut t = Trie::new_empty();
assert_eq!(t.insert("abc".chars(), "object 1".to_string()), Ok(()));
assert_eq!(t.insert("ab".chars(), "object 2".to_string()), Ok(()));
let res1 = t.search("abc".chars());
assert!(res1 != None);
if let Some(value) = res1 {
... | code_fim | hard | {
"lang": "rust",
"repo": "Roguelazer/rust_trie",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(res3 != None);
if let Some(value) = res3 {
assert_eq!(value, "object 2");
}
}
#[test]
fn test_ints_and_vectors() {
let mut t: Trie<i32, i32> = Trie::new_empty();
assert_eq!(t.insert(vec![1, 2], 10), Ok(()));
assert_eq!(t.in... | code_fim | hard | {
"lang": "rust",
"repo": "Roguelazer/rust_trie",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Medsko/AoC2020 path: /src/main.rs
use std::io;
mod utils;
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
mod day06;
mod day07;
mod day08;
fn main() {
println!("All things must end - even 2020");
println!("For which day do you want to generate files?");
<|fim_suffix|> l... | code_fim | medium | {
"lang": "rust",
"repo": "Medsko/AoC2020",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("For which day do you want to generate files?");
loop {
let mut user_input = String::new();
io::stdin()
.read_line(&mut user_input)
.expect("Failed to read line!");
let day: usize = match user_input.trim().parse() {
Ok(num) => ... | code_fim | medium | {
"lang": "rust",
"repo": "Medsko/AoC2020",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let mut user_input = String::new();
io::stdin()
.read_line(&mut user_input)
.expect("Failed to read line!");
let day: usize = match user_input.trim().parse() {
Ok(num) => num,
Err(_) => {
println!("{} is no... | code_fim | medium | {
"lang": "rust",
"repo": "Medsko/AoC2020",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn bench_to_snake_name(b: &mut Bencher) {
b.iter(|| {
to_snake_name("Abc");
});
}<|fim_prefix|>// repo: rbatis/rbatis path: /benches/table.rs
#![feature(test)]
extern crate test;
<|fim_middle|>use rbatis::utils::string_util::to_snake_name;
use test::Bencher;
| code_fim | medium | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/benches/table.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rbatis/rbatis path: /benches/table.rs
#![feature(test)]
extern crate test;
<|fim_suffix|> b.iter(|| {
to_snake_name("Abc");
});
}<|fim_middle|>use rbatis::utils::string_util::to_snake_name;
use test::Bencher;
#[bench]
fn bench_to_snake_name(b: &mut Bencher) {
| code_fim | medium | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/benches/table.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
to_snake_name("Abc");
});
}<|fim_prefix|>// repo: rbatis/rbatis path: /benches/table.rs
#![feature(test)]
extern crate test;
<|fim_middle|>use rbatis::utils::string_util::to_snake_name;
use test::Bencher;
#[bench]
fn bench_to_snake_name(b: &mut Bencher) {
| code_fim | medium | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/benches/table.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn bus(self) -> u8 {
((self.0 >> 8) & 0xFF) as u8
}
#[inline]
pub fn device(self) -> u8 {
((self.0 >> 3) & 0x1F) as u8
}
#[inline]
pub fn function(self) -> u8 {
(self.0 & 0x07) as u8
}
}
impl Deref for PCIAddress {
type Targe... | code_fim | hard | {
"lang": "rust",
"repo": "stmobo/epiphyllum",
"path": "/kernel/src/devices/pci/address.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stmobo/epiphyllum path: /kernel/src/devices/pci/address.rs
use core::fmt;
use core::fmt::Display;
use core::ops::Deref;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PCIAddress(u32);
impl PCIAddress {
pub fn new(segment: u16, bus: u8, device: u8, function: ... | code_fim | hard | {
"lang": "rust",
"repo": "stmobo/epiphyllum",
"path": "/kernel/src/devices/pci/address.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fstakem/rusty_edge path: /lib/edge_ingression/src/protocol/mqtt/client.rs
use std::time::Duration;
use std::sync::mpsc::Sender;
use super::super::super::ProtocolError;
use super::super::super::ErrorKind;
use super::super::super::Msg;
use super::super::super::deserializer::json::Json;
use edge_c... | code_fim | hard | {
"lang": "rust",
"repo": "fstakem/rusty_edge",
"path": "/lib/edge_ingression/src/protocol/mqtt/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(e) = tok.wait() {
println!("Error sending message: {:?}", e);
}
return Ok(());
}
let error = ErrorKind::Mqtt;
let result = Result::Err(ProtocolError{
kind: error,
msg: "Error not connected".to_... | code_fim | hard | {
"lang": "rust",
"repo": "fstakem/rusty_edge",
"path": "/lib/edge_ingression/src/protocol/mqtt/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.paho.is_connected() {
let mqtt_msg = paho_mqtt::MessageBuilder::new()
.topic(topic)
.payload(msg_str.clone())
.qos(0)
.finalize();
let output = ["Topic: ", &topic, " Msg: ", &msg_str].concat();
... | code_fim | hard | {
"lang": "rust",
"repo": "fstakem/rusty_edge",
"path": "/lib/edge_ingression/src/protocol/mqtt/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client = default_client();
let tx_list = client.get_script_hash_txs_mempool(
"c6598a8e5728c744b9734facbf1e786c3ff5101268739d38b14ea475b60eba3c",
);
assert!(tx_list.is_ok())
}
#[test]
fn blocking_get_address_utxo() {
let client = default_client();
let utxo = client.get_a... | code_fim | hard | {
"lang": "rust",
"repo": "vivienbcr/Blockstream-api-wrapper",
"path": "/tests/blocking_impl_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vivienbcr/Blockstream-api-wrapper path: /tests/blocking_impl_tests.rs
#[cfg(feature = "blocking")]
use esplora_api::blocking::{ApiClient, ClientOptions, HeadersOptions};
use reqwest;
use reqwest::header;
static ENDPOINT_URL: &str = "https://blockstream.info/testnet/api/";
fn default_client() ->... | code_fim | hard | {
"lang": "rust",
"repo": "vivienbcr/Blockstream-api-wrapper",
"path": "/tests/blocking_impl_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: compressed/quick-csv path: /src/columns.rs
//! Column management module
//!
//! Provides convenient or fast column conversions
//! Deserialize columns into a `Decodable` type
use std::str::FromStr;
use rustc_serialize as serialize;
use error::{Result, Error};
use std::slice::Iter;
/// Iterato... | code_fim | hard | {
"lang": "rust",
"repo": "compressed/quick-csv",
"path": "/src/columns.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// &str iterator on columns
pub struct Columns<'a> {
pos: usize,
line: &'a str,
iter: Iter<'a, usize>,
}
impl<'a> Iterator for Columns<'a> {
type Item = &'a str;
fn next(&mut self) -> Option<&'a str> {
self.iter.next().map(|p| {
let s = &self.line[self.pos..*p... | code_fim | hard | {
"lang": "rust",
"repo": "compressed/quick-csv",
"path": "/src/columns.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pprobst/roguelike path: /src/map_gen/wfc/cell.rs
use super::TileType;
use crate::utils::directions::*;
use bracket_lib::prelude::RandomNumberGenerator;
use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq)]
pub struct MapTile {
pub idx: usize,
pub pattern: Vec<TileType>,
... | code_fim | hard | {
"lang": "rust",
"repo": "pprobst/roguelike",
"path": "/src/map_gen/wfc/cell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for idx in self.possible_tiles.iter() {
let weight = *freq.get(idx).unwrap();
if remain >= weight {
remain -= weight;
} else {
return *idx;
}
}
unreachable!("sum_possible_weights was inconsistent!");
... | code_fim | hard | {
"lang": "rust",
"repo": "pprobst/roguelike",
"path": "/src/map_gen/wfc/cell.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drogue-iot/drogue-bluetooth path: /drogue-bluetooth-hci-macros/src/lib.rs
#![allow(dead_code)]
#![allow(unused_variables)]
extern crate proc_macro;
#[macro_use]
extern crate syn;
#[macro_use]
extern crate quote;
mod hci_command;
mod hci_serializable;
mod hci_deserializable;
<|fim_suffix|>#[pr... | code_fim | medium | {
"lang": "rust",
"repo": "drogue-iot/drogue-bluetooth",
"path": "/drogue-bluetooth-hci-macros/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[proc_macro_derive(HCISerializable)]
pub fn hci_serializable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
hci_serializable::hci_serializable(input)
}
#[proc_macro_derive(HCIDeserializable)]
pub fn hci_deserializable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
hci... | code_fim | medium | {
"lang": "rust",
"repo": "drogue-iot/drogue-bluetooth",
"path": "/drogue-bluetooth-hci-macros/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gifnksm/ProjectEulerRust path: /pkg/iter/benches/bench.rs
use criterion::{criterion_group, criterion_main, Criterion};
use iter::BitCombination;
<|fim_suffix|> c.bench_function("comb last", |b| {
b.iter(|| {
let cnt = criterion::black_box(5);
let size = criter... | code_fim | medium | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/pkg/iter/benches/bench.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("comb last", |b| {
b.iter(|| {
let cnt = criterion::black_box(5);
let size = criterion::black_box(10);
BitCombination::new(cnt, size).last()
})
});
c.bench_function("comb all", |b| {
b.iter(|| {
let cnt = ... | code_fim | medium | {
"lang": "rust",
"repo": "gifnksm/ProjectEulerRust",
"path": "/pkg/iter/benches/bench.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: r-asou/databend path: /common/meta/types/src/kv_reply.rs
// Copyright 2020 Datafuse Labs.
//
// 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.apac... | code_fim | medium | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/common/meta/types/src/kv_reply.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct GetKVActionReply {
pub result: Option<SeqV<Vec<u8>>>,
}
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct MGetKVActionReply {
pub result: Vec<Option<SeqV<Vec<u8>>>>,
}
pu... | code_fim | medium | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/common/meta/types/src/kv_reply.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type UpsertKVActionReply = Change<Vec<u8>>;
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct GetKVActionReply {
pub result: Option<SeqV<Vec<u8>>>,
}
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct MGetKVActionReply {
... | code_fim | medium | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/common/meta/types/src/kv_reply.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: username223/bl602-pac path: /src/rf/ppu_ctrl_hw.rs
#[doc = "Register `ppu_ctrl_hw` reader"]
pub struct R(crate::R<PPU_CTRL_HW_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<PPU_CTRL_HW_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "username223/bl602-pac",
"path": "/src/rf/ppu_ctrl_hw.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `ppu_lna_hw` writer - "]
pub struct PPU_LNA_HW_W<'a> {
w: &'a mut W,
}
impl<'a> PPU_LNA_HW_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
... | code_fim | hard | {
"lang": "rust",
"repo": "username223/bl602-pac",
"path": "/src/rf/ppu_ctrl_hw.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/samael path: /src/metadata/key_descriptor.rs
use crate::key_info::KeyInfo;
use crate::metadata::EncryptionMethod;
use quick_xml::events::{BytesEnd, BytesStart, Event};
use quick_xml::Writer;
use serde::Deserialize;
use std::io::Cursor;
<|fim_suffix|>#[derive(Clone, Debug, Deserial... | code_fim | medium | {
"lang": "rust",
"repo": "oxidecomputer/samael",
"path": "/src/metadata/key_descriptor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(encryption_methods) = &self.encryption_methods {
for method in encryption_methods {
writer.write(method.to_xml()?.as_bytes())?;
}
}
writer.write_event(Event::End(BytesEnd::borrowed(NAME.as_bytes())))?;
Ok(String::from_utf... | code_fim | medium | {
"lang": "rust",
"repo": "oxidecomputer/samael",
"path": "/src/metadata/key_descriptor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: turnage/huff path: /src/main.rs
pub mod data;
use std::io::Read;
use data::Countable;
use data::elem::KVPair;
use data::heap::BinaryHeap;
use data::abstr::PriorityQueue;
const EMPTY: &'static str = "";
#[derive(Debug)]
struct Node {
val: String,
left: Option<Box<Node>>,
right: Op... | code_fim | hard | {
"lang": "rust",
"repo": "turnage/huff",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = String::new();
match std::io::stdin().read_to_string(&mut buffer) {
Err(e) => println!("Failed to read frequencies from stdin: {}", e),
Ok(_) => {
let mut pairs = Vec::new();
for line in buffer.lines() {
let mut terms = line.... | code_fim | hard | {
"lang": "rust",
"repo": "turnage/huff",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
println!(">> Escriu un número: ");
//nou string per guardar resposta usuari
let mut guess = String::new();
//llegeix stdin i guarda resultat a "guess"
io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");
let guess: u32 = match guess.trim().pars... | code_fim | medium | {
"lang": "rust",
"repo": "holalluis/apunts",
"path": "/rust/guessing_game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: holalluis/apunts path: /rust/guessing_game/src/main.rs
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
println!("=== Endevina un numero de l'1 al 100 ===");
//genera un número aleatori
let secret_number = rand::thread_rng().gen_range(1, 101);
//println!("El número secre... | code_fim | medium | {
"lang": "rust",
"repo": "holalluis/apunts",
"path": "/rust/guessing_game/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //println!("Has escrit '{}'", guess);
match guess.cmp(&secret_number){
Ordering::Less => println!(">> Massa petit!"),
Ordering::Greater => println!(">> Massa gran!"),
Ordering::Equal => {
println!(">> CORRECTE! El número secret era el {secret_number}");
brea... | code_fim | medium | {
"lang": "rust",
"repo": "holalluis/apunts",
"path": "/rust/guessing_game/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scottwillmoore/glad-wrap path: /src/shader.rs
use gl::types::*;
use std::ffi::{CStr, CString};
use std::fs::File;
use std::io::Read;
use std::path::Path;
// https://codereview.stackexchange.com/questions/175001/modern-opengl-wrapper-abstractions-shaders
#[derive(Debug, Clone, Copy)]
pub enum S... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/glad-wrap",
"path": "/src/shader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let extension = path
.extension()
.and_then(|s| s.to_str())
.map_or("".to_string(), |s| s.to_ascii_lowercase());
let kind = match extension.as_str() {
"fs" => ShaderType::Fragment,
"vs" => ShaderType::Vertex,
_ => {
... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/glad-wrap",
"path": "/src/shader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_info_log(&self) -> String {
let mut len = 0;
unsafe { gl::GetShaderiv(self.id, gl::INFO_LOG_LENGTH, &mut len) };
let mut info_log: Vec<u8> = std::iter::repeat(0).take(len as usize).collect();
unsafe {
gl::GetShaderInfoLog(
self.id,
... | code_fim | hard | {
"lang": "rust",
"repo": "scottwillmoore/glad-wrap",
"path": "/src/shader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Take the next parameter and parse as the given type.
pub fn next_parse<T, M>(&mut self, m: M) -> Option<T>
where
T: std::str::FromStr,
T::Err: fmt::Display,
M: fmt::Display,
{
match self.next_parse_optional()? {
Some(value) => Some(value),
... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/OxidizeBot",
"path": "/bot/src/command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Verify that the current user has the associated scope.
pub fn check_scope(&mut self, scope: Scope) -> Result<(), Error> {
if !self.user.has_scope(scope) {
if let Some(name) = self.user.display_name() {
self.privmsg(format!(
"Do you think ... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/OxidizeBot",
"path": "/bot/src/command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonsan/OxidizeBot path: /bot/src/command.rs
//! Traits and shared plumbing for bot commands (e.g. `!uptime`)
use crate::{auth::Scope, irc, prelude::*, utils};
use failure::Error;
use hashbrown::HashMap;
use std::{fmt, time::Instant};
#[async_trait]
/// The handler trait for a given command.
... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/OxidizeBot",
"path": "/bot/src/command.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(format_elements![
formatter.format_token(&self.debugger_token()?)?,
token(";")
])
}
}<|fim_prefix|>// repo: pnoken/tools path: /crates/formatter/src/ts/statements/debugger_statement.rs
use crate::{format_elements, token, FormatElement, Formatter, ToFormatElement};
use rslint_parser::ast::... | code_fim | medium | {
"lang": "rust",
"repo": "pnoken/tools",
"path": "/crates/formatter/src/ts/statements/debugger_statement.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnoken/tools path: /crates/formatter/src/ts/statements/debugger_statement.rs
use crate::{format_elements, token, FormatElement, Formatter, ToFormatElement};
use rslint_parser::ast::DebuggerStmt;
<|fim_suffix|> Some(format_elements![
formatter.format_token(&self.debugger_token()?)?,
token... | code_fim | medium | {
"lang": "rust",
"repo": "pnoken/tools",
"path": "/crates/formatter/src/ts/statements/debugger_statement.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ToDeviceSecretSendEventContent {
/// Creates a new `SecretSendEventContent` with the given request ID and secret.
pub fn new(request_id: OwnedTransactionId, secret: String) -> Self {
Self { request_id, secret }
}
}
impl fmt::Debug for ToDeviceSecretSendEventContent {
fn fmt(&... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/src/secret/send.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The content of an `m.secret.send` event.
///
/// An event sent by a client to share a secret with another device, in response to an
/// `m.secret.request` event.
///
/// It must be encrypted as an `m.room.encrypted` event, then sent as a to-device event.
#[derive(Clone, Deserialize, Serialize, EventCo... | code_fim | medium | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/src/secret/send.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-events/src/secret/send.rs
//! Types for the [`m.secret.send`] event.
//!
//! [`m.secret.send`]: https://spec.matrix.org/latest/client-server-api/#msecretsend
use std::fmt;
use ruma_common::OwnedTransactionId;
use ruma_macros::EventContent;
use serde::{Deserialize, ... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-events/src/secret/send.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/values/calculation/calc/error/mod.rs
//! Tests auto-converted from "sass-spec/spec/values/calculation/calc/error"
#[allow(unused)]
fn runner() -> crate::TestRunner {
<|fim_suffix|>mod operator;
mod syntax;
mod value;<|fim_middle|> super::runner().with_cwd(... | code_fim | medium | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/values/calculation/calc/error/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod known_incompatible;
mod operator;
mod syntax;
mod value;<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/values/calculation/calc/error/mod.rs
//! Tests auto-converted from "sass-spec/spec/values/calculation/calc/error"
<|fim_middle|>#[allow(unused)]
fn runner() -> crate::TestRunner {
... | code_fim | medium | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/values/calculation/calc/error/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, data: Self::SystemData) {
for evt in data.channel.read(self.reader.as_mut().unwrap()) {
let player_data = Self::get_player_data(&data);
// TODO: Correct clock value and pass session through
let packet = Login {
clock: 0,
id: evt.0,
room: data.gamemode.get().room(... | code_fim | hard | {
"lang": "rust",
"repo": "Phantomical/mighty-server",
"path": "/server/src/systems/handlers/game/on_join/send_login.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phantomical/mighty-server path: /server/src/systems/handlers/game/on_join/send_login.rs
use specs::*;
use types::*;
use GameMode;
use GameModeWriter;
use OwnedMessage;
use SystemInfo;
use component::channel::*;
use protocol::server::{Login, LoginPlayer};
use protocol::{to_bytes, ServerPacket, ... | code_fim | hard | {
"lang": "rust",
"repo": "Phantomical/mighty-server",
"path": "/server/src/systems/handlers/game/on_join/send_login.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Swatinem/druid path: /druid/examples/markdown_preview.rs
// Copyright 2020 The Druid Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.... | code_fim | hard | {
"lang": "rust",
"repo": "Swatinem/druid",
"path": "/druid/examples/markdown_preview.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut current_pos = 0;
let mut builder = RichTextBuilder::new();
let mut tag_stack = Vec::new();
let parser = Parser::new(text);
for event in parser {
match event {
ParseEvent::Start(tag) => {
tag_stack.push((current_pos, tag));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Swatinem/druid",
"path": "/druid/examples/markdown_preview.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> expanded.into()
}
_ => {
let ident = &func.ident;
let inputs = &func.decl.inputs;
let output = &func.decl.output;
let sig = quote! { pub unsafe extern "C" fn #ident(#(#inputs),*) #output { ... } };
Error::custom(forma... | code_fim | hard | {
"lang": "rust",
"repo": "flier/rust-ebpf",
"path": "/ebpf-derive/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flier/rust-ebpf path: /ebpf-derive/src/lib.rs
extern crate proc_macro;
use darling::{Error, FromMeta};
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, parse_quote};
#[proc_macro_derive(TryFrom)]
pub fn try_from(input: TokenStream) -> TokenStream {
let syn::Deriv... | code_fim | hard | {
"lang": "rust",
"repo": "flier/rust-ebpf",
"path": "/ebpf-derive/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut visitor = VisitRepr::default();
for attr in attrs {
if attr.path.is_ident("repr") {
if let Ok(meta) = attr.parse_meta() {
syn::visit::visit_meta(&mut visitor, &meta);
}
}
}
visitor.ty
}
#[proc_macro]
pub fn license(input: T... | code_fim | hard | {
"lang": "rust",
"repo": "flier/rust-ebpf",
"path": "/ebpf-derive/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn inner() -> i32 {
let bins = or_exit!(make_bins());
let to_paste = or_exit!(bins.get_to_paste());
let engine = or_exit!(bins.get_engine());
let url = or_exit!(engine.upload(&bins, &to_paste));
println!("{}", url);
0
}
fn main() {
let exit_code = inner();
std::process::exit(exit_code);
}... | code_fim | hard | {
"lang": "rust",
"repo": "lol768/bins",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lol768/bins path: /src/main.rs
extern crate config;
extern crate argparse;
extern crate hyper;
extern crate rustc_serialize;
extern crate url;
#[macro_use]
extern crate error_chain;
mod bins;
use bins::error::*;
use bins::Bins;
use bins::arguments;
use bins::configuration::{BinsConfiguration, ... | code_fim | medium | {
"lang": "rust",
"repo": "lol768/bins",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unpluggedcoder/memory-profiler path: /preload/src/channel.rs
use std::time::Duration;
use std::mem;
use parking_lot::{
Mutex,
Condvar
};
pub struct Channel< T > {
queue: Mutex< Vec< T > >,
condvar: Condvar
}
impl< T > Channel< T > {
pub const fn new() -> Self {
Cha... | code_fim | hard | {
"lang": "rust",
"repo": "unpluggedcoder/memory-profiler",
"path": "/preload/src/channel.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> guard.reserve( 1 );
guard.push( callback() );
length
}
pub fn flush( &self ) {
self.condvar.notify_all();
}
#[allow(dead_code)]
pub fn len( &self ) -> usize {
self.queue.lock().len()
}
}<|fim_prefix|>// repo: unpluggedcoder/memory-profiler ... | code_fim | hard | {
"lang": "rust",
"repo": "unpluggedcoder/memory-profiler",
"path": "/preload/src/channel.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns `ProofMapIndex` with wallets.
pub fn transfer_proposals(&self) -> ProofMapIndex<&T, Hash, TransferProposal> {
ProofMapIndex::new("cryptocurrency.transfer_proposals", &self.view)
}
/// Returns proposals for the given tranfer hash.
pub fn transfer_proposal(&self, has... | code_fim | hard | {
"lang": "rust",
"repo": "ruslansalikhov/exonum-cryptocurrency-multisig",
"path": "/backend/src/schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create new transfer proposal.
pub fn create_transfer_proposal(&mut self, from: &String, to: &String, amount: u64, seed: u64) {
let transfer_proposal = TransferProposal::new(from, to, amount, seed, 1);
self.transfer_proposals_mut().put(&transfer_proposal.hash(), transfer_proposa... | code_fim | hard | {
"lang": "rust",
"repo": "ruslansalikhov/exonum-cryptocurrency-multisig",
"path": "/backend/src/schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruslansalikhov/exonum-cryptocurrency-multisig path: /backend/src/schema.rs
// Copyright 2019 The Exonum Team
//
// 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
//
// ... | code_fim | hard | {
"lang": "rust",
"repo": "ruslansalikhov/exonum-cryptocurrency-multisig",
"path": "/backend/src/schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// The first block in the chain, just a list of `Transaction`s.
#[derive(Debug, Serialize, Deserialize)]
pub struct GenesisTransactions {
/// The transactions in the genesis block.
pub transactions: Vec<Signed<super::Transaction>>,
/// The timestamp of genesis block creation.
pub timestam... | code_fim | hard | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock-client-api/src/consensus/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dfriedenberger/Prellblock path: /prellblock-client-api/src/consensus/mod.rs
//! Consensus abstractions
use pinxit::Signed;
use serde::{Deserialize, Serialize};
use std::time::SystemTime;
mod block;
mod block_number;
mod leader_term;
mod signature_list;
<|fim_suffix|>/// The first block in the... | code_fim | medium | {
"lang": "rust",
"repo": "dfriedenberger/Prellblock",
"path": "/prellblock-client-api/src/consensus/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TerminalStudio/nativeshell path: /nativeshell/src/shell/platform/win32/display.rs
use std::{
cell::{Ref, RefCell},
cmp::{self, Ordering},
};
use crate::shell::{IPoint, IRect, Point, Rect};
use super::{all_bindings::*, flutter_sys::FlutterDesktopGetDpiForMonitor};
#[derive(Clone, Debug... | code_fim | hard | {
"lang": "rust",
"repo": "TerminalStudio/nativeshell",
"path": "/nativeshell/src/shell/platform/win32/display.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
displays.convert_logical_to_physical(&Point::xy(250.0, 250.0)),
Some(IPoint::xy(500, 500))
);
assert_eq!(
displays.convert_physical_to_logical(&IPoint::xy(2000, 500)),
Some(Point::xy(1040.0, 500.0))
);
as... | code_fim | hard | {
"lang": "rust",
"repo": "TerminalStudio/nativeshell",
"path": "/nativeshell/src/shell/platform/win32/display.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.n_rounds
}
fn sbox(&self) -> Sbox {
self.sbox.borrow().clone()
}
}
// from https://eprint.iacr.org/2012/529.pdf
#[cfg(test)]
mod test {
use crate::bit;
use crate::targets::{prince::Prince, Cipher};
#[test]
fn validate_encrypt() {
let prince = Pr... | code_fim | hard | {
"lang": "rust",
"repo": "Symmetric-Q/CryptaPath",
"path": "/cryptapath/src/targets/prince.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Symmetric-Q/CryptaPath path: /cryptapath/src/targets/prince.rs
use crate::sbox::Sbox;
use crate::targets::Cipher;
use crate::{bit, bit::Bit, bit::*};
use std::cell::RefCell;
pub struct Prince {
n_rounds: usize,
message_length: usize,
key_length: usize,
constants: Vec<Vec<Bit>>,
... | code_fim | hard | {
"lang": "rust",
"repo": "Symmetric-Q/CryptaPath",
"path": "/cryptapath/src/targets/prince.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(key.len() == self.key_length);
let (k0, k1, k0_prime) = match self.key_length {
128 => {
let k0 = key.iter().cloned().take(64).collect::<Vec<Bit>>();
let k1 = key.iter().cloned().skip(64).take(64).collect::<Vec<Bit>>();
le... | code_fim | hard | {
"lang": "rust",
"repo": "Symmetric-Q/CryptaPath",
"path": "/cryptapath/src/targets/prince.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mahkoh/linux-rs path: /src/util/retry.rs
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
<|fim_suffix|>#[cfg(feature = "retry-interrupted")]
... | code_fim | medium | {
"lang": "rust",
"repo": "mahkoh/linux-rs",
"path": "/src/util/retry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(feature = "retry-interrupted"))]
pub fn retry<T: SignedInt>(mut f: impl FnMut() -> T) -> Result<T> {
let ret = f();
if ret.negative() {
Err(Errno(-ret.cast_i64() as c_int))
} else {
Ok(ret)
}
}<|fim_prefix|>// repo: mahkoh/linux-rs path: /src/util/retry.rs
// Thi... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/linux-rs",
"path": "/src/util/retry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /rpc/src/rpc_subscriptions.rs
}));
let mut highest_confirmed_slot: Slot = 0;
let mut highest_root_slot: Slot = 0;
let mut last_notified_confirmed_slot: Slot = 0;
// Optimistically notifying slot 3 without notifying slot 1 and 2, b... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/rpc/src/rpc_subscriptions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn notify_signatures_received(&self, slot_signatures: (Slot, Vec<Signature>)) {
self.enqueue_notification(NotificationEntry::SignaturesReceived(slot_signatures));
}
pub fn notify_vote(&self, vote_pubkey: Pubkey, vote: VoteTransaction, signature: Signature) {
self.enqueue_n... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/rpc/src/rpc_subscriptions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /rpc/src/rpc_subscriptions.rs
lockUpdateError::UnsupportedTransactionVersion(version)
}
})?;
// If last_modified_slot < last_notified_slot, then the last notif was for a fork.
// That's the risk clients take when subscribing to non-finalized ... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/rpc/src/rpc_subscriptions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
impl Node<128> for Noise {
fn process(&mut self, _inputs: &[Input<128>], output: &mut [Buffer<128>]) {
output[0].iter_mut().for_each(|s| *s = self.sig.next() as f32);
}
}<|fim_prefix|>// repo: remaininlight/glicol path: /rs/synth/src/signal/noise.rs
use dasp_graph::{Buffer, Input, Node};... | code_fim | medium | {
"lang": "rust",
"repo": "remaininlight/glicol",
"path": "/rs/synth/src/signal/noise.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: remaininlight/glicol path: /rs/synth/src/signal/noise.rs
use dasp_graph::{Buffer, Input, Node};
use dasp_signal::{self as signal, Signal};
use super::super::{ GlicolNodeData, mono_node, NodeData, BoxedNodeSend};
<|fim_suffix|> output[0].iter_mut().for_each(|s| *s = self.sig.next() as f32... | code_fim | hard | {
"lang": "rust",
"repo": "remaininlight/glicol",
"path": "/rs/synth/src/signal/noise.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.