text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /testing/jormungandr-integration-tests/src/jcli/rest/host.rs
use jormungandr_automation::jcli::JCli;
#[test]
pub fn test_correct_error_is_returned_for_incorrect_host_syntax() {
let jcli: JCli = Default::default();
let incorrect_host = "not_a_correct_sy... | code_fim | medium | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/jcli/rest/host.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
pub fn test_correct_error_is_returned_for_incorrect_host_address() {
let jcli: JCli = Default::default();
// Port 9 is standard port discarding all requests
let incorrect_host = "http://127.0.0.1:9/api";
jcli.rest()
.v0()
.tip_expect_fail(incorrect_host, "tcp connec... | code_fim | medium | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-integration-tests/src/jcli/rest/host.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lazy_static! {
pub static ref GeneratorG1: GroupG1 = GroupG1::generator();
pub static ref GeneratorG2: GroupG2 = GroupG2::generator();
}<|fim_prefix|>// repo: octavonce/signature-schemes path: /src/bls/constants.rs
extern crate amcl;
use self::amcl::arch::Chunk;
use BLSCurve::rom;
use BLSCurve::... | code_fim | hard | {
"lang": "rust",
"repo": "octavonce/signature-schemes",
"path": "/src/bls/constants.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: octavonce/signature-schemes path: /src/bls/constants.rs
extern crate amcl;
use self::amcl::arch::Chunk;
use BLSCurve::rom;
use BLSCurve::big::{NLEN, MODBYTES as bls381_MODBYTES};
use super::types::{GroupG1, GroupG2};
<|fim_suffix|>lazy_static! {
pub static ref GeneratorG1: GroupG1 = GroupG... | code_fim | hard | {
"lang": "rust",
"repo": "octavonce/signature-schemes",
"path": "/src/bls/constants.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let prog = match parse_program().easy_parse(State::new(input)) {
Ok(p) => p,
Err(e) => {
eprintln!("{}", e);
process::exit(exitcode::USAGE);
},
};
if !prog.1.input.is_empty() {
eprintln!("{}", ParseError::LeftOver);
process::exit(... | code_fim | hard | {
"lang": "rust",
"repo": "scampi/falcon",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scampi/falcon path: /src/main.rs
#![recursion_limit = "256"]
use crate::{
errors::{EvaluationError, ParseError},
interpreter::Runtime,
parser::{ast::Program, program::parse_program},
};
use atty;
use combine::{parser::Parser, stream::state::State};
use exitcode;
use std::{
fs::{... | code_fim | hard | {
"lang": "rust",
"repo": "scampi/falcon",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl<E, A> ReceiveEvent<E, Self> for A
where
E: 'static,
A: Aggregate<E> + WithAggregateId,
{
fn receive_event(&mut self, event: DomainEventView<'_, E, Self>) {
self.apply_event(event);
}
}<|fim_prefix|>// repo: tdcare/eventmill path: /eventmill/src/query.rs
use crate::aggregat... | code_fim | medium | {
"lang": "rust",
"repo": "tdcare/eventmill",
"path": "/eventmill/src/query.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tdcare/eventmill path: /eventmill/src/query.rs
use crate::aggregate::{Aggregate, WithAggregateId};
use crate::event::DomainEventView;
<|fim_suffix|>impl<E, A> ReceiveEvent<E, Self> for A
where
E: 'static,
A: Aggregate<E> + WithAggregateId,
{
fn receive_event(&mut self, event: Domain... | code_fim | medium | {
"lang": "rust",
"repo": "tdcare/eventmill",
"path": "/eventmill/src/query.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn describe_i64(self) -> Result<Self::Ok, Self::Error>;
fn describe_i128(self) -> Result<Self::Ok, Self::Error>;
fn describe_isize(self) -> Result<Self::Ok, Self::Error>;
fn describe_u8(self) -> Result<Self::Ok, Self::Error>;
fn describe_u16(self) -> Result<Self::Ok, Self::Error>;
... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/schematic",
"path": "/src/describe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: randomPoison/schematic path: /src/describe.rs
use crate::{PrimitiveValue, TypeName};
// A *data structure* that can be described by schematic.
pub trait Describe: Sized {
// The unique name identifying the type.
fn type_name() -> TypeName;
fn describe<D>(describer: D) -> Result<D::... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/schematic",
"path": "/src/describe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait DescribeTupleStruct {
type Ok;
type Error;
fn describe_element<T: Describe>(&mut self) -> Result<(), Self::Error>;
fn end(self) -> Result<Self::Ok, Self::Error>;
}
pub trait DescribeEnum {
type Ok;
type Error;
type DescribeStructVariant: DescribeStructVariant<Er... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/schematic",
"path": "/src/describe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Records this command, returning a bool indicating whether it is stable.
#[must_use]
pub fn add(&mut self, dot: Dot) -> bool {
let count = self.dot_to_count.entry(dot).or_default();
*count += 1;
if *count == self.n {
self.dot_to_count.remove(&dot);
... | code_fim | medium | {
"lang": "rust",
"repo": "tuanir/fantoch",
"path": "/fantoch/src/protocol/gc/basic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tuanir/fantoch path: /fantoch/src/protocol/gc/basic.rs
use crate::id::Dot;
use crate::HashMap;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BasicGCTrack {
n: usize,
dot_to_count: HashMap<Dot, usize>,
}
<|fim_suffix|> /// Records this command, returning a bool indicating whether... | code_fim | medium | {
"lang": "rust",
"repo": "tuanir/fantoch",
"path": "/fantoch/src/protocol/gc/basic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wpickachu/polkadot-ethereum path: /parachain/pallets/dot-app/src/tests.rs
use crate::Config;
use crate::mock::{Test, AccountId, Balances, DOTApp, Event, Origin, System, new_tester};
use frame_support::{assert_noop, assert_ok,
dispatch::{
DispatchError,
},
traits::Currency,
};
use sp_keyring... | code_fim | hard | {
"lang": "rust",
"repo": "wpickachu/polkadot-ethereum",
"path": "/parachain/pallets/dot-app/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
Event::dot_app(crate::Event::<Test>::Unlocked(sender, recipient, amount)),
last_event()
);
});
}
#[test]
fn should_not_unlock_on_bad_origin_failure() {
new_tester().execute_with(|| {
let unknown_peer_contract = H160::repeat_byte(64);
let sender = H160::repeat_byte(7);
let re... | code_fim | hard | {
"lang": "rust",
"repo": "wpickachu/polkadot-ethereum",
"path": "/parachain/pallets/dot-app/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Juici/strife path: /src/model/gateway/presence.rs
//! Models related to Rich Presence.
use chrono::{DateTime, FixedOffset};
use serde::{Deserialize, Serialize};
use crate::model::gateway::activity::Activity;
use crate::model::id::{GuildId, RoleId, ToSnowflakeId, UserId};
use crate::model::user... | code_fim | hard | {
"lang": "rust",
"repo": "Juici/strife",
"path": "/src/model/gateway/presence.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let deserialized = PartialUser::deserialize(&value).unwrap();
assert_eq_fields!(user, deserialized);
}
#[test]
fn test_serialize_partial_user() {
let value = json!({
"id": "80351110224678912"
});
let user = PartialUser::Partial {
... | code_fim | hard | {
"lang": "rust",
"repo": "Juici/strife",
"path": "/src/model/gateway/presence.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /zircon/kernel/phys/efi/mkfatfs/src/main.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Error,
argh::FromArgs,
fatfs as _,
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/zircon/kernel/phys/efi/mkfatfs/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Record file sizes and directories to get a sense for the would-be size
// of the data region.
let mut files = HashMap::<String, FileWithPath>::new(); // destination -> source
let mut dirs = HashSet::<String>::new();
let mut num_clusters: u64 = 0;
for entry in entries {
/... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/zircon/kernel/phys/efi/mkfatfs/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The destination path within the filesystem, spelled with whatever form
// of slash the host uses for a path token.
pub destination: String,
}
// std::fs::File is a thin wrapper around a file descriptor and does not track
// any associated filepath.
pub struct FileWithPath {
pub file: F... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/zircon/kernel/phys/efi/mkfatfs/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/objc/src/test_utils.rs
use
std
:
:
ops
:
:
{
Deref
DerefMut
}
;
use
std
:
:
os
:
:
raw
:
:
c_char
;
use
std
:
:
sync
:
:
{
Once
ONCE_INIT
}
;
use
declare
:
:
{
ClassDecl
ProtocolDecl
}
;
use
runtime
:
:
{
Class
Object
Protocol
Sel
self
}
;
use
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/objc/src/test_utils.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(
foo
)
get_foo
)
;
let
get_struct
:
extern
fn
(
&
Object
Sel
)
-
>
CustomStruct
=
custom_obj_get_struct
;
decl
.
add_method
(
sel
!
(
customStruct
)
get_struct
)
;
let
class_method
:
extern
fn
(
&
Class
Sel
)
-
>
u32
=
custom_obj_class_method
;
decl
.
add_class_method
(
sel
!
(
classFoo
)
class_method
)... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/objc/src/test_utils.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: euclio/diesel path: /diesel/src/types/impls/decimal.rs
#[cfg(feature = "bigdecimal")]
mod bigdecimal {
ex<|fim_suffix|> queryable_impls!(Numeric -> bigdecimal::BigDecimal);
}<|fim_middle|>tern crate bigdecimal;
use types::Numeric;
expression_impls!(Numeric -> bigdecimal::BigDecimal)... | code_fim | medium | {
"lang": "rust",
"repo": "euclio/diesel",
"path": "/diesel/src/types/impls/decimal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ression_impls!(Numeric -> bigdecimal::BigDecimal);
queryable_impls!(Numeric -> bigdecimal::BigDecimal);
}<|fim_prefix|>// repo: euclio/diesel path: /diesel/src/types/impls/decimal.rs
#[cfg(feature = "bigdecimal")]
mod bigdecimal {
ex<|fim_middle|>tern crate bigdecimal;
use types::Numeric;
... | code_fim | easy | {
"lang": "rust",
"repo": "euclio/diesel",
"path": "/diesel/src/types/impls/decimal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let error = promise::Error::from(format!("promise error {}", 5678));
assert_eq!(error.to_string(), String::from("promise error 5678"));
}<|fim_prefix|>// repo: wolfgang/no-promises path: /src/_tests/promise_error_test.rs
use crate::promise;
#[test]
fn can_be_constructed_from_string() {
<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/no-promises",
"path": "/src/_tests/promise_error_test.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolfgang/no-promises path: /src/_tests/promise_error_test.rs
use crate::promise;
#[test]
fn can_be_constructed_from_string() {
<|fim_suffix|> let error = promise::Error::from(format!("promise error {}", 5678));
assert_eq!(error.to_string(), String::from("promise error 5678"));
}<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/no-promises",
"path": "/src/_tests/promise_error_test.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zingolabs/quizface path: /src/utils/logging.rs
use std::fs;
use std::path::Path;
const QUIZFACE_VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn name_logdirs() -> (String, String, String) {
let log_parent_template: String =
format!("./logs/{}/", create_version_name());
let ... | code_fim | hard | {
"lang": "rust",
"repo": "zingolabs/quizface",
"path": "/src/utils/logging.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn log_blessed_output(blessed: Vec<String>) {
let mut blessed_list = String::new();
for command in blessed {
blessed_list = blessed_list + &command + "\n"
}
fs::write(format!("{}blessed.txt", name_logdirs().2), blessed_list)
.expect("panic during fs::write blessed!");
}... | code_fim | hard | {
"lang": "rust",
"repo": "zingolabs/quizface",
"path": "/src/utils/logging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/RVM1.5 path: /crates/uart_16550/src/lib.rs
//! Minimal support for uart_16550 serial I/O.
//!
//! # Usage
//!
//! ```no_run
//! use uart_16550::SerialPort;
//!
//! const SERIAL_IO_PORT: u16 = 0x3F8;
//!
//! let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
//! serial_port... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/RVM1.5",
"path": "/crates/uart_16550/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Enable FIFO, clear TX/RX queues and
// set interrupt watermark at 14 bytes
self.fifo_ctrl.write(0xC7);
// Mark data terminal ready, signal request to send
// and enable auxilliary output #2 (used as interrupt line for CPU)
self.mo... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/RVM1.5",
"path": "/crates/uart_16550/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Trait defining all possible methods
pub trait PyAPI:
method::New +
method::Init +
method::Delete +
method::GetAttr +
method::GetAttribute +
method::SetAttr +
method::DelAttr +
method::Hashed +
method::StringCast +
method::BytesCast +
method::StringFormat +
method::StringRepresentation +
method::Equal ... | code_fim | hard | {
"lang": "rust",
"repo": "dillonhicks/rsnek",
"path": "/rsnek/src/api/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dillonhicks/rsnek path: /rsnek/src/api/mod.rs
//! The core of the API are defined by the trait `PyAPI` and struct `RtObject`.
//! The `PyAPI` trait is the union of all possible Object method traits that any
//! type used in the `Runtime` must implement. `RtObject` is a reference counted
//! wrap... | code_fim | hard | {
"lang": "rust",
"repo": "dillonhicks/rsnek",
"path": "/rsnek/src/api/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/daemon/protocols/testing/src/lib.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Result, async_trait::async_trait, f... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/daemon/protocols/testing/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait(?Send)]
impl FidlProtocol for Testing {
type Protocol = ffx::TestingMarker;
type StreamHandler = FidlStreamHandler<Self>;
async fn handle(&self, _cx: &Context, req: ffx::TestingRequest) -> Result<()> {
match req {
// Hang intends to block the reactor indefini... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/daemon/protocols/testing/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Capacity in bytes
println!("Capacity is {}",string1.capacity());
// 是否为空
println!("string1 为空吗{}",string1.is_empty());
// 是否包含
println!("string1 包含 Y 吗{}",string1.contains("Y"));
// 替换
println!("string1 中将Y 替换为X :{}", string1.replace("Y","X"));
// 通过空格进行分割 并循环打印
... | code_fim | hard | {
"lang": "rust",
"repo": "Naruto-1996/rust_learnings",
"path": "/src/string_learnings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // String 的push方法只能在String的末尾添加一个字符
string1.push('Y');
println!("添加了Y之后 :{}",string1);
string1.push('\u{1f4a9}');
println!("添加了表情之后 :{}",string1);
// 如果想要 添加字符串的话 可以使用 push_str()
string1.push_str("World");
println!("使用push_str()方法添加字符串了之后 :{}",string1);
// Capacity in ... | code_fim | medium | {
"lang": "rust",
"repo": "Naruto-1996/rust_learnings",
"path": "/src/string_learnings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Naruto-1996/rust_learnings path: /src/string_learnings.rs
// 字符串的学习
pub fn string_test() {
// &str 这种类型不可以改变 而且不具有这个字符串的拥有权
let test_string = "你好 我是rust";
println!("字节如下:{:?}", test_string.as_bytes());
println!("test {}", test_string);
// 如果 想要拥有这个字符串 可以进行以下代码
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "Naruto-1996/rust_learnings",
"path": "/src/string_learnings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alpiro/fdec path: /src/binomial.rs
/// Binomial coefficients iterator.
pub(crate) struct Binomial {
n: u64,
idx: u64,
}
impl Binomial {
/// Creates a binomial coefficients iterator for the given `n`.
pub fn new(n: u32) -> Binomial {
Binomial {
n: n as u64,
... | code_fim | hard | {
"lang": "rust",
"repo": "alpiro/fdec",
"path": "/src/binomial.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_binomial() {
assert_binomial(0, &[1]);
assert_binomial(1, &[1, 1]);
assert_binomial(2, &[1, 2, 1]);
assert_binomial(3, &[1, 3, 3, 1]);
assert_binomial(4, &[1, 4, 6, 4, 1]);
assert_binomial(5, &[1, 5, 10, 10, 5, 1]);
}
fn asse... | code_fim | hard | {
"lang": "rust",
"repo": "alpiro/fdec",
"path": "/src/binomial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_chain_iter(&cmds[1..], next)
} else {
Err("Could not open stdout".to_string())
}
}
},
Err(e) => Err(e)
}
}
fn use_std_io(io_path: &CmdIO) -> Stdio {
match io_path {
&CmdIO::File(path) =... | code_fim | hard | {
"lang": "rust",
"repo": "shterrett/rust-os-class",
"path": "/ps3/src/external.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shterrett/rust-os-class path: /ps3/src/external.rs
// Copied with modification from ps2
use std::process::{ Command, Stdio, Child };
use cmd_line::{ CmdLine, CmdIO };
use std::fs::OpenOptions;
use std::error::Error;
pub fn run(cmd: &CmdLine) -> Result<Child, String> {
let stdin = use_std_i... | code_fim | hard | {
"lang": "rust",
"repo": "shterrett/rust-os-class",
"path": "/ps3/src/external.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match io_path {
&CmdIO::File(path) => {
let mut options = OpenOptions::new();
let file = options.read(true).write(true).truncate(true).open(path).unwrap();
Stdio::from(file)
},
&CmdIO::Console => Stdio::piped(),
&CmdIO::Pipe => Stdio:... | code_fim | hard | {
"lang": "rust",
"repo": "shterrett/rust-os-class",
"path": "/ps3/src/external.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jianshu93/block-aligner path: /examples/block_img.rs
#[cfg(not(feature = "simd_avx2"))]
fn main() {}
#[cfg(feature = "simd_avx2")]
fn main() {
use block_aligner::scan_block::*;
use block_aligner::scores::*;
use block_aligner::cigar::*;
use image::{Rgb, RgbImage, ColorType};
... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/block-aligner",
"path": "/examples/block_img.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> draw_filled_rect_mut(&mut img, Rect::at(x, y).of_size(width, height), fg_color);
draw_hollow_rect_mut(&mut img, Rect::at(x, y).of_size(width, height), bg_color);
}
let mut x = cell_size / 2;
let mut y = cell_size / 2;
let vec = cigar.to_vec();
... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/block-aligner",
"path": "/examples/block_img.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 1 => Ok(Self::Eof),
2 => Ok(Self::NoSuchFile),
3 => Ok(Self::PermissionDenied),
4 => Ok(Self::Failure),
5 => Ok(Self::BadMessage),
6 => Ok(Self::NoConnection),
7 => Ok(Self::ConnectionLost),
8 => Ok(Self::OpUns... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/wezterm",
"path": "/wezterm-ssh/src/sftp/error.rs",
"mode": "spm",
"license": "OFL-1.1",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quark-zju/wezterm path: /wezterm-ssh/src/sftp/error.rs
use std::convert::TryFrom;
use thiserror::Error;
/// Represents a result whose error is [`SftpError`]
pub type SftpResult<T> = Result<T, SftpError>;
/// Represents errors associated with sftp operations
#[derive(Copy, Clone, Debug, Error, ... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/wezterm",
"path": "/wezterm-ssh/src/sftp/error.rs",
"mode": "psm",
"license": "OFL-1.1",
"source": "the-stack-v2"
} |
<|fim_suffix|> // "Using a field in the order by that is not part of the selected fields" should "work"
#[connector_test]
async fn order_by_not_selected(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"
mutation {
createOneFoo(
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/order_and_pagination/order_by_mutation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create the node-api client and set the signer.
let client = JsonrpseeClient::with_default_url().unwrap();
let signer = AccountKeyring::Alice.pair();
let mut api = Api::<AssetRuntimeConfig, _>::new(client).unwrap();
api.set_signer(ExtrinsicSigner::<AssetRuntimeConfig>::new(signer.clone()));
// Fi... | code_fim | hard | {
"lang": "rust",
"repo": "scs/substrate-api-client",
"path": "/examples/examples/get_account_identity.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Send and watch extrinsic until InBlock.
let _block_hash = api
.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
.unwrap()
.block_hash
.unwrap();
// Get the storage value from the pallet. Check out the pallet itself to know it's type:
// see https://github.com/paritytech/substrate/bl... | code_fim | hard | {
"lang": "rust",
"repo": "scs/substrate-api-client",
"path": "/examples/examples/get_account_identity.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scs/substrate-api-client path: /examples/examples/get_account_identity.rs
/*
Copyright 2019 Supercomputing Systems AG
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
ht... | code_fim | hard | {
"lang": "rust",
"repo": "scs/substrate-api-client",
"path": "/examples/examples/get_account_identity.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The Workflow Execution has finished successfully.
Succeeded = 2,
/// The Workflow Execution failed with an error.
Failed = 3,
/// The Workflow Execution has been stopped intentionally.
Cancelled = 4,
}
/// Detailed log information.
#[derive(C... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.workflows.r#type.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/googapis path: /googapis/genproto/google.cloud.workflows.r#type.rs
/// Logged during the lifetime of Workflow Execution.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutionsSystemLog {
/// Human readable contents of the log in English. The size limit is 5 kB.
#[p... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.workflows.r#type.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>n message, e.g. "division by zero". The size limit is 1 kB.
#[prost(string, tag = "1")]
pub exception: ::prost::alloc::string::String,
/// The code location of the statement that has created the log. For example,
/// a log created in subworkflow 'Foo' in step 'bar' will hav... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/googapis",
"path": "/googapis/genproto/google.cloud.workflows.r#type.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let meshes = Rule::new()
.push(Replicate::n(4, Tf::ty(1.0)), RandCube {})
.generate();
let mut output = File::create("randtower.obj").expect("obj file");
write_meshes(ExportConfig::default(), meshes, &mut output).expect("rendered scene");
}<|fim_prefix|>// rep... | code_fim | hard | {
"lang": "rust",
"repo": "alpn/immense",
"path": "/examples/randtower.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alpn/immense path: /examples/randtower.rs
use immense::*;
use rand::*;
use std::fs::File;
#[derive(Debug)]
struct RandCube;
impl ToRule for RandCube {
fn to_rule(&self) -> Rule {
<|fim_suffix|>fn main() {
let meshes = Rule::new()
.push(Replicate::n(4, Tf::ty(1.0)), R... | code_fim | medium | {
"lang": "rust",
"repo": "alpn/immense",
"path": "/examples/randtower.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobdillon/advent-rs path: /day2/src/main.rs
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
use std::cmp::min;
fn main() {
// Paper and ribbon variables
let mut paper = 0;
let mut ribbon = 0;
// Open file and read it into buffer
let f = File::open("input"... | code_fim | hard | {
"lang": "rust",
"repo": "jacobdillon/advent-rs",
"path": "/day2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add the extra paper needed
paper += smallest_side;
// Calculate the volume of the present
ribbon += l * w * h;
// Add the extra ribbon needed
if smallest_side == l * w {
ribbon += l + l + w + w
} else if smallest_side == w * h {
... | code_fim | medium | {
"lang": "rust",
"repo": "jacobdillon/advent-rs",
"path": "/day2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Expect the path to a single bundled JS source file to execute
let args: Vec<String> = env::args().collect();
let source_path: &str = &args[1][..];
lib::run_local(source_path);
}<|fim_prefix|>// repo: mbrevoort/tinker-with-deno-runtime-crate path: /src/main.rs
use std::env;
mod lib;
<|fim_mid... | code_fim | easy | {
"lang": "rust",
"repo": "mbrevoort/tinker-with-deno-runtime-crate",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbrevoort/tinker-with-deno-runtime-crate path: /src/main.rs
use std::env;
mod lib;
<|fim_suffix|> // Expect the path to a single bundled JS source file to execute
let args: Vec<String> = env::args().collect();
let source_path: &str = &args[1][..];
lib::run_local(source_path);
}<|fim_mid... | code_fim | easy | {
"lang": "rust",
"repo": "mbrevoort/tinker-with-deno-runtime-crate",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: filiprejmus/algeng path: /src/branch.rs
use crate::*;
use crate::{HashMap, HashSet};
#[must_use]
pub fn branch(s: State) -> Vec<State> {
let v = max_degree(&s.graph);
let mut branches:Vec<State> = vec![];
let s_clone = s.clone();
if let Some(s1) = branch_left(s,v) {branches.push... | code_fim | hard | {
"lang": "rust",
"repo": "filiprejmus/algeng",
"path": "/src/branch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn is_mirror(g: &Graph, u:Vx, n_v: &HashSet<Vx>)->bool{
let induced: HashSet<Vx> = n_v.difference(g.neighbours_hashset(u).unwrap()).cloned().collect();
//Check if induced is a (possibly empty) clique
for w in &induced {
if !induced.iter().all(|&v| (v==*w || g.get_edge(v, *w))){return... | code_fim | hard | {
"lang": "rust",
"repo": "filiprejmus/algeng",
"path": "/src/branch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: advaiyalad/use-github-api-rs path: /src/test_utils.rs
#[macro_export]
macro_rules! mock_response {
($client:expr, $mod:literal, $fn:literal, $cfg:expr) => {{
use std::fs::read_to_string;
let cfg = format!("{:#?}", $cfg).replace(": ", "-").replace("\n", "").replace(" "<|fim_su... | code_fim | hard | {
"lang": "rust",
"repo": "advaiyalad/use-github-api-rs",
"path": "/src/test_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>]
let filename = format!("./tests/files/{mod}/{fn}/{cfg}.json", mod=$mod, fn=$fn, cfg=cfg);
dbg!(&filename);
#[cfg(feature = "auth")]
if $client.client.default_headers.get("Authorization").unwrap() == &format!("token {}", crate::constants::BAD_FAKE_TOKEN).parse::<::reqwest:... | code_fim | hard | {
"lang": "rust",
"repo": "advaiyalad/use-github-api-rs",
"path": "/src/test_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>format!("token {}", crate::constants::BAD_FAKE_TOKEN).parse::<::reqwest::header::HeaderValue>().unwrap() {
filename = "./tests/files/Bad_creds.json".to_owned();
}
read_to_string(filename).unwrap()
}};
}<|fim_prefix|>// repo: advaiyalad/use-github-api-rs path: /src/test_uti... | code_fim | hard | {
"lang": "rust",
"repo": "advaiyalad/use-github-api-rs",
"path": "/src/test_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: junikimm717/gradecalc path: /src/categories.rs
#[derive(Debug)]
pub enum Score {
Points(f64, f64),
Percentage(f64),
}
#[derive(Debug)]
pub struct Category {
pub name: String,
pub weight: f64,
pub scores: Vec<Score>,
}
impl Category {
fn all_points(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "junikimm717/gradecalc",
"path": "/src/categories.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn average(v: Vec<Category>) -> Result<f64, ()> {
let mut sum: f64 = 0 as f64;
let mut weights: f64 = 0 as f64;
for cat in v {
if cat.scores.len() == 0 {
continue;
}
weights += cat.weight;
sum += cat.weight
* match cat.avg() {
... | code_fim | hard | {
"lang": "rust",
"repo": "junikimm717/gradecalc",
"path": "/src/categories.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benkay86/matlab-ndarray-tutorial path: /rust/src/bin/functions.rs
//! Writing functions that do linear algebra.
//!
//! Writing functions that take a concrete type such as
//! `Array<f64, Dim<[Ix; 1]>>` is easy. The function can borrow the array `&`,
//! mutably borrow the array `&mut` to modif... | code_fim | hard | {
"lang": "rust",
"repo": "benkay86/matlab-ndarray-tutorial",
"path": "/rust/src/bin/functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
Data: ndarray::Data<Elem = F>,
Dim: ndarray::Dimension,
F: Float,
{
arr + F::from_real(F::real(2))
}
fn main() {
// Make an array and a scalar to add togehter.
let arr = ndarray::array![1., 2., 3.];
let scal = 2.;
// Test out each of our functions above.
println... | code_fim | hard | {
"lang": "rust",
"repo": "benkay86/matlab-ndarray-tutorial",
"path": "/rust/src/bin/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get() -> MutexGuard<'static, Wallet> {
WALLET.lock().unwrap()
}
}
pub fn main() {
Wallet::get().print_amount();
Wallet::get().set_amount(42f64);
Wallet::get().print_amount();
}<|fim_prefix|>// repo: alexander-smoktal/rust-patterns path: /src/creational/singleton.rs
#[macro... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-smoktal/rust-patterns",
"path": "/src/creational/singleton.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexander-smoktal/rust-patterns path: /src/creational/singleton.rs
#[macro_use]
extern crate lazy_static;
use std::sync::{Mutex, MutexGuard};
lazy_static! {
static ref WALLET: Mutex<Wallet> = Mutex::new(Wallet::new());
}
#[derive(Debug)]
pub struct Wallet {
amount: f64,
}
impl Wallet... | code_fim | medium | {
"lang": "rust",
"repo": "alexander-smoktal/rust-patterns",
"path": "/src/creational/singleton.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Wallet amount: {}", self.amount);
}
fn get() -> MutexGuard<'static, Wallet> {
WALLET.lock().unwrap()
}
}
pub fn main() {
Wallet::get().print_amount();
Wallet::get().set_amount(42f64);
Wallet::get().print_amount();
}<|fim_prefix|>// repo: alexander-smokta... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-smoktal/rust-patterns",
"path": "/src/creational/singleton.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hugodutka/sk-big-2-rust path: /src/telnet.rs
use crate::channels::{CHANNEL_MODEL_S, CHANNEL_TELNET_R};
use crate::events::{EventModel, EventTelnet};
use anyhow::{Context, Result};
use lazy_static::lazy_static;
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::sync::{Arc, ... | code_fim | hard | {
"lang": "rust",
"repo": "hugodutka/sk-big-2-rust",
"path": "/src/telnet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *WRITE_HANDLE.lock().unwrap() = None;
thread::spawn(|| TelnetServer::new(SERVER_HOST, SERVER_PORT + 2).start());
thread::spawn(|| TelnetServer::start_writer());
for _ in 0..100 {
match TcpStream::connect((SERVER_HOST, SERVER_PORT + 2)) {
... | code_fim | hard | {
"lang": "rust",
"repo": "hugodutka/sk-big-2-rust",
"path": "/src/telnet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn telnet_writer_reacts_to_events() {
const INPUT: &'static [u8] = &[6, 7, 8, 9, 10];
*WRITE_HANDLE.lock().unwrap() = None;
thread::spawn(|| TelnetServer::new(SERVER_HOST, SERVER_PORT + 2).start());
thread::spawn(|| TelnetServer::st... | code_fim | hard | {
"lang": "rust",
"repo": "hugodutka/sk-big-2-rust",
"path": "/src/telnet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wraikny/kaisendon_saba path: /src/json.rs
// use serde::{Deserialize, Serialize};
use super::{
state::{
user::{UserID},
},
game::{RoomID},
};
#[derive(Debug, Serialize)]
#[serde(tag = "tag", content = "content")]
pub enum JsonResult<T, E> {
Ok(T),
Err(E),
}
<|fim_su... | code_fim | hard | {
"lang": "rust",
"repo": "wraikny/kaisendon_saba",
"path": "/src/json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, E> From<Result<T, E>> for JsonResult<T, String>
where E : std::string::ToString,
{
fn from(r: Result<T, E>) -> Self {
match r {
Ok(t) => JsonResult::Ok(t),
Err(e) => JsonResult::Err(e.to_string()),
}
}
}
#[derive(Debug, Deserialize)]
pub struct ... | code_fim | medium | {
"lang": "rust",
"repo": "wraikny/kaisendon_saba",
"path": "/src/json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Cow reference type
pub type CowRef<T> = Arc<RwLock<Cow<T>>>;
/// Cow weak reference type
pub type CowWeakRef<T> = Weak<RwLock<Cow<T>>>;
/// Wrap value into Cow reference
pub trait IntoCow<'de>
where
Self: Debug
+ Default
+ Send
+ Sync
+ CloneNew
+ Persista... | code_fim | hard | {
"lang": "rust",
"repo": "shadowshows/zbox",
"path": "/src/trans/cow.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowshows/zbox path: /src/trans/cow.rs
use std::fmt::{self, Debug};
use std::sync::{Arc, RwLock, Weak};
use std::clone::Clone;
use std::default::Default;
use std::ops::Deref;
use serde::{Deserialize, Serialize};
use error::{Error, Result};
use base::IntoRef;
use base::lru::{Lru, CountMeter, ... | code_fim | hard | {
"lang": "rust",
"repo": "shadowshows/zbox",
"path": "/src/trans/cow.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2015/day18/src/grid.rs
use std::cmp::{min, max};
use std::fmt::{Debug, Error, Formatter, Write};
use std::fs::File;
use std::io::{BufRead, BufReader};
pub struct Grid {
cells: Vec<Vec<bool>>
}
impl Grid {
pub fn parse(filename: &str) -> Grid {
... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2015/day18/src/grid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let grid = Grid::parse("data/example.txt");
assert!(!grid.cells[0][0]);
assert!(grid.cells[1][3]);
}
#[test]
fn test_live_neighbours() {
let grid = Grid::parse("data/example.txt");
assert_eq!(grid.live_neighbours(0, 0), 1);
assert_eq!(grid.live_... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2015/day18/src/grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Response {
/// Creates a new `Response` with the given aliases.
pub fn new(aliases: Vec<RoomAliasId>) -> Self {
Self { aliases }
}
}<|fim_prefix|>// repo: kroeckx/ruma path: /crates/ruma-client-api/src/r0/room/aliases.rs
//! [GET /_matrix/client/r0/rooms/{roomId}/aliases](https:/... | code_fim | medium | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-client-api/src/r0/room/aliases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kroeckx/ruma path: /crates/ruma-client-api/src/r0/room/aliases.rs
//! [GET /_matrix/client/r0/rooms/{roomId}/aliases](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases)
<|fim_suffix|> request: {
/// The room ID to get aliases of.
#[ru... | code_fim | hard | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-client-api/src/r0/room/aliases.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> response: {
/// The server's local aliases on the room.
pub aliases: Vec<RoomAliasId>,
}
error: crate::Error
}
impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID.
pub fn new(room_id: &'a RoomId) -> Self {
Self { room_id }
}
}
impl R... | code_fim | hard | {
"lang": "rust",
"repo": "kroeckx/ruma",
"path": "/crates/ruma-client-api/src/r0/room/aliases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: binh-vu/rython path: /src_backup/types.rs
use std::borrow::Cow;
use std::ops::Add;
#[derive(Debug, Clone)]
pub enum SingleType {
Str,
I64,
F64,
}
#[derive(Debug, Clone)]
pub enum VarType {
Single(SingleType),
List(SingleType),
Dict((SingleType, SingleType)),
}
<|fim_suffix|>impl T... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/rython",
"path": "/src_backup/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Type for Str {}
impl Type for i64 {}
impl Type for f64 {}
impl Type for Vec<Str> {}
impl Type for Vec<i64> {}
impl Type for Vec<f64> {}
impl VarType {
pub fn is_number(&self) -> bool {
match self {
VarType::Single(t) => {
match t {
SingleType::Str => false,
Si... | code_fim | hard | {
"lang": "rust",
"repo": "binh-vu/rython",
"path": "/src_backup/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let index_buffer = &self.index_buffers[precision];
index_buffer.get_or_init(move || {
let indices: RefMap<_, _, [u32]> = RefMap::new(self.source.clone(), move |s| s.precisions()[precision].indices());
loader.load(indices, buffer::Usage::IndexBuffer, sharing_queues)
}).get()
}
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "waonder-rs/engine",
"path": "/src/view/geometry/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waonder-rs/engine path: /src/view/geometry/mod.rs
use std::{
rc::Rc,
sync::Arc
};
use magma::{
mem::{
buffer
},
sync::SharingQueues
};
use crate::util::RefMap;
use crate::sync::{
Loader,
loader::Loading,
};
use once_cell::unsync::OnceCell;
pub mod projection;
pub use projection::Projec... | code_fim | hard | {
"lang": "rust",
"repo": "waonder-rs/engine",
"path": "/src/view/geometry/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn vertex_buffer(&self, loader: &Loader, sharing_queues: SharingQueues) -> Option<&Arc<buffer::Bound>> {
self.vertex_buffer.get_or_init(move || {
let vertices: RefMap<_, _, [u8]> = RefMap::new(self.source.clone(), |s| s.vertices());
loader.load_untyped(vertices, buffer::Usage::VertexBuffer, s... | code_fim | hard | {
"lang": "rust",
"repo": "waonder-rs/engine",
"path": "/src/view/geometry/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NickDriscoll/whee_tanks path: /src/render.rs
use gl::types::*;
use ozy_engine::{glutil, routines};
use std::collections::HashMap;
use std::mem;
use std::ptr;
use std::os::raw::c_void;
use crate::DEFAULT_TEX_PARAMS;
pub const MAP_COUNT: usize = 3; //[albedo, normal, roughness]
pub struct S... | code_fim | hard | {
"lang": "rust",
"repo": "NickDriscoll/whee_tanks",
"path": "/src/render.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Framebuffer {
pub unsafe fn bind(&self) {
gl::BindFramebuffer(gl::FRAMEBUFFER, self.name);
gl::Viewport(0, 0, self.size.0, self.size.1);
gl::Clear(self.clear_flags);
gl::CullFace(self.cull_face);
}
}
impl Drop for Framebuffer {
fn drop(&mut self) {
... | code_fim | hard | {
"lang": "rust",
"repo": "NickDriscoll/whee_tanks",
"path": "/src/render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futurepaul/amethyst path: /amethyst_renderer/src/pipe/pass.rs
//! Types for constructing render passes.
#![allow(missing_docs)]
use std::marker::PhantomData;
use rayon::iter::ParallelIterator;
use rayon::iter::internal::UnindexedConsumer;
use rayon_core;
use specs::SystemData;
use error::Resu... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/amethyst",
"path": "/amethyst_renderer/src/pipe/pass.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<P> CompiledPass<P> {
pub fn apply<'a, 'b: 'a>(
&'a mut self,
encoders: &'a mut [Encoder],
data: <P as PassData<'b>>::Data,
) -> <P as PassApply<'a>>::Apply
where
P: Pass,
{
if encoders.len() > self.effects.len() {
let effect = self.e... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/amethyst",
"path": "/amethyst_renderer/src/pipe/pass.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_deep_nesting_repeated() {
fn build_and_roundtrip(depth: usize) -> Result<(), prost::DecodeError> {
use crate::nesting::C;
let mut c = C::default();
for _ in 0..depth {
let mut next = C::default();
next.r.p... | code_fim | hard | {
"lang": "rust",
"repo": "KaiserKarel/prosit",
"path": "/tests/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_custom_type_attributes() {
// We abuse the ident conversion protobuf for the custom attribute additions. We placed
// `Ord` on the FooBarBaz (which is not implemented by ordinary messages).
let mut set1 = BTreeSet::new();
let msg1 = foo::bar_baz::Foo... | code_fim | hard | {
"lang": "rust",
"repo": "KaiserKarel/prosit",
"path": "/tests/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaiserKarel/prosit path: /tests/src/lib.rs
num_value {
include!(concat!(env!("OUT_DIR"), "/default_enum_value.rs"));
}
pub mod groups {
include!(concat!(env!("OUT_DIR"), "/groups.rs"));
}
pub mod proto3 {
pub mod presence {
include!(concat!(env!("OUT_DIR"), "/proto3.presenc... | code_fim | hard | {
"lang": "rust",
"repo": "KaiserKarel/prosit",
"path": "/tests/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut dim = vec![1; 1024];
dim[16] = 4;
dim[17] = 3;
let z = Array::<f32, _>::zeros(dim.clone());
assert_eq!(z.shape(), &dim[..]);
}
#[test]
fn dyn_insert() {
let mut v = vec![2, 3, 4, 5];
let mut dim = Dim(v.clone());
defmac!(test_insert index => {
dim = dim.ins... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ndarray/ndarray",
"path": "/tests/dimension.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-ndarray/ndarray path: /tests/dimension.rs
#![allow(clippy::float_cmp)]
use defmac::defmac;
use ndarray::{arr2, ArcArray, Array, Axis, Dim, Dimension, IxDyn, RemoveAxis};
use std::hash::{Hash, Hasher};
#[test]
fn insert_axis() {
assert_eq!(Dim([]).insert_axis(Axis(0)), Dim([1]));
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ndarray/ndarray",
"path": "/tests/dimension.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let strides = Dim([-2isize as usize, 8, -4isize as usize, -1isize as usize]);
let order = strides._fastest_varying_stride_order();
assert_eq!(order.slice(), &[3, 0, 2, 1]);
assert_eq!(Dim([1, 3])._fastest_varying_stride_order(), Dim([0, 1]));
assert_eq!(
Dim([1, -3isize as usi... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ndarray/ndarray",
"path": "/tests/dimension.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn browser() -> Browser {
unsafe { js!( console.log("BROWSER:", browser); return browser; ).into_reference_unchecked() }.unwrap()
}
impl Browser {
pub fn sync_storage(&self) -> SyncStorage {
unsafe {
js!(
return @{self}.storage.sync;
)
... | code_fim | medium | {
"lang": "rust",
"repo": "nndii/readlater-temporary",
"path": "/src/browser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> console.log("ACTIVE_TABS", @{self}.tabs);
const active_tabs = @{self}.tabs.query({
currentWindow: true,
active: true,
});
console.log("ACTIVE_TABS", active_tabs);
return active_tabs[0];
).try_into().unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "nndii/readlater-temporary",
"path": "/src/browser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.