text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> prev_node = curr_node;
}
}
Ok(proto_graph)
}
pub fn display(
graph: &Graph<ProtoGraphNode, ()>,
file: &mut File,
node: NodeIndex,
) -> Result<(), anyhow::Error> {
let children = graph.neighbors_directed(node, Direction::Outgoing);
if graph[node].is_root {... | code_fim | hard | {
"lang": "rust",
"repo": "tl-marco-cameriero/grpc-build",
"path": "/src/graph_layout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /src/client/src/spu/spu_leader.rs
use std::io::Error as IoError;
use std::io::ErrorKind;
use tracing::debug;
use tracing::trace;
use kf_protocol::api::RecordSet;
use kf_protocol::api::PartitionOffset;
use kf_protocol::api::ReplicaKey;
use kf_protocol::message::fetch::... | code_fim | hard | {
"lang": "rust",
"repo": "vijaylaxmid/fluvio",
"path": "/src/client/src/spu/spu_leader.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use kf_protocol::message::produce::DefaultKfProduceRequest;
use kf_protocol::message::produce::DefaultKfPartitionRequest;
use kf_protocol::message::produce::DefaultKfTopicRequest;
use kf_protocol::api::DefaultBatch;
use kf_protocol::api::DefaultRecord;
// ... | code_fim | hard | {
"lang": "rust",
"repo": "vijaylaxmid/fluvio",
"path": "/src/client/src/spu/spu_leader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The `const FIELDS: [...; n]`-item holding tuples describing each field
fn fields_array(&self) -> syn::ItemConst {
let elemens = self
.fields
.iter()
.map(|f| f.fields_ary_entry(&self.modifier));
let size = self.fields.len();
syn::pars... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/restruct",
"path": "/impl/src/generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaslueg/restruct path: /impl/src/generator.rs
mat::ULongLong) => syn::parse_quote! { u64 },
(false, Format::UShort) => syn::parse_quote! { u16 },
(false, Format::USize) => syn::parse_quote! { usize },
(true, Format::Char) => syn::parse_quote! { libc::c_char ... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/restruct",
"path": "/impl/src/generator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaslueg/restruct path: /impl/src/generator.rs
es",
parser::ByteOrder::LittleEndian => "to_le_bytes",
parser::ByteOrder::BigEndian => "to_be_bytes",
},
proc_macro2::Span::call_site(),
)
}
/// The method to call on numer-ty... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/restruct",
"path": "/impl/src/generator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> encode_with_size(self, s)
}
}
impl Decodable for Vec<u8> {
#[inline]
fn decode<D: io::Read>(mut d: D) -> Result<Self> {
let len = VarInt::decode(&mut d)?.0 as usize;
let mut ret = vec![0u8; len];
d.read_slice(&mut ret)?;
Ok(ret)
}
}
impl Encodable ... | code_fim | hard | {
"lang": "rust",
"repo": "narodnik/sapvi",
"path": "/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.0 {
0..=0xFC => {
(self.0 as u8).encode(s)?;
Ok(1)
}
0xFD..=0xFFFF => {
s.write_u8(0xFD)?;
(self.0 as u16).encode(s)?;
Ok(3)
}
0x10000..=0xFFFFFFFF... | code_fim | hard | {
"lang": "rust",
"repo": "narodnik/sapvi",
"path": "/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: narodnik/sapvi path: /src/serial.rs
Ok(VarInt(x as u64))
}
}
0xFD => {
let x = ReadExt::read_u16(&mut d)?;
if x < 0xFD {
Err(self::Error::NonMinimalVarInt)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "narodnik/sapvi",
"path": "/src/serial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>(- a b c d e ...)
is equivalent to:
(- a (+ b c d e ...))
(- a)
is equivalent to:
(- 0 a)
Examples:
(- 5 3)
=> 2
(- 10 1 2 3 4)
=> 0";
pub fn sub(args: &[LispObjRef], _: EnvironmentRef) -> EvalResult {
if args.len() == 0 {
arity_error!("(-) must have at least one argument")
} else if a... | code_fim | hard | {
"lang": "rust",
"repo": "jhod0/rustylisp",
"path": "/src/evaluator/builtins/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhod0/rustylisp path: /src/evaluator/builtins/math.rs
use ::core::{LispObj, LispObjRef, AsLispObjRef, EvalResult, EnvironmentRef};
enum Number {
Int(i64),
Float(f64),
}
impl Number {
fn from_lisp_obj(obj: &LispObj) -> EvalResult<Number> {
match obj {
&LispObj::L... | code_fim | hard | {
"lang": "rust",
"repo": "jhod0/rustylisp",
"path": "/src/evaluator/builtins/math.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for num in &args[1..] {
try!(div_two(&mut out, &**num))
}
Ok(out.into_lisp_obj().to_obj_ref())
}
}
pub const PRODUCT_DOCSTR: &'static str = "Performs multiplication.
Throws a type-error if an argument is not a number.
Examples:
(*)
;; => 1
(* 1 2 3 4)
;; => 12... | code_fim | hard | {
"lang": "rust",
"repo": "jhod0/rustylisp",
"path": "/src/evaluator/builtins/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //let month = ["monday", "truesday", "wendsday", "saturday", "friday"];
}
fn function_demo(x: i32, y: i32) {
// parameter
println!("start func demo");
println!("parameter 1 {}, para 2 {}", x, y);
let z = {
let x = 1;
//x + 3; //()
x + 3
};
println!("z ... | code_fim | hard | {
"lang": "rust",
"repo": "BearGrass/rust_demo",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BearGrass/rust_demo path: /variables/src/main.rs
//const MAX_POINT:u32 = 100_000;
fn main() {
let guess: u32 = "42".parse().expect("Not a number");
println!("{}", guess);
println!("Hello, world!");
let x = 5;
println!("The value is {}", x);
//x = 6;
let x = x + 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "BearGrass/rust_demo",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // tuple
// any type and the length is fixed
let tup: (i32, f64, u8) = (500, 6.3, 1);
println!("{}, {}, {}", tup.0, tup.1, tup.2);
let (x, y, z) = tup;
println!("{}, {}, {}", x, y, z);
// array one type and the length is fixed
let a: [i32; 5] = [1, 2, 3, 4, 5];
let b:... | code_fim | hard | {
"lang": "rust",
"repo": "BearGrass/rust_demo",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scanbots/rat path: /src/modules/centerdevice/search.rs
use super::client;
use config::{Config, OutputFormat};
use utils::console::*;
use utils::output;
use clap::{App, Arg, ArgMatches, SubCommand};
use serde_json;
use std::fmt;
use std::str;
pub const NAME: &'static str = "search";
error_cha... | code_fim | hard | {
"lang": "rust",
"repo": "scanbots/rat",
"path": "/src/modules/centerdevice/search.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn call(args: Option<&ArgMatches>, config: &Config) -> Result<()> {
let args = args.unwrap();
let filenames: Option<Vec<&str>> = args.values_of("filename").map(|c| c.collect());
let tags: Option<Vec<&str>> = args.values_of("tags").map(|c| c.collect());
let named = if args.is_present("... | code_fim | hard | {
"lang": "rust",
"repo": "scanbots/rat",
"path": "/src/modules/centerdevice/search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::Length(length::Bag::default())
}
}
impl From<length::Bag> for DateTimeFormatOptions {
fn from(input: length::Bag) -> Self {
Self::Length(input)
}
}
impl From<components::Bag> for DateTimeFormatOptions {
fn from(input: components::Bag) -> Self {
Self::Compone... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/icu4x",
"path": "/components/datetime/src/options/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fabura/icu4x path: /components/datetime/src/options/mod.rs
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
//! [`DateTimeFormatOptions`] is a... | code_fim | hard | {
"lang": "rust",
"repo": "fabura/icu4x",
"path": "/components/datetime/src/options/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_chunk_meshes: Vec<(ChunkKey3, Option<PosNormMesh>)>,
mesh_materials: &MeshMaterials,
commands: &mut Commands,
mesh_assets: &mut Assets<Mesh>,
chunk_meshes: &mut ChunkMeshes,
) {
for (chunk_key, item) in new_chunk_meshes.into_iter() {
let old_mesh = if let Some(mesh) = i... | code_fim | hard | {
"lang": "rust",
"repo": "Lemonzyy/building-blocks",
"path": "/examples/lod_terrain/mesh_generator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lemonzyy/building-blocks path: /examples/lod_terrain/mesh_generator.rs
use crate::voxel_map::VoxelMap;
use bevy_utilities::{
bevy::{asset::prelude::*, ecs, prelude::*, tasks::ComputeTaskPool},
mesh::create_mesh_bundle,
thread_local_resource::ThreadLocalResource,
};
use building_bloc... | code_fim | hard | {
"lang": "rust",
"repo": "Lemonzyy/building-blocks",
"path": "/examples/lod_terrain/mesh_generator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_raw_box_hold_copy_str() {
static mut TEST_AREA: [u8; 4096] = [0; 4096];
let pack = Pack::new(unsafe { Block::from_slice(&mut TEST_AREA) });
assert_eq!(pack.live(), 0);
assert_eq!(pack.used(), 0);
assert_eq!(pack.free(), 4064);
{
let xs = RawBox::hold_copy(p... | code_fim | hard | {
"lang": "rust",
"repo": "theseusyang/swim-kernel",
"path": "/lib/mem/tests/raw_box_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theseusyang/swim-kernel path: /lib/mem/tests/raw_box_tests.rs
extern crate swim_mem;
use swim_mem::block::Block;
use swim_mem::alloc::Pack;
use swim_mem::lease::RawBox;
#[test]
fn test_raw_box_hold_new() {
static mut TEST_AREA: [u8; 4096] = [0; 4096];
let pack = Pack::new(unsafe { Bloc... | code_fim | hard | {
"lang": "rust",
"repo": "theseusyang/swim-kernel",
"path": "/lib/mem/tests/raw_box_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(pack.live(), 0);
assert_eq!(pack.used(), 0);
assert_eq!(pack.free(), 4064);
{
let xs = RawBox::hold_copy(pack, "test");
assert_eq!(pack.live(), 1);
assert_eq!(pack.used(), 8);
assert_eq!(pack.free(), 4048);
assert_eq!(xs.len(), 4);
... | code_fim | hard | {
"lang": "rust",
"repo": "theseusyang/swim-kernel",
"path": "/lib/mem/tests/raw_box_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maksimil/sourcegen path: /cli/src/region.rs
use crate::SourceGenerator;
use proc_macro2::{Span, TokenStream};
use syn::spanned::Spanned;
use syn::{Attribute, AttributeArgs, Item};
pub fn item_attributes(item: &mut syn::Item) -> Option<&mut Vec<Attribute>> {
Some(match item {
Item::E... | code_fim | hard | {
"lang": "rust",
"repo": "maksimil/sourcegen",
"path": "/cli/src/region.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn invoke_generator(
item: &Item,
args: AttributeArgs,
generator: &dyn SourceGenerator,
) -> Result<Option<TokenStream>, anyhow::Error> {
match item {
// ExternCrate(ItemExternCrate),
// Use(ItemUse),
// Static(ItemStatic),
// ... | code_fim | hard | {
"lang": "rust",
"repo": "maksimil/sourcegen",
"path": "/cli/src/region.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hugal31/geoip-influxdb-pipeline path: /src/geoip/mod.rs
use std::error::Error;
use async_trait::async_trait;
pub mod maxmind;
pub struct Coords {
lat: f64,
long: f64,
}
#[async_trait]
pub trait GeoIPResolver {
async fn get_geoip(&self, ip: &str) -> Result<Coords, Box<dyn Error>>;... | code_fim | medium | {
"lang": "rust",
"repo": "Hugal31/geoip-influxdb-pipeline",
"path": "/src/geoip/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn s2_cell_from_coords(coords: Coords, precision: usize) -> Result<String, Box<dyn Error>> {
use s2::{cell::Cell, latlng::LatLng, s1::Deg};
let precision = precision as u64;
let latlng = LatLng::new(Deg(coords.lat).into(), Deg(coords.long).into());
let mut cell = Cell::from(latlng);
... | code_fim | hard | {
"lang": "rust",
"repo": "Hugal31/geoip-influxdb-pipeline",
"path": "/src/geoip/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: panghongye/Learn path: /Rust/demo/src/sqlx/mysql.rs
// https://github.com/launchbadge/sqlx
use async_std::task;
<|fim_suffix|>impl MySQL {
pub fn new() -> Self {
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL is required");
let pool = MySqlPool::conne... | code_fim | medium | {
"lang": "rust",
"repo": "panghongye/Learn",
"path": "/Rust/demo/src/sqlx/mysql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MySQL {
pub fn new() -> Self {
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL is required");
let pool = MySqlPool::connect(database_url).await?;
let pool = task::block_on(sqlx::MySqlPool::new(database_url.as_str())).expect("Failed to create pool");
... | code_fim | medium | {
"lang": "rust",
"repo": "panghongye/Learn",
"path": "/Rust/demo/src/sqlx/mysql.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The state is already INITIALIZING.
INITIALIZING => {
// Make sure the state became INITIALIZING finally.
while STATE.load(Ordering::SeqCst) == INITIALIZING {
hint::spin_loop();
}
Err(SetStdoutError::new())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "alekseysidorov/no-stdout",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alekseysidorov/no-stdout path: /src/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
use core::{
fmt::{self},
hint,
sync::atomic::{AtomicUsize, Ordering},
};
static STATE: AtomicUsize = AtomicUsize::new(UNINITIALIZED);
static mut STDOUT: &dyn StdOut = &NopOut;
/// A trait describ... | code_fim | hard | {
"lang": "rust",
"repo": "alekseysidorov/no-stdout",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/fly.rs path: /distributed-fly/src/conn.rs
use bytes::{Buf, BufMut};
use futures::Poll;
use std::io::{self, Read, Write};
use tokio::io::{AsyncRead, AsyncWrite};
use crate::proxy;
pub enum Conn {
Tls(tokio_openssl::SslStream<proxy::ProxyTcpStream>),
Tcp(proxy::ProxyTcpStream),
}... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/fly.rs",
"path": "/distributed-fly/src/conn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_buf<B: BufMut>(&mut self, buf: &mut B) -> Poll<usize, io::Error> {
match self {
Conn::Tcp(proxy_stream) => proxy_stream.read_buf(buf),
Conn::Tls(ssl_stream) => ssl_stream.read_buf(buf),
}
}
}
impl AsyncWrite for Conn {
fn shutdown(&mut self) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/fly.rs",
"path": "/distributed-fly/src/conn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Surpris/rs-deep path: /src/dlfs01/common/layers/mod.rs
//! layers
//!
//! Layers
pub mod activation;
pub mod affine;
pub mod batch_normalization;
pub mod convolution;
pub mod dropout;
pub mod layer_base;
pub mod pooling;
pub mod softmax_with_loss;
use super::util::CrateFloat;
pub use activatio... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/layers/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
ActivatorEnum::Identity => write!(f, "Identity"),
ActivatorEnum::ReLU => write!(f, "ReLU"),
ActivatorEnum::Sigmoid => write!(f, "Sigmoid"),
ActivatorEnum::Softmax => write!(f, "Softmax"),
}
}
}
/// generate an activator
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "Surpris/rs-deep",
"path": "/src/dlfs01/common/layers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/snowball/src/client.rs
= self.inner.set_tax_documents(input);
self
}
/// <p>Defines the device configuration for an AWS Snowcone job.</p>
/// <p>For more information, see
/// "https://docs.aws.amazon.com/snowball/latest/... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/snowball/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rror,
crate::input::UpdateClusterInputOperationRetryAlias,
>,
{
let input = self
.inner
.build()
.map_err(|err| smithy_http::result::SdkError::ConstructionFailure(err.into()))?;
let op = input
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/snowball/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/snowball/src/client.rs
f, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_role_arn(input);
self
}
/// <p>The updated description of this cluster.</p>
pub fn description(mut self,... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/snowball/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustielin/libra path: /language/move-prover/bytecode/src/usage_analysis.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
function_target::{FunctionTarget, FunctionTargetData},
function_target_pipeline::{FunctionTargetProcessor, FunctionT... | code_fim | hard | {
"lang": "rust",
"repo": "rustielin/libra",
"path": "/language/move-prover/bytecode/src/usage_analysis.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
annotation: &mut UsageAnnotation,
func_target: FunctionTarget<'_>,
targets: &FunctionTargetsHolder,
) {
use Bytecode::*;
use Operation::*;
for code in func_target.get_bytecode() {
if let Call(_, _, oper, _) = code {
... | code_fim | hard | {
"lang": "rust",
"repo": "rustielin/libra",
"path": "/language/move-prover/bytecode/src/usage_analysis.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ambaxter/enarx-keepldr path: /src/backend/sev/builder.rs
// SPDX-License-Identifier: Apache-2.0
use crate::backend::kvm::shim::{BootInfo, SevSecret};
use crate::backend::kvm::Hv2GpFn;
use crate::backend::kvm::{self, measure};
use sev::firmware::Firmware;
use sev::launch::Launcher;
use ciboriu... | code_fim | hard | {
"lang": "rust",
"repo": "ambaxter/enarx-keepldr",
"path": "/src/backend/sev/builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn hv2gp(&self) -> Box<Hv2GpFn> {
use core::arch::x86_64::__cpuid_count;
let c_bit_loc = unsafe { __cpuid_count(0x8000_001f, 0x0000_0000) }.ebx;
let c_bit_loc = c_bit_loc & 0x3f;
Box::new(move |target, start| {
PhysAddr::new((target.as_u64() - start.as_u64(... | code_fim | hard | {
"lang": "rust",
"repo": "ambaxter/enarx-keepldr",
"path": "/src/backend/sev/builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lisalotte/KittenAlert path: /src/kitties.rs
use serde::{Serialize, Deserialize};
use scraper::{Html, Selector};
#[derive(Debug, Serialize, Deserialize)]
pub struct Kitty {
pub title: String,
pub date: String,
pub url: String,
}
fn is_ad(html: scraper::ElementRef) -> bool {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Lisalotte/KittenAlert",
"path": "/src/kitties.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = "test_page.txt";
let content = fs::read_to_string(filename)
.expect("Something went wrong reading the file");
let body: &str = content.as_str();
let document = Html::parse_document(body);
let listings = Selector::parse("li").unwrap();
for element in do... | code_fim | hard | {
"lang": "rust",
"repo": "Lisalotte/KittenAlert",
"path": "/src/kitties.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn on_update(
&self,
_parent: &Element,
events: &Vec<Event>,
) -> Result<Option<ElementData>, String> {
for event in events.iter() {
//TODO: I wonder how can I avoid this clone
if event.clone() == Event::Action {
... | code_fim | medium | {
"lang": "rust",
"repo": "josnelihurt/rust-stuff",
"path": "/simple-rust-gaming/src/game/player_shooter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: josnelihurt/rust-stuff path: /simple-rust-gaming/src/game/player_shooter.rs
use crate::engine::basic_types::Event;
use crate::engine::element::Element;
use crate::engine::element::ElementData;
use crate::engine::Component;
use crate::engine::Renderer;
pub struct PlayerShooter {}
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "josnelihurt/rust-stuff",
"path": "/simple-rust-gaming/src/game/player_shooter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samlet/bluecc path: /entity-seed/src/meta/template_builder.rs
use crate::{GenericError, new_snowflake_id, get_entity_model, FIELD_MAPPINGS, Entity};
use std::collections::HashMap;
use crate::meta_model::BelongsTo;
use tera::Tera;
use tera::{Context, Filter, Function};
use serde_json::{json, Valu... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/entity-seed/src/meta/template_builder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let val = value.as_str().unwrap().to_camel_case();
Ok(Value::String(format!("{}", val)))
}
fn pkg_name(value: &Value, _args: &HashMap<String, Value>) -> tera::Result<Value> {
let val:String = value.as_str().unwrap()
.trim_start_matches("... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/entity-seed/src/meta/template_builder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tera.add_raw_template("ent", include_str!("incls/ent.j2"))?;
self.tera.add_raw_template("ent_rel", include_str!("incls/ent_rel.j2"))?;
self.tera.add_raw_template("ent_drop", include_str!("incls/ent_drop.j2"))?;
self.tera.add_raw_template("model", include_str!("incls/mo... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/entity-seed/src/meta/template_builder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Order constant.
///
/// Subdivided into either 32-bit or 64-bit "limbs" (depending on the
/// target CPU's word size), specified from least to most significant.
const ORDER: Self::Limbs;
}<|fim_prefix|>// repo: PY-Foundation-Group-SA/traits path: /elliptic-curve/src/order.rs
//! L... | code_fim | medium | {
"lang": "rust",
"repo": "PY-Foundation-Group-SA/traits",
"path": "/elliptic-curve/src/order.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PY-Foundation-Group-SA/traits path: /elliptic-curve/src/order.rs
//! Low-level elliptic curve parameters.
use crate::Curve;
use core::fmt::Debug;
/// Order of an elliptic curve group.
///
/// This trait is available even when the `arithmetic` feature of the crate
/// is disabled and does not r... | code_fim | medium | {
"lang": "rust",
"repo": "PY-Foundation-Group-SA/traits",
"path": "/elliptic-curve/src/order.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> state.heap.init(&mut uc)?;
// populate IntEnv
c_stdlib::setup_environment(&mut uc, &mut state, args, env_vars)?;
// inject shim functions
c_ctype::install_shims(&mut uc, &mut state)?;
c_fenv::install_shims(&mut state);
c_stdio::install_shims(&mut uc, &mut state)?;
c_stdlib::install_shims... | code_fim | hard | {
"lang": "rust",
"repo": "Treeki/mpw-emu",
"path": "/src/emulator/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Treeki/mpw-emu path: /src/emulator/mod.rs
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use std::time::Instant;
use anyhow::Result;
use bimap::BiHashMap;
use unicorn_engine::{Unicorn, RegisterPPC};
use unicorn_engine::unicorn_const::{Arch, HookType, Mode, Permission};
... | code_fim | hard | {
"lang": "rust",
"repo": "Treeki/mpw-emu",
"path": "/src/emulator/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
_registry: &mio::Registry,
_token: mio::Token,
) -> Result<()> {
Ok(())
}
fn nonblocking_help(&self) -> Result<()> {
Ok(())
}
}<|fim_prefix|>// repo: lowRISC/opentitan path: /sw/host/opentitanlib/src/io/nonblocking_help.rs
// Copyright lowRIS... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/host/opentitanlib/src/io/nonblocking_help.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lowRISC/opentitan path: /sw/host/opentitanlib/src/io/nonblocking_help.rs
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
use anyhow::Result;
/// In order to provide nonblocking functionality (... | code_fim | medium | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/host/opentitanlib/src/io/nonblocking_help.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
_registry: &mio::Registry,
_token: mio::Token,
) -> Result<()>;
fn nonblocking_help(&self) -> Result<()>;
}
/// Implementation to be used by backends which do not need to put any internal source into
/// `mio::poll()` of the main event loop.
pub struct NoNonblocking... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/host/opentitanlib/src/io/nonblocking_help.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slippytoadstata/vm-rs path: /vmm/kvm/src/vcpu.rs
use {VirtualMachine, RawFd, KVM_IO};
use errors::Result;
use object::Object;
use nix::unistd::close;
use nix::sys::mman::{mmap, munmap, PROT_READ, PROT_WRITE, MAP_SHARED};
use std::{mem, ptr};
use vm_x86::state::State;
/// Represents a virtual ... | code_fim | hard | {
"lang": "rust",
"repo": "slippytoadstata/vm-rs",
"path": "/vmm/kvm/src/vcpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> set_regs(self.fd, ®s)?;
}
} else {
let r = unsafe {
let mut regs = mem::uninitialized();
ioctl!(read get_regs with KVM_IO, 0x81; Registers);
get_regs(self.fd, &mut regs)?;
regs
... | code_fim | hard | {
"lang": "rust",
"repo": "slippytoadstata/vm-rs",
"path": "/vmm/kvm/src/vcpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Checks that setting / reading general-purpose registers works.
#[test]
fn general_registers() {
let vcpu = tests::get_vcpu();
const RAX: u64 = 0xAB_CD;
const RDX: u64 = 0x12_34;
{
let mut state: State = unsafe { mem::zeroed() };
sta... | code_fim | hard | {
"lang": "rust",
"repo": "slippytoadstata/vm-rs",
"path": "/vmm/kvm/src/vcpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hfaulds/octo-traders path: /src/cards.rs
use wasm_bindgen::JsCast;
use web_sys::CanvasRenderingContext2d;
use web_sys::HtmlCanvasElement;
use yew::prelude::*;
use yew::services::{RenderService, Task};
use crate::map;
pub struct Cards {
canvas: Option<HtmlCanvasElement>,
ctx: Option<CanvasR... | code_fim | hard | {
"lang": "rust",
"repo": "hfaulds/octo-traders",
"path": "/src/cards.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // canvas center
let cx = (canvas.width() as f64 - image_width) / 2.;
let cy = (canvas.height() as f64 - image_height) / 2.;
// card position
let tx = (x as f64 - (card_count as f64 / 2.) + 0.5) * (card.width + 10.) + cx;
let ty = cy - 60.;
return (tx, ty);
}
fn collide(mx: f64, my: f64, ca... | code_fim | hard | {
"lang": "rust",
"repo": "hfaulds/octo-traders",
"path": "/src/cards.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> kv.push_str(&format!("{}={}", k, v));
}
kv
}<|fim_prefix|>// repo: fayizk1/logshipper path: /src/tools/common.rs
use std::collections::BTreeMap;
pub fn join_btree_map(dict: BTreeMap<String, String>) -> String {
let mut kv<|fim_middle|> = String::from("");
for (k, v) in dict.iter() {... | code_fim | easy | {
"lang": "rust",
"repo": "fayizk1/logshipper",
"path": "/src/tools/common.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fayizk1/logshipper path: /src/tools/common.rs
use std::collections::BTreeMap;
pub fn join_btree_map(d<|fim_suffix|> kv.push_str(&format!("{}={}", k, v));
}
kv
}<|fim_middle|>ict: BTreeMap<String, String>) -> String {
let mut kv = String::from("");
for (k, v) in dict.iter() {... | code_fim | medium | {
"lang": "rust",
"repo": "fayizk1/logshipper",
"path": "/src/tools/common.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evanxg852000/erjson path: /src/buffer.rs
use std::fs::File;
use std::io::{prelude::*, BufReader, Lines};
use std::iter::Iterator;
use std::str;
#[derive(Debug)]
pub enum LineBuffer<'a> {
Text(str::Lines<'a>),
Reader(Lines<BufReader<File>>),
}
impl<'a> LineBuffer<'a> {
pub fn from_s... | code_fim | hard | {
"lang": "rust",
"repo": "evanxg852000/erjson",
"path": "/src/buffer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl StringIterator {
pub fn new(text: String) -> Self {
StringIterator {
chars: text.chars().collect(),
pos: 0,
}
}
}
impl Iterator for StringIterator {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
if self.pos >= self.chars... | code_fim | hard | {
"lang": "rust",
"repo": "evanxg852000/erjson",
"path": "/src/buffer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: claderoki/Intergalactica-Discord-Bot-Rust path: /src/modules/shared/repository/human.rs
use crate::database::schema::human;
use crate::database::utils::Countable;
use crate::modules::shared::models::human::Human;
use diesel::sql_query;
use diesel::sql_types::Integer;
use diesel::RunQueryDsl;
us... | code_fim | hard | {
"lang": "rust",
"repo": "claderoki/Intergalactica-Discord-Bot-Rust",
"path": "/src/modules/shared/repository/human.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get(uid: u64) -> HumanResult {
use crate::database::schema::human::dsl::*;
use diesel::prelude::*;
let connection = get_connection_diesel()?;
human
.filter(user_id.eq(uid))
.first::<Human>(&connection)
.map_err(|_| "Human not ... | code_fim | hard | {
"lang": "rust",
"repo": "claderoki/Intergalactica-Discord-Bot-Rust",
"path": "/src/modules/shared/repository/human.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/events/ws/web_socket_client_cmd.rs
// Copyright 2018-2022 Cargill Incorporated
//
// 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... | code_fim | medium | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/events/ws/web_socket_client_cmd.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>or the specific language governing permissions and
// limitations under the License.
use awc::ws::Frame;
pub(super) enum WebSocketClientCmd {
Frame(Frame),
Stop,
}<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/events/ws/web_socket_client_cmd.rs
// Copyright 2018-2022 Cargill Inc... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/events/ws/web_socket_client_cmd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ftware
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use awc::ws::Frame;
pub(super) enum WebSocketCl... | code_fim | medium | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/events/ws/web_socket_client_cmd.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DLR-FT/a653rs path: /macros/src/parse/channel.rs
use std::str::FromStr;
use darling::{FromAttributes, FromMeta};
use proc_macro2::Ident;
use quote::format_ident;
use strum::{Display, EnumString};
// use strum::{Display, EnumString, EnumVariantNames, VariantNames};
use syn::{parse_quote, spanned... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs",
"path": "/macros/src/parse/channel.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_content(items: &mut Vec<Item>) -> syn::Result<Vec<Channel>> {
let mut channel = vec![];
*items = items
.drain(..)
.filter_map(|item| match item {
Item::Struct(mut item) => {
let mut vec: Vec<Option<darling::Result<... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs",
"path": "/macros/src/parse/channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MayFromAttributes for QueuingInProc {
fn may_from_attributes(attrs: &mut Vec<Attribute>) -> Option<darling::Result<Self>> {
if !contains_attribute("queuing_in", attrs) {
return None;
}
let port = Some(Self::from_attributes(attrs));
Some(remove_attribute... | code_fim | hard | {
"lang": "rust",
"repo": "DLR-FT/a653rs",
"path": "/macros/src/parse/channel.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn priv_len(&self) -> usize { 32 }
fn pubkey(&self) -> &[u8] {
&self.keypair.public().as_ref()
}
fn privkey(&self) -> &[u8] {
&self.keypair.secret().as_ref()
}
fn set(&mut self, privkey: &[u8]) {
let mut s = [0; 32];
s.copy_from_slice(privkey);
... | code_fim | hard | {
"lang": "rust",
"repo": "foxundermoon/rust-libp2p",
"path": "/protocols/noise/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxundermoon/rust-libp2p path: /protocols/noise/src/util.rs
// Copyright 2019 Parity Technologies (UK) Ltd.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software witho... | code_fim | hard | {
"lang": "rust",
"repo": "foxundermoon/rust-libp2p",
"path": "/protocols/noise/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.keypair.public().as_ref()
}
fn privkey(&self) -> &[u8] {
&self.keypair.secret().as_ref()
}
fn set(&mut self, privkey: &[u8]) {
let mut s = [0; 32];
s.copy_from_slice(privkey);
let secret = SecretKey::new(s);
let public = secret.public... | code_fim | hard | {
"lang": "rust",
"repo": "foxundermoon/rust-libp2p",
"path": "/protocols/noise/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tweedegolf/rust-sync-async-test-cases path: /contrib/lis3dh/examples/ai2c.rs
#![feature(type_alias_impl_trait)]
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![no_std]
#![no_main]
// use circuit_playground_express as hal;
extern crate panic_halt;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "tweedegolf/rust-sync-async-test-cases",
"path": "/contrib/lis3dh/examples/ai2c.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Register::WHOAMI
let mut lis3dh = Lis3dh::new(twim, SlaveAddr::Default, Configuration::default())
.await
.unwrap();
let mut tracker = Tracker::new(3700.0);
loop {
let accel = lis3dh.accel_raw().await.unwrap();
let orientation = tracker.update(accel);
... | code_fim | hard | {
"lang": "rust",
"repo": "tweedegolf/rust-sync-async-test-cases",
"path": "/contrib/lis3dh/examples/ai2c.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GamepadEventMethods for GamepadEvent {
// https://w3c.github.io/gamepad/#gamepadevent-interface
fn Gamepad(&self) -> DomRoot<Gamepad> {
DomRoot::from_ref(&*self.gamepad)
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.event... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/gamepadevent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_with_type(global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad)
-> DomRoot<GamepadEvent> {
let name = match event_type {
GamepadEventType::Connected => "gamepadconnected",
GamepadEventType::Disconnected => "gamepaddis... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/style-servo/components/script/dom/gamepadevent.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn dataframe(pairs: Vec<(&str, Column)>) -> DataFrame<String> {
pairs.into_iter().map(|(k, v)| (k.to_owned(), v)).collect()
}
#[test]
fn test_make_split_dataframe() -> Fallible<()> {
let transformation = Result::from(opendp_trans__make_split_dataframe(
null(),
... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp-ffi/src/trans/dataframe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoyRin/opendp path: /rust/opendp-ffi/src/trans/dataframe.rs
use std::convert::TryFrom;
use std::fmt::Debug;
use std::hash::Hash;
use std::os::raw::c_char;
use opendp::err;
use opendp::trans::{make_create_dataframe, make_select_column, make_split_dataframe, make_split_lines, make_split_records};... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp-ffi/src/trans/dataframe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(opcode.is_terminator());
opcode.is_branch().then_some(last)
}
// Critical edges won't have successor information in block_succ_range, but
// they only have a single known successor to reco... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/codegen/src/machinst/blockorder.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/codegen/src/machinst/blockorder.rs
e 0->1) | | (edge 0->2) |
//! | CLIF block 1 | | CLIF block 2 |
//! | (edge 1->3) | | (edge 2->3) |
//! +--------------+ +--------------+
//! \ /
//! ... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/codegen/src/machinst/blockorder.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the lowered order of blocks.
pub fn lowered_order(&self) -> &[LoweredBlock] {
&self.lowered_order[..]
}
/// Get the successor indices for a lowered block.
pub fn succ_indices(&self, block: BlockIndex) -> (Option<Inst>, &[BlockIndex]) {
let (opt_inst, range) = &... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/codegen/src/machinst/blockorder.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> queue.push_back(new_remain)
}
}
// println!("{:?}, step {}, res {}", queue, step, result);
}
result as i32
}
}
struct Solution;<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/perfect_squares.rs
//! 279. Perfect ... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/rust-alg",
"path": "/src/leetcode/perfect_squares.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if new_remain == 0 && result > step {
result = step;
continue;
}
queue.push_back(new_remain)
}
}
// println!("{:?}, step {}, res {}", queue, step, result);
... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/rust-alg",
"path": "/src/leetcode/perfect_squares.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RicoGit/rust-alg path: /src/leetcode/perfect_squares.rs
//! 279. Perfect Squares
use std::collections::VecDeque;
impl Solution {
pub fn num_squares(n: i32) -> i32 {
let max_square = (n as f64).sqrt();
let squares = (1..=(max_square as usize))
.map(|n| n * n)
... | code_fim | hard | {
"lang": "rust",
"repo": "RicoGit/rust-alg",
"path": "/src/leetcode/perfect_squares.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ontroller", log_level)
.chain(std::io::stdout())
// .chain(fern::log_file("output.log")?)
.apply()
.unwrap();
log::info!("Initialized logger from options.");
}<|fim_prefix|>// repo: southball/judge-controller path: /src/logger.rs
use crate::cli::{self, Opts};
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "southball/judge-controller",
"path": "/src/logger.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: southball/judge-controller path: /src/logger.rs
use crate::cli::{self, Opts};
pub fn init_logger(opts: &Opts) {
// Derive log level from CLI options and construct logger.
let log_level = cli::calc_log_level(opts.verbosity, opts.quiet);
fern::Dispatch::new()
.format(|out, me... | code_fim | hard | {
"lang": "rust",
"repo": "southball/judge-controller",
"path": "/src/logger.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
F: FnOnce(Pool<ConnectionManager<PgConnection>>) -> Result<()>,
{
dotenv::dotenv().ok();
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(&database_url);
let pool ... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-social-bookmarking",
"path": "/src/pg/pg_user_repository.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-social-bookmarking path: /src/pg/pg_user_repository.rs
use crate::entity::{CredentialId, User, UserId, UserKey};
use crate::repository::UserRepository;
use crate::schema::{credential, user};
use anyhow::Result;
use diesel::{
prelude::*,
r2d2::{ConnectionManager, Pool},
s... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-social-bookmarking",
"path": "/src/pg/pg_user_repository.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Provides abstracted cryptographic primitives.
pub mod crypto;
/// Provides a cross-platform abstracted asynchronous executor.
pub mod executor;
/// Provides interfaces to graphics APIs.
pub mod graphics;
/// Provides interfaces to user input/HID APIs.
pub mod input;
/// Provides interfaces to abstract... | code_fim | hard | {
"lang": "rust",
"repo": "ZeroMemes/vessels",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZeroMemes/vessels path: /src/lib.rs
//! vessels is a software development framework intended to facilitate
//! the ergonomic development of performant cross-platform informational
//! ecosystems using a novel paradigm based on a single-source distributed
//! object model and low-overhead contain... | code_fim | hard | {
"lang": "rust",
"repo": "ZeroMemes/vessels",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanfdunn/hypermine path: /common/src/lib.rs
use rand::{
distributions::{Distribution, Standard},
Rng,
};
#[macro_use]
mod id;
mod chunks;
pub mod codec;
pub mod cursor;
pub mod dodeca;
pub mod graph;
mod graph_entities;
pub mod math;
pub mod proto;
mod sim_config;
pub mod world;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "nathanfdunn/hypermine",
"path": "/common/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Display for EntityId {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:016x}", self.0)
}
}
impl Distribution<EntityId> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> EntityId {
EntityId(rng.gen())
}
}
pub type... | code_fim | hard | {
"lang": "rust",
"repo": "nathanfdunn/hypermine",
"path": "/common/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Robbepop/cionc path: /src/parser/src/ast/item.rs
use ast::node_id::NodeId;
use ast::ptr::P;
use ast::expr::Expr;
use ::name::{Name};
pub struct Item {
pub id : NodeId,
pub kind: ItemKind
}
pub enum ItemKind {
/// Named items (`foo := struct {...}´) are Declarations
Defn(Defn),
<|fim_suf... | code_fim | hard | {
"lang": "rust",
"repo": "Robbepop/cionc",
"path": "/src/parser/src/ast/item.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub enum DefnKind {
/// Named binding to an expression. (`x := 42 + 1337;´)
Expr(ExprDefn),
/// Function definition (`add := fn(a: I32, b: I32) -> I32 { a + b }´)
Fn(FnDefn),
/// Struct definition (`Point2D := struct { x: F32, y: F32 }´)
Struct(StructDefn),
/// Enum definition (`Trite := enum { ... | code_fim | hard | {
"lang": "rust",
"repo": "Robbepop/cionc",
"path": "/src/parser/src/ast/item.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeakyBucket/app_therapy path: /src/server.rs
use byteorder::{NetworkEndian, ReadBytesExt};
use crypto;
use crypto::FileBacked;
use messaging::{Message, Payload};
use sodiumoxide::crypto::box_::{PublicKey, SecretKey};
use std::collections::HashMap;
use std::io::{Read, Write};
use std::net::TcpStr... | code_fim | hard | {
"lang": "rust",
"repo": "LeakyBucket/app_therapy",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.