text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: pchickey/cap-std path: /tests/canonicalize.rs
#[macro_use]
mod sys_common;
use std::path::Path;
use sys_common::io::tmpdir;
#[test]
fn canonicalize_dot() {
let tmpdir = tmpdir();
assert_eq!(check!(tmpdir.canonicalize(".")), Path::new("."));
}
#[test]
fn canonicalize_edge_cases() {
... | code_fim | hard | {
"lang": "rust",
"repo": "pchickey/cap-std",
"path": "/tests/canonicalize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> check!(tmpdir.create_dir_all("foo/bar"));
assert_eq!(check!(tmpdir.canonicalize("foo")), Path::new("foo"));
assert_eq!(check!(tmpdir.canonicalize("foo/")), Path::new("foo"));
assert_eq!(check!(tmpdir.canonicalize("foo/")).to_str(), Some("foo"));
assert_eq!(check!(tmpdir.canonicalize("f... | code_fim | hard | {
"lang": "rust",
"repo": "pchickey/cap-std",
"path": "/tests/canonicalize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output.step(&format!("[{}]", validation.name));
let arguments: Vec<&str> = validation.command.iter().map(|s| &**s).collect();
let pushed = output.push();
subprocess::run_cmd(arguments, |line| pushed.error(line))?;
output.success(&format!("[{}] - OK", validation.na... | code_fim | hard | {
"lang": "rust",
"repo": "purposed/landlord",
"path": "/src/publib/validator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: purposed/landlord path: /src/publib/validator.rs
use std::collections::HashMap;
use anyhow::Result;
use rood::cli::OutputManager;
use crate::lease::Validation;
use crate::stacks::go::GoValidator;
use crate::stacks::rust::RustValidator;
use crate::subprocess;
use crate::{Project, ProjectStack,... | code_fim | hard | {
"lang": "rust",
"repo": "purposed/landlord",
"path": "/src/publib/validator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> filters.iter()
.find_map(|filter| match filter {
TxFilter::SortBy(sort) => {
match sort {
SortKey::TxHash => Some(object!{"tokenDetails.tokenIdHex" => 1}),
}
},
_ => None,
... | code_fim | hard | {
"lang": "rust",
"repo": "slpdex/slpdexdb",
"path": "/slpdexdb_db/src/token_source.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slpdex/slpdexdb path: /slpdexdb_db/src/token_source.rs
use crate::endpoint::Endpoint;
use crate::tx_source::{TxFilter, SortKey};
use cashcontracts::tx_hash_to_hex;
use json::{JsonValue, object, object::Object};
pub struct TokenSource {
endpoint: Endpoint
}
pub mod token_result {
use se... | code_fim | hard | {
"lang": "rust",
"repo": "slpdex/slpdexdb",
"path": "/slpdexdb_db/src/token_source.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = insert_into(dsl::items)
.values(&data)
.get_result(&mut connection)?;
Ok(result)
}
fn delete_item(ctx: &Context, id: ID) -> FieldResult<Item> {
use schema::items::dsl;
let mut connection = ctx.connection()?;
let resul... | code_fim | hard | {
"lang": "rust",
"repo": "dacioromero/hello-rust",
"path": "/graphql-server/src/graphql.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dacioromero/hello-rust path: /graphql-server/src/graphql.rs
use crate::models::*;
use crate::schema;
use diesel::{
delete, insert_into,
pg::PgConnection,
r2d2::{ConnectionManager, Pool, PoolError, PooledConnection},
update, ExpressionMethods, QueryDsl, RunQueryDsl,
};
use juniper... | code_fim | hard | {
"lang": "rust",
"repo": "dacioromero/hello-rust",
"path": "/graphql-server/src/graphql.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = (read & 0b01111111) as u64;
result |= value << (7 * count);
count += 1;
if count > 10 {
return Err(SerdeError::DeserializeError(
"VarLong too long.".to_string(),
));
}
(read & 0b10000000) > 0
} {}
... | code_fim | hard | {
"lang": "rust",
"repo": "michihupf/Arrow",
"path": "/arrow-protocol/src/serde/varint.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michihupf/Arrow path: /arrow-protocol/src/serde/varint.rs
use std::io::{Read, Write};
use std::result::Result as StdResult;
use serde::{
de::Error as DeError,
de::{SeqAccess, Visitor},
ser::Error as SerError,
Deserialize, Serialize,
};
use super::error::{Result, SerdeError};
/... | code_fim | hard | {
"lang": "rust",
"repo": "michihupf/Arrow",
"path": "/arrow-protocol/src/serde/varint.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnPeel/flirc-sdk-rs path: /flirc-sdk-sys/build.rs
use std::{env, path::PathBuf};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn get_lib_dir() -> Result<&'static str> {
if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
Ok("sdk/libs/Darwin_x86_64"... | code_fim | hard | {
"lang": "rust",
"repo": "JohnPeel/flirc-sdk-rs",
"path": "/flirc-sdk-sys/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cfg!(target_os = "windows") {
builder = builder.clang_arg("-DWINDOWS");
}
let bindings = builder
.generate()
.map_err(|_| "Unable to generate bindings.rs")?;
let out_path = PathBuf::from(env::var("OUT_DIR")?);
bindings.write_to_file(out_path.join("bindi... | code_fim | hard | {
"lang": "rust",
"repo": "JohnPeel/flirc-sdk-rs",
"path": "/flirc-sdk-sys/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut builder = bindgen::Builder::default()
.header("sdk/libs/flirc/flirc.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.clang_arg("-Isdk/cli/include")
.whitelist_recursively(false)
.whitelist_type("flirc_.*")
.whitelist_type("usb_iface_type"... | code_fim | hard | {
"lang": "rust",
"repo": "JohnPeel/flirc-sdk-rs",
"path": "/flirc-sdk-sys/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andynog/ibc-rs path: /relayer/cli/src/commands/config/validate.rs
use crate::prelude::*;
use abscissa_core::{Command, Options, Runnable};
<|fim_suffix|>impl Runnable for ValidateCmd {
/// Validate the loaded configuration.
fn run(&self) {
let config = app_config();
stat... | code_fim | medium | {
"lang": "rust",
"repo": "andynog/ibc-rs",
"path": "/relayer/cli/src/commands/config/validate.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: Validate configuration
}
}<|fim_prefix|>// repo: andynog/ibc-rs path: /relayer/cli/src/commands/config/validate.rs
use crate::prelude::*;
use abscissa_core::{Command, Options, Runnable};
<|fim_middle|>#[derive(Command, Debug, Options)]
pub struct ValidateCmd {}
impl Runnable for V... | code_fim | hard | {
"lang": "rust",
"repo": "andynog/ibc-rs",
"path": "/relayer/cli/src/commands/config/validate.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anon767/blog path: /backend/src/schema.rs
table! {
blogs (id) {
id -> Varchar,
token -> Varchar,
}
}
<|fim_suffix|>allow_tables_to_appear_in_same_query!(
blogs,
posts,
);<|fim_middle|>table! {
posts (id) {
id -> Nullable<Integer>,
content -> V... | code_fim | medium | {
"lang": "rust",
"repo": "anon767/blog",
"path": "/backend/src/schema.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>allow_tables_to_appear_in_same_query!(
blogs,
posts,
);<|fim_prefix|>// repo: anon767/blog path: /backend/src/schema.rs
table! {
blogs (id) {
id -> Varchar,
token -> Varchar,
}
}
<|fim_middle|>table! {
posts (id) {
id -> Nullable<Integer>,
content -> V... | code_fim | medium | {
"lang": "rust",
"repo": "anon767/blog",
"path": "/backend/src/schema.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_buffer(&self) -> f32 {
self.buffer
}
}<|fim_prefix|>// repo: wartyz/ThinMatrixRust path: /src/textures/texture_data.rs
pub struct TextureData {
width: i32,
height: i32,
buffer: f32,
}
impl TextureData {
pub fn new(buffer: f32, width: i32, height: i32) -> Textur... | code_fim | medium | {
"lang": "rust",
"repo": "wartyz/ThinMatrixRust",
"path": "/src/textures/texture_data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wartyz/ThinMatrixRust path: /src/textures/texture_data.rs
pub struct TextureData {
width: i32,
height: i32,
buffer: f32,
}
<|fim_suffix|> pub fn get_height(&self) -> i32 {
self.height
}
pub fn get_buffer(&self) -> f32 {
self.buffer
}
}<|fim_middle|>im... | code_fim | hard | {
"lang": "rust",
"repo": "wartyz/ThinMatrixRust",
"path": "/src/textures/texture_data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected3 = Matrix4x3::new(
11, 12, 13,
21, 22, 23,
41, 42, 43,
51, 52, 53);
assert_eq!(m.remove_row(0), expected1);
assert_eq!(m.remove_row(4), expected2);
assert_eq!(m.remove_row(2), expected3);
let expected1 = Matrix3::new(
31, 32, 33,
... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/tests/linalg/full_piv_lu.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected1 = Matrix3::new(
13, 14, 15,
23, 24, 25,
33, 34, 35);
let expected2 = Matrix3::new(
11, 12, 13,
21, 22, 23,
31, 32, 33);
let expected3 = Matrix3::new(
11, 12, 15,
21, 22, 25,
31, 32, 35);
assert_eq!(m.r... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/tests/linalg/full_piv_lu.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mebus/nalgebra path: /tests/linalg/full_piv_lu.rs
use na::Matrix3;
#[test]
#[rustfmt::skip]
fn full_piv_lu_simple() {
let m = Matrix3::new(
2.0, -1.0, 0.0,
-1.0, 2.0, -1.0,
0.0, -1.0, 2.0);
let lu = m.full_piv_lu();
assert_eq!(lu.determinant(), 4.0);
... | code_fim | hard | {
"lang": "rust",
"repo": "Mebus/nalgebra",
"path": "/tests/linalg/full_piv_lu.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<LinkedHashMap<String, Value, FxBuildHasher>> for Group {
fn from(hashmap: LinkedHashMap<String, Value, FxBuildHasher>) -> Self {
let mut keys = LinkedHashMap::with_capacity_and_hasher(hashmap.len(), Default::default());
Self::new(
hashmap
.into_iter()
.map(|(key, value)| {
i... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/amadeus",
"path": "/amadeus-types/src/group.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alecmocatta/amadeus path: /amadeus-types/src/group.rs
//! Implement [`Record`] for [`Group`] aka [`Row`].
use fxhash::FxBuildHasher;
use hashlink::LinkedHashMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::{
cmp::Ordering, fmt::{self, Debug}, ops::Index, slice::Slic... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/amadeus",
"path": "/amadeus-types/src/group.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! tuple_from {
($len:tt $($t:ident $i:tt)*) => (
impl<$($t,)*> From<($($t,)*)> for Group where $($t: Into<Value>,)* {
#[allow(unused_variables)]
fn from(value: ($($t,)*)) -> Self {
Group::new(vec![$(value.$i.into(),)*], None)
}
}
);
}
tuple!(tuple_from);
// impl From<Group> ... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/amadeus",
"path": "/amadeus-types/src/group.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Emit the pickled source files.
for pf in &syntax_trees {
// For each file, start with a clean replacement table.
pickle.replace_table.clear();
// Iterate again and check for usage
for node in &pf.ast {
match node {
// Instantiations, e... | code_fim | hard | {
"lang": "rust",
"repo": "fabianschuiki/morty",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Parse the input files.
let printer = Arc::new(Mutex::new(printer::Printer::new()));
let mut syntax_trees = vec![];
let minimize = matches.is_present("minimize");
let strip_comments = matches.is_present("strip_comments") | minimize;
for bundle in file_list {
let bundle_i... | code_fim | hard | {
"lang": "rust",
"repo": "fabianschuiki/morty",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabianschuiki/morty path: /src/main.rs
ght 2019 Florian Zaruba
// SPDX-License-Identifier: Apache-2.0
#![recursion_limit = "256"]
#[macro_use]
extern crate log;
use anyhow::{Context as _, Error, Result};
use clap::{App, Arg};
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use std... | code_fim | hard | {
"lang": "rust",
"repo": "fabianschuiki/morty",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jsen-/db path: /src/db/oracle.rs
use super::{Preparable, Queryable};
use oracle;
pub trait MyToSql: oracle::ToSql {
fn as_ora(&self) -> &oracle::ToSql;
<|fim_suffix|> self
}
}
impl<'a, T: MyToSql> From<&'a T> for &'a dyn MyToSql {
fn from(t: &'a T) -> Self {
t as &My... | code_fim | medium | {
"lang": "rust",
"repo": "jsen-/db",
"path": "/src/db/oracle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self
}
}
impl<'a, T: MyToSql> From<&'a T> for &'a dyn MyToSql {
fn from(t: &'a T) -> Self {
t as &MyToSql
}
}
impl<'a, I> Queryable<oracle::Statement<'a>> for I
where
I: IntoIterator,
I::Item: Into<&'a MyToSql>,
{
type Error = oracle::Error;
fn query(self, stm... | code_fim | medium | {
"lang": "rust",
"repo": "jsen-/db",
"path": "/src/db/oracle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let params: Vec<&dyn oracle::ToSql> = self
.into_iter()
.map(Into::into)
.map(MyToSql::as_ora)
.collect();
stmt.query(params.as_slice())?;
Ok(())
}
}
impl<'a> Preparable<'a, oracle::Statement<'a>> for oracle::Connection {
typ... | code_fim | hard | {
"lang": "rust",
"repo": "jsen-/db",
"path": "/src/db/oracle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ben-wallis/aoc2020 path: /examples/3.rs
use aoc2020::utils::read_lines;
use std::iter::once;
fn main() {
let input = read_lines("C:\\rust\\aoc2020\\day3_input.txt");
let map = input
.map(|line| line.chars().map(|x| x == '#').collect::<Vec<bool>>())
.collect::<Vec<Vec<bo... | code_fim | hard | {
"lang": "rust",
"repo": "ben-wallis/aoc2020",
"path": "/examples/3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn part2(map: &Vec<Vec<bool>>) {
let result: u64 = once(calc_trees(&map, 1, 1))
.chain(once(calc_trees(&map, 3, 1)))
.chain(once(calc_trees(&map, 5, 1)))
.chain(once(calc_trees(&map, 7, 1)))
.chain(once(calc_trees(&map, 1, 2)))
.product();
println!("part 2: ... | code_fim | hard | {
"lang": "rust",
"repo": "ben-wallis/aoc2020",
"path": "/examples/3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = calc_trees(&map, 3, 1);
println!("total trees: {}", result);
}
fn part2(map: &Vec<Vec<bool>>) {
let result: u64 = once(calc_trees(&map, 1, 1))
.chain(once(calc_trees(&map, 3, 1)))
.chain(once(calc_trees(&map, 5, 1)))
.chain(once(calc_trees(&map, 7, 1)))
... | code_fim | hard | {
"lang": "rust",
"repo": "ben-wallis/aoc2020",
"path": "/examples/3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Layout{ size: self.size, align: self.align }
}
}
impl<PTR: Copy + From<usize>> Layout<PTR>
{
pub unsafe fn new_unchecked<T>() -> Self {
let layout = alloc::Layout::new::<T>();
Layout::from_size_align_unchecked(layout.size().into(), layout.align().into())
}
}
impl<PTR:... | code_fim | medium | {
"lang": "rust",
"repo": "lostmsu/mem_bitness",
"path": "/src/alloc/layout.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lostmsu/mem_bitness path: /src/alloc/layout.rs
use std::alloc;
use std::ops::{Add, Sub, BitAnd, Not};
#[derive(Copy)]
pub struct Layout<PTR: Copy>
{
size: PTR,
align: PTR,
}
<|fim_suffix|>impl<PTR: Into<usize> + Copy> From<Layout<PTR>> for alloc::Layout
where
PTR: Add<PTR, Output=P... | code_fim | hard | {
"lang": "rust",
"repo": "lostmsu/mem_bitness",
"path": "/src/alloc/layout.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<PTR: Copy> Clone for Layout<PTR>
{
fn clone(&self) -> Self {
Layout{ size: self.size, align: self.align }
}
}
impl<PTR: Copy + From<usize>> Layout<PTR>
{
pub unsafe fn new_unchecked<T>() -> Self {
let layout = alloc::Layout::new::<T>();
Layout::from_size_align_unc... | code_fim | hard | {
"lang": "rust",
"repo": "lostmsu/mem_bitness",
"path": "/src/alloc/layout.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tarkah/ajour path: /src/curse_api.rs
use crate::{error::ClientError, network::request_async, Result};
use isahc::prelude::*;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use serde_derive::Deserialize;
const API_ENDPOINT: &str = "https://addons-ecs.forgesvc.net/api/v2/addon";
... | code_fim | hard | {
"lang": "rust",
"repo": "tarkah/ajour",
"path": "/src/curse_api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Function to fetch a remote addon packages for a search string.
pub async fn fetch_remote_packages(search_string: &str) -> Result<Vec<Package>> {
let game_id = 1; // wow
let page_size = 20; // capping results
let timeout = Some(15);
let search_string = utf8_percent_encode(search_string,... | code_fim | hard | {
"lang": "rust",
"repo": "tarkah/ajour",
"path": "/src/curse_api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1aguna/influxdb_iox path: /server/src/db/lifecycle/persist.rs
//! This module contains the code that splits and persist chunks
use super::{LockableCatalogChunk, LockableCatalogPartition, Result};
use crate::db::{
catalog::{chunk::CatalogChunk, partition::Partition},
lifecycle::{collect_... | code_fim | hard | {
"lang": "rust",
"repo": "1aguna/influxdb_iox",
"path": "/server/src/db/lifecycle/persist.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (new_chunk_id, new_chunk) = partition_write.create_rub_chunk(
to_persist,
time_of_first_write,
time_of_last_write,
schema,
delete_predicates,
min_order,
);
let to_persist... | code_fim | hard | {
"lang": "rust",
"repo": "1aguna/influxdb_iox",
"path": "/server/src/db/lifecycle/persist.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: planet0104/android_sdl2_test path: /cbrain/src/ga/genalg.rs
use ga::genome::Genome;
use rand::rngs::ThreadRng;
use rand::{thread_rng, Rng};
use std::sync::mpsc::channel;
use std::thread;
use std::sync::{Arc, Mutex};
use ga::Params;
pub struct GenAlg {
params: Params,
pop: Vec<Genome>,
... | code_fim | hard | {
"lang": "rust",
"repo": "planet0104/android_sdl2_test",
"path": "/cbrain/src/ga/genalg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.total_fitness = 0.0;
self.best_fitness = 0.0;
self.worst_fitness = ::std::f64::MAX;
self.average_fitness = 0.0;
}
//精英选择
pub fn grab_n_best(&self, n: usize, num_copies: usize, pop:&mut Vec<Genome>){
for n_best in 0..n{
for _ in 0..num_c... | code_fim | hard | {
"lang": "rust",
"repo": "planet0104/android_sdl2_test",
"path": "/cbrain/src/ga/genalg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn overrides_all_bits_sign_bit() {
instruction_runs! {
instr_i!(LI, T0, ZERO, 0xF321u16 as i16),
[T0 = 0x1234_5678] => [T0 = 0xFFFF_F321u32]
};
}<|fim_prefix|>// repo: snacchus/vcpu path: /src/test/instructions/li.rs
use super::*;
#[test]
fn positive() {
instruction_r... | code_fim | medium | {
"lang": "rust",
"repo": "snacchus/vcpu",
"path": "/src/test/instructions/li.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> instruction_runs! {
instr_i!(LI, T0, ZERO, 0x4321),
[T0 = 0x1234_5678] => [T0 = 0x0000_4321]
};
}
#[test]
fn overrides_all_bits_sign_bit() {
instruction_runs! {
instr_i!(LI, T0, ZERO, 0xF321u16 as i16),
[T0 = 0x1234_5678] => [T0 = 0xFFFF_F321u32]
};
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "snacchus/vcpu",
"path": "/src/test/instructions/li.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snacchus/vcpu path: /src/test/instructions/li.rs
use super::*;
#[test]
fn positive() {
instruction_runs! {
instr_i!(LI, T0, ZERO, 0x1234),
[] => [T0 = 0x0000_1234]
};
}
<|fim_suffix|> instruction_runs! {
instr_i!(LI, T0, ZERO, 0x4321),
[T0 = 0x1234_56... | code_fim | medium | {
"lang": "rust",
"repo": "snacchus/vcpu",
"path": "/src/test/instructions/li.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true, e.enforce(("bob", "/bob_data/resource1", "POST")).unwrap());
assert_eq!(true, e.enforce(("cathy", "/cathy_data", "GET")).unwrap());
assert_eq!(true, e.enforce(("cathy", "/cathy_data", "POST")).unwrap());
Ok(())
}
#[tokio::test]
async fn securi... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/cc-data-srv/src/acl/permissions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true, e.enforce(("cathy", "/cathy_data", "GET")).unwrap());
assert_eq!(true, e.enforce(("cathy", "/cathy_data", "POST")).unwrap());
Ok(())
}
#[tokio::test]
async fn security_manager_works() -> Result<()> {
let delegator=Delegator::new().await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/cc-data-srv/src/acl/permissions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samlet/bluecc path: /cc-data-srv/src/acl/permissions.rs
use casbin::prelude::*;
use crate::acl::Result;
use deles::delegators::Delegator;
use deles::resources::policy::{UserLoginSecurityGroup, SecurityGroupPermission};
use crate::acl::{role_lines, perm_lines};
use crate::acl::adapters::SecurityA... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/cc-data-srv/src/acl/permissions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The number of paths from the last element to itself is 1
*n_paths.last_mut().unwrap() = 1;
// Starting from the end start filling `n_paths`
for pos in (0..data.len()).rev() {
// For a given position `pos` the next item will be one of the three following ones
for next_po... | code_fim | hard | {
"lang": "rust",
"repo": "Stannislav/Advent-of-Code",
"path": "/2020/src/bin/10.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Stannislav/Advent-of-Code path: /2020/src/bin/10.rs
use std::fs;
#[doc(hidden)]
fn main() {
// Read input
let mut data: Vec<usize> = fs::read_to_string("input/10.txt")
.expect("Can't read input file")
.trim()
.lines()
.map(|x| x.parse().unwrap())
... | code_fim | hard | {
"lang": "rust",
"repo": "Stannislav/Advent-of-Code",
"path": "/2020/src/bin/10.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let diffs: Vec<usize> = data
.iter()
.zip(data.iter().skip(1))
.map(|(&n1, &n2)| n2 - n1)
.collect();
let count_1 = diffs.iter().filter(|&&x| x == 1).count();
let count_3 = diffs.iter().filter(|&&x| x == 3).count();
count_1 * count_3
}
/// Solve part 2.
///... | code_fim | hard | {
"lang": "rust",
"repo": "Stannislav/Advent-of-Code",
"path": "/2020/src/bin/10.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abhijeetbhagat/boa path: /boa/src/syntax/ast/punctuator.rs
//! This module implements the `Punctuator`, which represents all punctuators used in JavaScript
//!
//! More information:
//! - [ECMAScript Reference][spec]
//!
//! [spec]: https://tc39.es/ecma262/#prod-Punctuator
use crate::syntax::a... | code_fim | hard | {
"lang": "rust",
"repo": "abhijeetbhagat/boa",
"path": "/boa/src/syntax/ast/punctuator.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Punctuator {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(
f,
"{}",
match self {
Self::Add => "+",
Self::And => "&",
Self::Arrow => "=>",
Self::Assign => "... | code_fim | hard | {
"lang": "rust",
"repo": "abhijeetbhagat/boa",
"path": "/boa/src/syntax/ast/punctuator.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
element_signature,
elements,
signature,
}
}
}
impl<'a, T> From<&Vec<T>> for Array<'a>
where
T: Type + Into<Value<'a>> + Clone,
{
fn from(values: &Vec<T>) -> Self {
Self::from(&values[..])
}
}
impl<'a, T> TryFrom<Array<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "emmanueltouzery/zbus",
"path": "/zvariant/src/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emmanueltouzery/zbus path: /zvariant/src/array.rs
use serde::ser::{Serialize, SerializeSeq, Serializer};
use std::convert::TryFrom;
use crate::{Error, Result};
use crate::{Signature, Type, Value};
/// A helper type to wrap arrays in a [`Value`].
///
/// API is provided to convert from, and to ... | code_fim | hard | {
"lang": "rust",
"repo": "emmanueltouzery/zbus",
"path": "/zvariant/src/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> TryFrom<Array<'a>> for Vec<T>
where
T: TryFrom<Value<'a>>,
{
type Error = Error;
fn try_from(v: Array<'a>) -> core::result::Result<Self, Self::Error> {
// there is no try_map yet..
let mut res = vec![];
for e in v.elements.into_iter() {
res.push... | code_fim | hard | {
"lang": "rust",
"repo": "emmanueltouzery/zbus",
"path": "/zvariant/src/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c0c1/salvo path: /examples/file_list.rs
use salvo_core::prelude::*;
use salvo_extra::serve::{Options, StaticDir};
<|fim_suffix|> let router = Router::with_path("<**path>").get(StaticDir::width_options(
vec!["examples/static/boy", "examples/static/girl"],
Options {
... | code_fim | medium | {
"lang": "rust",
"repo": "c0c1/salvo",
"path": "/examples/file_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let router = Router::with_path("<**path>").get(StaticDir::width_options(
vec!["examples/static/boy", "examples/static/girl"],
Options {
dot_files: false,
listing: true,
defaults: vec!["index.html".to_owned()],
},
));
Server::new(route... | code_fim | medium | {
"lang": "rust",
"repo": "c0c1/salvo",
"path": "/examples/file_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imsnif/netstat-rs path: /src/integrations/osx/netstat.rs
use std::io::{BufRead, BufReader};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::process::{Command, Stdio};
use types::*;
pub fn iterate_netstat_info(
af_flags: AddressFamilyFlags,
proto_flags: ProtocolFlags,
) -> Result<im... | code_fim | hard | {
"lang": "rust",
"repo": "imsnif/netstat-rs",
"path": "/src/integrations/osx/netstat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, c) in endpoint.chars().rev().enumerate() {
if c == '.' {
return (
&endpoint[0..endpoint.len() - i - 1],
&endpoint[endpoint.len() - i..],
);
}
}
(endpoint, &endpoint[0..0])
}
fn remove_zone_index(ip_str: &str) -> &... | code_fim | hard | {
"lang": "rust",
"repo": "imsnif/netstat-rs",
"path": "/src/integrations/osx/netstat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicochatzi/soultrain path: /tests/e2e.rs
mod utils;
use crate::utils::*;
#[test]
fn fresh_install_of_latest_version() {
<|fim_suffix|> sys::remove_soultrain();
sys::remove_soul();
}
#[test]
fn fresh_install_of_previous_version() {
sys::remove_soul();
sys::remove_soultrain();
... | code_fim | hard | {
"lang": "rust",
"repo": "nicochatzi/soultrain",
"path": "/tests/e2e.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = cmd::soultrain::select("previous").unwrap();
let output = cmd::soultrain::show().unwrap();
assert!(output.stderr.is_empty());
assert!(sys::is_soul_installed());
sys::remove_soultrain();
sys::remove_soul();
}<|fim_prefix|>// repo: nicochatzi/soultrain path: /tests/e2e.rs
... | code_fim | medium | {
"lang": "rust",
"repo": "nicochatzi/soultrain",
"path": "/tests/e2e.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jthelin/demikernel path: /src/rust/pal/functions.rs
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
use crate::pal::data_structures::SockAddrIn;
#[cfg(feature = "catnip-libos")]
const NUM_OCTETS_IN_IPV4: usize = 4;
#[cfg(feature = "catnip-libos")]
const NUM_SIN_ZERO... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/src/rust/pal/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(all(feature = "catnip-libos", target_os = "windows"))]
use windows::Win32::Networking::WinSock::IN_ADDR;
#[cfg(all(feature = "catnip-libos", target_os = "windows"))]
use windows::Win32::Networking::WinSock::IN_ADDR_0;
#[cfg(all(feature = "catnip-libos", target_os = "linux"))]
use libc::in_addr;
/... | code_fim | medium | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/src/rust/pal/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get() -> Vec<Box<dyn Catcher>> {
default_catchers! {
StatusCode::BAD_REQUEST,
StatusCode::UNAUTHORIZED,
StatusCode::PAYMENT_REQUIRED,
StatusCode::FORBIDDEN,
StatusCode::NOT_FOUND,
StatusCode::METHOD_NOT_ALLOWED,
... | code_fim | hard | {
"lang": "rust",
"repo": "c0c1/salvo",
"path": "/core/src/catcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c0c1/salvo path: /core/src/catcher.rs
use crate::http::errors::*;
use crate::http::{guess_accept_mime, header, Request, Response, StatusCode};
/// Catch error in current response.
pub trait Catcher: Send + Sync + 'static {
/// If the current catcher caught the error, it will return true.
... | code_fim | hard | {
"lang": "rust",
"repo": "c0c1/salvo",
"path": "/core/src/catcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mich101mich/hierarchical_pathfinding path: /src/graph/a_star.rs
use super::*;
use crate::neighbors::Neighborhood;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
pub fn a_star_search<N: Neighborhood>(
nodes: &NodeList,
start: NodeID,
goal: NodeID,
neighborhood: &N,
... | code_fim | hard | {
"lang": "rust",
"repo": "mich101mich/hierarchical_pathfinding",
"path": "/src/graph/a_star.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut needs_visit = true;
if let Some((prev_cost, prev_id)) = visited.get_mut(&other_id) {
if *prev_cost > other_cost {
*prev_cost = other_cost;
*prev_id = current_id;
} else {
needs_visit... | code_fim | hard | {
"lang": "rust",
"repo": "mich101mich/hierarchical_pathfinding",
"path": "/src/graph/a_star.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lasia98/Filecoin path: /mirrors.ustc.edu.cn-b63e9dae659fc205/commandspec-0.12.2/src/signal.rs
// From https://raw.githubusercontent.com/watchexec/watchexec/master/src/signal.rs
#![allow(unused)]
use std::sync::Mutex;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
lazy_stati... | code_fim | hard | {
"lang": "rust",
"repo": "Lasia98/Filecoin",
"path": "/mirrors.ustc.edu.cn-b63e9dae659fc205/commandspec-0.12.2/src/signal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let _ = sigaction(
SIGCHLD,
&SigAction::new(
SigHandler::Handler(sigchld_handler),
SaFlags::empty(),
SigSet::empty(),
),
);
}
// Spawn a thread to catch these signals
let id = GLOB... | code_fim | hard | {
"lang": "rust",
"repo": "Lasia98/Filecoin",
"path": "/mirrors.ustc.edu.cn-b63e9dae659fc205/commandspec-0.12.2/src/signal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(windows)]
pub fn uninstall_handler() {
use kernel32::SetConsoleCtrlHandler;
use winapi::{BOOL, DWORD, FALSE, TRUE};
unsafe {
SetConsoleCtrlHandler(Some(ctrl_handler), FALSE);
}
debug!("Removed ConsoleCtrlHandler.");
}
#[cfg(windows)]
pub unsafe extern "system" fn ctrl_h... | code_fim | hard | {
"lang": "rust",
"repo": "Lasia98/Filecoin",
"path": "/mirrors.ustc.edu.cn-b63e9dae659fc205/commandspec-0.12.2/src/signal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub struct Gameplay;
impl SimpleState for Gameplay {
fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>)
{
let world = data.world;
//initialize_camera(world);
GameCamera::initialize(world);
PaddleEntity::initialize(world);
}
}<|fim_prefix|>// repo:... | code_fim | hard | {
"lang": "rust",
"repo": "DomCristaldi/TopDog",
"path": "/src/States/gameplay.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DomCristaldi/TopDog path: /src/States/gameplay.rs
use amethyst::{
assets::{AssetStorage, Loader, Handle},
core::transform::Transform,
prelude::*,
};
use crate::{
Entities::{
PaddleEntity,
GameCamera,
},
StaticData::StaticData,
};
<|fim_suffix|>impl Simpl... | code_fim | hard | {
"lang": "rust",
"repo": "DomCristaldi/TopDog",
"path": "/src/States/gameplay.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>l 0 is driven on pin, provided pin is configured for general-purpose output."]
_0,
#[doc = "Logic level 1 is driven on pin, provided pin is configured for general-purpose output."]
_1,
}
impl PDO13W {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _bits(&self) -> bool {... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/gpioa/pdor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stv0g/k66 path: /src/gpioa/pdor.rs
bit is clear (0)"]
#[inline]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r" Returns `true` if the bit is set (1)"]
#[inline]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r" Value of the f... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/gpioa/pdor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stv0g/k66 path: /src/gpioa/pdor.rs
]
pub fn bit(&self) -> bool {
match *self {
PDO28R::_0 => false,
PDO28R::_1 => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
pub fn _from(value: bool) -> PDO28R {
match value {
... | code_fim | hard | {
"lang": "rust",
"repo": "stv0g/k66",
"path": "/src/gpioa/pdor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d0x2f/ip-echo path: /src/main.rs
use hyper::header::HeaderValue;
use hyper::server::conn::AddrStream;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, HeaderMap, Request, Response, Server};
use std::convert::Infallible;
use std::env;
// Headers to check in order of priority
... | code_fim | hard | {
"lang": "rust",
"repo": "d0x2f/ip-echo",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let make_svc = make_service_fn(|socket: &AddrStream| {
let remote_address = socket.remote_addr();
async move {
Ok::<_, Infallible>(service_fn(move |request: Request<Body>| async move {
Ok::<_, Infallible>(match check_for_headers(request.headers()) {
Ok(client_ip) => Respo... | code_fim | hard | {
"lang": "rust",
"repo": "d0x2f/ip-echo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/parser/expression/left_hand_side/tests.rs
use crate::syntax::{
ast::node::{field::GetConstField, Call, Identifier},
parser::tests::check_parser,
};
use boa_interner::Interner;
#[track_caller]
fn check_call_property_identifier(property_name: &'st... | code_fim | hard | {
"lang": "rust",
"repo": "CalliEve/boa",
"path": "/boa_engine/src/syntax/parser/expression/left_hand_side/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> check_member_property_identifier("prop");
check_member_property_identifier("true");
check_member_property_identifier("false");
check_member_property_identifier("null");
check_member_property_identifier("let");
}<|fim_prefix|>// repo: CalliEve/boa path: /boa_engine/src/syntax/parser/ex... | code_fim | hard | {
"lang": "rust",
"repo": "CalliEve/boa",
"path": "/boa_engine/src/syntax/parser/expression/left_hand_side/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut interner = Interner::default();
check_parser(
format!("a.{}", property_name).as_str(),
vec![GetConstField::new(
Identifier::new(interner.get_or_intern_static("a")),
interner.get_or_intern_static(property_name),
)
.into()],
int... | code_fim | hard | {
"lang": "rust",
"repo": "CalliEve/boa",
"path": "/boa_engine/src/syntax/parser/expression/left_hand_side/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_not_process_identifier(arc_process: Arc<Process>) -> BoxedStrategy<Term> {
strategy::term(arc_process)
.prop_filter(
"Process identifier cannot be a pid, atom, or {atom, atom}",
|process_identifier| match process_identifier.to_typed_term().unwrap() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/lumen_runtime/src/otp/erlang/monitor_2/test/with_process_type.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Giovan/lumen path: /lumen_runtime/src/otp/erlang/monitor_2/test/with_process_type.rs
mod with_atom_process_identifier;
mod with_local_pid_process_identifier;
mod with_tuple_process_identifier;
use super::*;
use std::convert::TryInto;
use liblumen_alloc::erts::process::code::stack::frame::Plac... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/lumen_runtime/src/otp/erlang/monitor_2/test/with_process_type.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaynus/balls path: /game/client/src/behavior/mod.rs
use rl_ai::{
bt::{self, make, BehaviorStatus},
pathfinding::SpatialMapSet,
};
use rl_core::{
components::PositionComponent,
data::Target,
defs::reaction::ReactionDefinitionId,
fnv,
legion::prelude::*,
map::{
... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/client/src/behavior/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: ACTUALLY SEARCH IN CORRECT ORDER
//let stockpile_query = <Read<ItemComponent>>::query()
// .filter(component::<StockpileItemChildComponent>());
//let spatial_map = state.resources.get::<SpatialMap>().unwrap();
let solo_item_query = <(Read<PositionCompon... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/client/src/behavior/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(item_property) = args
.blackboard
.get::<ItemProperty>(fnv!("FindItemsProperty"))
.cloned()
{
rl_core::inventory::for_all_items_recursive(
args.entity,
state.world,
|_, (entity, comp... | code_fim | hard | {
"lang": "rust",
"repo": "jaynus/balls",
"path": "/game/client/src/behavior/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/workmail/src/operation_ser.rs
let mut out = String::new();
let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out);
crate::json_ser::serialize_structure_crate_input_deregister_from_work_mail_input(
&mut object,
input,
);... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/workmail/src/operation_ser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/workmail/src/operation_ser.rs
tWriter::new(&mut out);
crate::json_ser::serialize_structure_crate_input_create_user_input(&mut object, input);
object.finish();
Ok(smithy_http::body::SdkBody::from(out))
}
pub fn serialize_operation_crate_operation_delete... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/workmail/src/operation_ser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_operation_crate_operation_list_mailbox_permissions(
input: &crate::input::ListMailboxPermissionsInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::Error> {
let mut out = String::new();
let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out);
crat... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/workmail/src/operation_ser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>any(self) -> bool {
#[cfg(target_arch = "x86")]
use crate::arch::x86::_mm256_movemask_epi8;
#[cfg(target_arch = "x86_64")]
use crate::arch::x86_64::_mm256_movemask_epi8;
_mm256_movemask_epi8(crate::mem::transmute(self)) != 0
... | code_fim | hard | {
"lang": "rust",
"repo": "hsivonen/packed_simd",
"path": "/src/codegen/reductions/mask/x86/avx2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsivonen/packed_simd path: /src/codegen/reductions/mask/x86/avx2.rs
//! Mask reductions implementation for `x86` and `x86_64` targets with `AVX2`.
#![allow(unused)]
/// x86/x86_64 256-bit m8x32 AVX2 implementation
macro_rules! x86_m8x32_avx2_impl {
($id:ident) => {
impl All for $id ... | code_fim | hard | {
"lang": "rust",
"repo": "hsivonen/packed_simd",
"path": "/src/codegen/reductions/mask/x86/avx2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const ACCOUNT_FIELDS: &str = r#"
acc_type_name
balance(format: DEC)
last_paid
last_trans_lt
data
boc
code_hash
"#;
pub async fn get_account(conf: Config, addr: &str, dumpfile: Option<&str>, dumpboc: Option<&str>) -> Result<(), String> {
let ton = create_client_verbose(&con... | code_fim | hard | {
"lang": "rust",
"repo": "klamenzui/tonos-cli",
"path": "/src/account.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klamenzui/tonos-cli path: /src/account.rs
/*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software... | code_fim | hard | {
"lang": "rust",
"repo": "klamenzui/tonos-cli",
"path": "/src/account.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if dumpfile.is_some() || dumpboc.is_some() {
if accounts.len() == 1 {
let acc = &accounts[0];
let boc = acc["boc"].as_str()
.ok_or("failed to get boc of the account")
.map_err(|e| format!("{}", e))?;
let account = Account::con... | code_fim | hard | {
"lang": "rust",
"repo": "klamenzui/tonos-cli",
"path": "/src/account.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ::std::fs::write(
file_name,
::std::panic::catch_unwind(|| ::prettyplease::unparse(&parse_quote!(#output)))
.unwrap_or_else(|_| quote!(#output).to_string())
,
)
.unwrap_or_else(|err| panic!(
"`DEBUG_MACROS_LOCATION`-error: failed to write to ... | code_fim | hard | {
"lang": "rust",
"repo": "getditto/safer_ffi",
"path": "/src/proc_macro/utils/mb_file_expanded.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: getditto/safer_ffi path: /src/proc_macro/utils/mb_file_expanded.rs
#![cfg_attr(rustfmt, rustfmt::skip)]
use super::*;
pub(in crate)
fn mb_file_expanded (output: TokenStream2)
-> TokenStream2
{
let mut debug_macros_dir =
match ::std::env::var_os("DEBUG_MACROS_LOCATION") {
... | code_fim | hard | {
"lang": "rust",
"repo": "getditto/safer_ffi",
"path": "/src/proc_macro/utils/mb_file_expanded.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
/// Saves a *copy* of a value in a new zone.
pub trait Save<Q, R> : Saved<R> + Pointee {
type SavePoll : SavePoll<Q, R, Target = Self>;
//fn init_save(&self, dst: &mut D) -> Result<Self::SavePoll, ;
}
pub trait SavePoll<Q, R> {
type Target : ?Sized + Pointee;
}
impl<R, T: Saved<R>> Saved... | code_fim | hard | {
"lang": "rust",
"repo": "rs19hack/proofmarshal",
"path": "/hoard/src/zone/type.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub trait SavePoll<Q, R> {
fn save_poll<D>(&mut self, dst: D) -> Result<D, D::Error>
where D: SavePtr<Source=Q, Target=R>;
}
pub trait Saver : Sized {
type Source;
type Target;
type Error;
/// Tries to directly coerce a `Source` pointer into a `Target` pointer.
unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "rs19hack/proofmarshal",
"path": "/hoard/src/zone/type.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rs19hack/proofmarshal path: /hoard/src/zone/type.rs
//! Saving values.
use crate::pointee::Pointee;
use crate::zone::{Zone, Ptr, Own};
use crate::bag::Bag;
/// The type of a type when saved in a specific zone.
pub trait Type<Zone> : Pointee {
type Type : ?Sized + Pointee<Metadata = <Self a... | code_fim | hard | {
"lang": "rust",
"repo": "rs19hack/proofmarshal",
"path": "/hoard/src/zone/type.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.