text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: divergentdave/rsass path: /tests/spec/libsass_closed_issues/issue_2236/mod.rs
//! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_2236"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/libsass-closed-issues/issue_2236/floats.hrx"
#[test]
#[ignore] // wrong result... | code_fim | hard | {
"lang": "rust",
"repo": "divergentdave/rsass",
"path": "/tests/spec/libsass_closed_issues/issue_2236/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
rsass(
".foo {\r\
\n test-01: +0 % 1;\r\
\n test-02: -0 % 1;\r\
\n test-03: +0 % -1;\r\
\n test-04: -0 % -1;\r\
\n}"
)
.unwrap(),
".foo {\
\n test-01: 0;\
\n test-0... | code_fim | medium | {
"lang": "rust",
"repo": "divergentdave/rsass",
"path": "/tests/spec/libsass_closed_issues/issue_2236/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// From "sass-spec/spec/libsass-closed-issues/issue_2236/zeros.hrx"
#[test]
fn zeros() {
assert_eq!(
rsass(
".foo {\r\
\n test-01: +0 % 1;\r\
\n test-02: -0 % 1;\r\
\n test-03: +0 % -1;\r\
\n test-04: -0 % -1;\r\
\n}"
... | code_fim | hard | {
"lang": "rust",
"repo": "divergentdave/rsass",
"path": "/tests/spec/libsass_closed_issues/issue_2236/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("Stopping http server");
server
.stop(graceful)
.then(move |_result| {
info!("Stopping delta generator");
delta_generator.send(StopDeltaGenerator())
})
.then(move |_result| {
info!("Stopping job processing");
job... | code_fim | hard | {
"lang": "rust",
"repo": "flatpak/flat-manager",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flatpak/flat-manager path: /src/lib.rs
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
mod api;
mod app;
mod config;
mod db;
mod delayed;
mod deltas;
pub mod errors;
mod jobs;
mod logger;
mod models;
pub mod ostree;
mod schema;
mod tokens;
use actix::prelude::*... | code_fim | hard | {
"lang": "rust",
"repo": "flatpak/flat-manager",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn connect_to_db(config: &Arc<Config>) -> r2d2::Pool<ConnectionManager<PgConnection>> {
let manager = ConnectionManager::<PgConnection>::new(config.database_url.clone());
{
let mut conn = manager.connect().unwrap();
log::info!("Running DB Migrations...");
conn.run_pending_m... | code_fim | hard | {
"lang": "rust",
"repo": "flatpak/flat-manager",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tpm::LoadedSessionTpmHandle;
pub use tpm::NvIndexTpmHandle;
pub use tpm::PcrTpmHandle;
pub use tpm::PermanentTpmHandle;
pub use tpm::PersistentTpmHandle;
pub use tpm::PolicySessionTpmHandle;
pub use tpm::SavedSessionTpmHandle;
pub use tpm::TpmHandle;
pub use tpm::TransientTpmHandle;
mod tpm;<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "genofire/rust-tss-esapi",
"path": "/src/handles/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>e::session::SessionHandle;
pub use handle::tpm_constants::TpmConstantsHandle;
mod handle;
/////////////////////////////////////////////////////////
/// TPM Handles
/////////////////////////////////////////////////////////
pub use tpm::AcTpmHandle;
pub use tpm::HmacSessionTpmHandle;
pub use tpm::LoadedSess... | code_fim | hard | {
"lang": "rust",
"repo": "genofire/rust-tss-esapi",
"path": "/src/handles/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: genofire/rust-tss-esapi path: /src/handles/mod.rs
// Copyright 2020 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
/// Module that contains the different types of handles
/// that the ESAPI and the TPM uses in order to provide
/// access to objects that was or has be... | code_fim | hard | {
"lang": "rust",
"repo": "genofire/rust-tss-esapi",
"path": "/src/handles/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>erticalConentAlignment;
pub use self::container_style::ContainerStyle;
pub use self::weight::Weight;
pub use self::width::Width;
pub use self::width::WidthOrNumber;<|fim_prefix|>// repo: Peternator7/botframework-rs path: /adaptive_cards/src/props/mod.rs
mod color;
mod container_style;
mod height;
mod ho... | code_fim | hard | {
"lang": "rust",
"repo": "Peternator7/botframework-rs",
"path": "/adaptive_cards/src/props/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Peternator7/botframework-rs path: /adaptive_cards/src/props/mod.rs
mod color;
mod container_style;
mod height;
mod horizontal_alignment;
mod text_size;
mod image_size;
mod image_style;
mod spacing;
mod vertical_content_alignment;
mod weight;
mod width;
pub use self::color::Color;
pub use self:... | code_fim | medium | {
"lang": "rust",
"repo": "Peternator7/botframework-rs",
"path": "/adaptive_cards/src/props/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> system
.add(create_server(
&[(
"https://repository.timot.se/test2",
"./target/wasm32-unknown-unknown/release/test2.wasm",
)],
&system,
))
.unwrap();
system
.add(create_server(&[("https://repository... | code_fim | hard | {
"lang": "rust",
"repo": "atimos/lambdaless",
"path": "/system/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> system
.add(create_server(&[("https://repository.timot.se/test3", "./test3/main.wasm")], &system))
.unwrap();
println!("Running https://repository.timot.se/test1::return_double_arg");
println!(
"{:?}",
system
.run("https://repository.timot.se/test1"... | code_fim | hard | {
"lang": "rust",
"repo": "atimos/lambdaless",
"path": "/system/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atimos/lambdaless path: /system/src/main.rs
use std::{
collections::HashMap,
fs::read,
sync::{Arc, RwLock},
};
use wasmtime::{
ExportType, Extern, ExternType, HostRef, ImportType, Instance, Module as WasmModule, Store,
Trap, Val,
};
type Server = HashMap<String, Module>;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "atimos/lambdaless",
"path": "/system/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// try getting the threadnames, but don't sweat it if we can't. Since this relies on dictionary
// processing we only handle py3.6+ right now, and this doesn't work at all if the
// threading module isn't imported in the target program
pub fn thread_name_lookup(process: &PythonSpy) -> Option<HashMap<u64, ... | code_fim | hard | {
"lang": "rust",
"repo": "KonstantinKlepikov/py-spy",
"path": "/src/python_threading.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KonstantinKlepikov/py-spy path: /src/python_threading.rs
use std::collections::HashMap;
use failure::Error;
use crate::python_bindings::{v3_6_6, v3_7_0, v3_8_0};
use crate::python_interpreters::{InterpreterState, Object, TypeObject};
use crate::python_spy::PythonSpy;
use crate::python_data_acc... | code_fim | hard | {
"lang": "rust",
"repo": "KonstantinKlepikov/py-spy",
"path": "/src/python_threading.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl winsize {
pub fn get_row_col(&self) -> (c_ushort, c_ushort) {
(self.ws_row, self.ws_col)
}
}
pub use self::sys::*;
#[cfg(target_os = "linux")]
#[path = "linux.rs"]
pub mod sys;
#[cfg(target_os = "redox")]
#[path = "redox.rs"]
pub mod sys;<|fim_prefix|>// repo: redox-os/relibc path... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/sys_ioctl/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/relibc path: /src/header/sys_ioctl/mod.rs
//! ioctl implementation for linux
use crate::platform::types::*;
// This is used from sgtty
#[repr(C)]
pub struct sgttyb {
sg_ispeed: c_char,
sg_ospeed: c_char,
sg_erase: c_char,
sg_kill: c_char,
sg_flags: c_ushort,
}
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/sys_ioctl/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(target_os = "linux")]
#[path = "linux.rs"]
pub mod sys;
#[cfg(target_os = "redox")]
#[path = "redox.rs"]
pub mod sys;<|fim_prefix|>// repo: redox-os/relibc path: /src/header/sys_ioctl/mod.rs
//! ioctl implementation for linux
use crate::platform::types::*;
// This is used from sgtty
#[repr(C)]
p... | code_fim | medium | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/sys_ioctl/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrvon/leetcode path: /0015/0015_3sum.rs
struct Solution;
impl Solution {
pub fn three_sum(mut nums: Vec<i32>) -> Vec<Vec<i32>> {
let mut result: Vec<Vec<i32>> = vec![];
let n = nums.len();
nums.sort();
let mut i = 0;
while i < n {
if nums[... | code_fim | hard | {
"lang": "rust",
"repo": "mrvon/leetcode",
"path": "/0015/0015_3sum.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(vec![] as Vec<Vec<i32>>, Solution::three_sum(vec![]));
assert_eq!(vec![] as Vec<Vec<i32>>, Solution::three_sum(vec![0]));
assert_eq!(vec![vec![0, 0, 0]] as Vec<Vec<i32>>, Solution::three_sum(vec![0, 0, 0]));
assert_eq!(
vec![vec![-1, -1, 2], vec![-1, 0, 1]] as Vec<Vec<i3... | code_fim | hard | {
"lang": "rust",
"repo": "mrvon/leetcode",
"path": "/0015/0015_3sum.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) async fn list_aliases(
context: Context,
message: Message,
aliases: Vec<(String, String)>,
) {
if let Some(m) = aliases
.iter()
.map(|(alias, expr)| format!("`{}` => `{}`", alias, expr))
.reduce(|p1, p2| format!("{}\n{}", p1, p2))
{
if let Err... | code_fim | hard | {
"lang": "rust",
"repo": "RobinMarchart/roll-bot",
"path": "/discord-bot/src/handler/alias.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobinMarchart/roll-bot path: /discord-bot/src/handler/alias.rs
use serenity::{client::Context, model::channel::Message};
pub(crate) async fn add_alias(context: Context, message: Message) {
if let Err(err) = Message::react(&message, &context, '✅').await {
log::warn!("unable to react ... | code_fim | hard | {
"lang": "rust",
"repo": "RobinMarchart/roll-bot",
"path": "/discord-bot/src/handler/alias.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jchen706/freebsdrust path: /std/src/os/allocator.rs
#![no_std]
//#![allow(warnings, unused_variables, dead_code, improper_ctypes, non_camel_case_types, non_snake_case, non_upper_case_globals)]
use core::alloc::{GlobalAlloc, Layout};
use core::fmt;
use core::ptr;
use os::mutex::Mutex;
<|fim_s... | code_fim | medium | {
"lang": "rust",
"repo": "jchen706/freebsdrust",
"path": "/std/src/os/allocator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `LocalAlloc` is an analogous trait to the standard library's `GlobalAlloc`,
/// but it takes `&mut self` in `alloc()` and `dealloc()`.
pub trait LocalAlloc {
unsafe fn alloc(&mut self, layout: Layout) -> *mut u8;
unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout);
}
static ALLOCATOR:... | code_fim | medium | {
"lang": "rust",
"repo": "jchen706/freebsdrust",
"path": "/std/src/os/allocator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/grep/.meta/example.rs
use anyhow::Error;
use std::{fs, path::Path};
#[derive(Debug, thiserror::Error)]
enum FileAccessError {
#[error("File not found: {}", file_name)]
FileNotFoundError { file_name: String },
#[error("Error reading file: {}"... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/grep/.meta/example.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> inner_pattern = inner_pattern.to_lowercase();
}
if flags.use_inverted_comparison {
!inner_line.contains(&inner_pattern)
} else if flags.match_entire_line {
inner_line == inn... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/grep/.meta/example.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(e) = __a_r.close() {
return Err(e.into());
}
}}
}
mod into_model;
mod scope;
pub mod environment;
pub use self::environment::Environment;<|fim_prefix|>// repo: nmaraston/reproto path: /lib/trans/lib.rs
extern crate linked_hash_map;
#[macro_use]
extern crate l... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/trans/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for unused in $sel.unused() {
__a_r = __a_r.err(unused, "unknown attribute");
}
if let Some(e) = __a_r.close() {
return Err(e.into());
}
}}
}
mod into_model;
mod scope;
pub mod environment;
pub use self::environment::Environment;<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/trans/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nmaraston/reproto path: /lib/trans/lib.rs
extern crate linked_hash_map;
#[macro_use]
extern crate log;
extern crate reproto_ast as ast;
extern crate reproto_core as core;
extern crate reproto_naming as naming;
extern crate reproto_parser as parser;
extern crate reproto_path_parser as path_parser... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/trans/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/dbus/examples/unity_focused_window.rs
extern
crate
dbus
;
/
/
Tracks
currently
focused
window
under
the
Unity
desktop
by
listening
to
the
/
/
FocusedWindowChanged
signal
.
The
signal
contains
"
window_id
"
"
app_id
"
and
"
stage
"
/
/
we
print
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/dbus/examples/unity_focused_window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dowStack
"
{
return
None
}
;
if
&
*
m
.
member
(
)
.
unwrap
(
)
!
=
"
FocusedWindowChanged
"
{
return
None
}
;
let
(
_
app
)
=
m
.
get2
:
:
<
u32
&
str
>
(
)
;
app
}
fn
main
(
)
{
let
c
=
Connection
:
:
get_private
(
BusType
:
:
Session
)
.
unwrap
(
)
;
c
.
add_match
(
"
interface
=
'
com
.
canonical
.
Un... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/dbus/examples/unity_focused_window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> left: Option<Rc<RefCell<TreeNode>>>,
right: Option<Rc<RefCell<TreeNode>>>,
depth: i32,
) -> i32 {
match (left, right) {
(Some(l), Some(r)) => cmp::max(
add_depth(l.borrow().left.clone(), l.borrow().right.clone(), d... | code_fim | hard | {
"lang": "rust",
"repo": "Bert0324/leetcode-vscode",
"path": "/104.二叉树的最大深度.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bert0324/leetcode-vscode path: /104.二叉树的最大深度.rs
/*
* @lc app=leetcode.cn id=104 lang=rust
*
* [104] 二叉树的最大深度
*
* https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/description/
*
* algorithms
* Easy (71.39%)
* Likes: 433
* Dislikes: 0
* Total Accepted: 115.4K
* Total... | code_fim | hard | {
"lang": "rust",
"repo": "Bert0324/leetcode-vscode",
"path": "/104.二叉树的最大深度.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: homeworkprod/smfnotify path: /src/main.rs
/*
* Copyright 2022-2023 Jochen Kupperschmidt
* License: MIT
*/
#[macro_use]
extern crate log;
use crate::announce::Announcer;
use crate::config::{load_config, Config};
use crate::feed::FeedReader;
use crate::idkeeper::IdKeeper;
use anyhow::Result;
... | code_fim | hard | {
"lang": "rust",
"repo": "homeworkprod/smfnotify",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> simple_logger::init_with_level(level).unwrap()
}
struct Application {
id_keeper: IdKeeper,
feed_reader: FeedReader,
announcer: Announcer,
interval: Option<Duration>,
}
impl Application {
fn new(config: Config) -> Self {
Self {
id_keeper: IdKeeper {
... | code_fim | hard | {
"lang": "rust",
"repo": "homeworkprod/smfnotify",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Direction: Server -> Client.
pub struct ConnectionComplete {
const TAG = 129;
}
}<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/packets/connection_complete.rs
use crate::serde::packet_struct;
packet_struct! {
<|fim_middle|> /// Finished connecting to the serve... | code_fim | easy | {
"lang": "rust",
"repo": "Lonami/terry",
"path": "/terraria-protocol/src/packets/connection_complete.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/packets/connection_complete.rs
use crate::serde::packet_struct;
packet_struct! {
/// Finished connecting to the server.
///
<|fim_suffix|>onnectionComplete {
const TAG = 129;
}
}<|fim_middle|> /// Direction: Server -> Client.
... | code_fim | easy | {
"lang": "rust",
"repo": "Lonami/terry",
"path": "/terraria-protocol/src/packets/connection_complete.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> log!(debug, "appending {}", elm.to_string());
node.as_node().append(elm);
}
_ => return
}
}<|fim_prefix|>// repo: makovich/inliners path: /src/handler/base.rs
use crate::SH;
use crate::OPT;
use html5ever::{interface::QualName, local_name, namespace_url, ns};
... | code_fim | hard | {
"lang": "rust",
"repo": "makovich/inliners",
"path": "/src/handler/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makovich/inliners path: /src/handler/base.rs
use crate::SH;
use crate::OPT;
use html5ever::{interface::QualName, local_name, namespace_url, ns};
use kuchiki::{Attribute, ElementData, ExpandedName, NodeDataRef, NodeRef};
pub const TAG: SH = (r#"head"#, base_href);
<|fim_suffix|> if let Ok(t... | code_fim | hard | {
"lang": "rust",
"repo": "makovich/inliners",
"path": "/src/handler/base.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(tag) = node.as_node().select_first("base[href]") {
log!(debug, "{} found; skipping", tag.as_node().to_string());
return
}
match OPT.get_base().scheme() {
"https" |
"http" => {
let elm = NodeRef::new_element(
QualName::new(N... | code_fim | hard | {
"lang": "rust",
"repo": "makovich/inliners",
"path": "/src/handler/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let document = web_sys::window().unwrap_throw().document().unwrap_throw();
let div_json = document.create_element("div").unwrap_throw();
div_json.set_inner_html(&format!("{:#?}", object_json.get().unwrap_throw()));
document
.body()
.unwrap_throw()
.append_child(&di... | code_fim | hard | {
"lang": "rust",
"repo": "Ratysz/goods",
"path": "/examples/fetch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let div_json = document.create_element("div").unwrap_throw();
div_json.set_inner_html(&format!("{:#?}", object_json.get().unwrap_throw()));
document
.body()
.unwrap_throw()
.append_child(&div_json)
.unwrap_throw();
let div_yaml = document.create_element("di... | code_fim | hard | {
"lang": "rust",
"repo": "Ratysz/goods",
"path": "/examples/fetch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ratysz/goods path: /examples/fetch.rs
#![cfg(target_arch = "wasm32")]
use {goods::*, std::collections::HashMap, wasm_bindgen::prelude::*};
/// First we defined type to represent our assets.
#[derive(Clone, Debug, serde::Deserialize, PartialEq, Eq)]
struct Object {
key: Kind,
#[serde(f... | code_fim | hard | {
"lang": "rust",
"repo": "Ratysz/goods",
"path": "/examples/fetch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> CheckListItem::ensure_loaded();
Self {
props,
node_ref: NodeRef::default(),
request_selected_listener: None,
}
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
false
}
fn change(&mut self, props: Self::Prope... | code_fim | hard | {
"lang": "rust",
"repo": "realotz/material-yew",
"path": "/material-yew/src/list/check_list_item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> html! {
<mwc-check-list-item
left=bool_to_option(self.props.left)
graphic=self.props.graphic.to_cow_string()
disabled=self.props.disabled
ref=self.node_ref.clone()
>{ self.props.children.clone() }</mwc-check-li... | code_fim | hard | {
"lang": "rust",
"repo": "realotz/material-yew",
"path": "/material-yew/src/list/check_list_item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: realotz/material-yew path: /material-yew/src/list/check_list_item.rs
use crate::bool_to_option;
use crate::list::request_selected::request_selected_listener;
use crate::list::{GraphicType, RequestSelectedDetail};
use gloo::events::EventListener;
use wasm_bindgen::prelude::*;
use yew::prelude::*;... | code_fim | hard | {
"lang": "rust",
"repo": "realotz/material-yew",
"path": "/material-yew/src/list/check_list_item.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duchu89/design_patterns path: /command/src/command.rs
use crate::Stock;
pub trait Command {
fn execute(&self);
}
pub struct BuyStock<'a> {
stock: &'a Stock,
}
<|fim_suffix|> self.stock.buy();
}
}
pub struct SellStock<'a> {
stock: &'a Stock,
}
impl<'a> SellStock<'a> {
... | code_fim | medium | {
"lang": "rust",
"repo": "duchu89/design_patterns",
"path": "/command/src/command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct SellStock<'a> {
stock: &'a Stock,
}
impl<'a> SellStock<'a> {
pub fn new(stock: &'a Stock) -> SellStock<'a> {
SellStock{stock}
}
}
impl<'a> Command for SellStock<'a> {
fn execute(&self) {
self.stock.sell();
}
}<|fim_prefix|>// repo: duchu89/design_patterns ... | code_fim | medium | {
"lang": "rust",
"repo": "duchu89/design_patterns",
"path": "/command/src/command.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn into_ordinal(self) -> Result<RpEnumOrdinal> {
let ordinal = match self {
RpValue::String(value) => RpEnumOrdinal::String(value),
_ => return Err(Error::new("Not an ordinal")),
};
Ok(ordinal)
}
}
impl fmt::Display for RpValue {
fn fmt(&se... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/core/src/rp_value.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for RpValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let out = match *self {
RpValue::String(_) => "<string>",
RpValue::Number(_) => "<number>",
RpValue::Identifier(_) => "<identifier>",
RpValue::Array(_) => "<ar... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/core/src/rp_value.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nmaraston/reproto path: /lib/core/src/rp_value.rs
//! Value of models
use super::{Loc, RpEnumOrdinal, RpNumber};
use errors::{Error, Result};
use std::fmt;
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum RpValue {
String(Stri... | code_fim | medium | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/core/src/rp_value.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rdhaliwal/currency-converter path: /src/main.rs
#![allow(non_snake_case)]
use serde::Deserialize;
use std::collections::HashMap;
use std::env;
#[derive(Deserialize, Debug)]
struct ResponseData {
rates: HashMap<String, f32>,
base: String,
date: String,
}
<|fim_suffix|> let url =... | code_fim | hard | {
"lang": "rust",
"repo": "rdhaliwal/currency-converter",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"{}{} is {}{}",
input_currency, input_amount, output_currency, output_amount
);
return Ok(());
}<|fim_prefix|>// repo: rdhaliwal/currency-converter path: /src/main.rs
#![allow(non_snake_case)]
use serde::Deserialize;
use std::collections::HashMap;
use std::env;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "rdhaliwal/currency-converter",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = getintvec();
let k = v[0];
let n = v[1];
let families = getintvec();
let years = families.iter().fold(0, |acc, x| acc + x);
let num = k * n - years;
if num >= 0 {
println!("{}", num);
} else {
println!("-1");
}
}<|fim_prefix|>// repo: mottodora/c... | code_fim | medium | {
"lang": "rust",
"repo": "mottodora/contest",
"path": "/yukicoder/143.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mottodora/contest path: /yukicoder/143.rs
fn getline() -> String{
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
<|fim_suffix|> let v = getintvec();
let k = v[0];
let n = v[1];
let families = getintvec();
let years = families... | code_fim | medium | {
"lang": "rust",
"repo": "mottodora/contest",
"path": "/yukicoder/143.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/rkv/src/store/keys/encodables.rs
/
/
Copyright
2018
-
2019
Mozilla
/
/
/
/
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
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rkv/src/store/keys/encodables.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>leKey
{
fn
to_bytes
(
&
self
)
-
>
Result
<
Vec
<
u8
>
DataError
>
;
}
impl
<
T
>
EncodableKey
for
T
where
T
:
Serialize
{
fn
to_bytes
(
&
self
)
-
>
Result
<
Vec
<
u8
>
DataError
>
{
serialize
(
self
)
.
map_err
(
|
e
|
e
.
into
(
)
)
}
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_pa... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rkv/src/store/keys/encodables.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ither
express
or
implied
.
See
the
License
for
the
/
/
specific
language
governing
permissions
and
limitations
under
the
License
.
use
bincode
:
:
serialize
;
use
serde
:
:
Serialize
;
use
crate
:
:
error
:
:
DataError
;
pub
trait
EncodableKey
{
fn
to_bytes
(
&
self
)
-
>
Result
<
Vec
<
u8
>
DataError
>
;... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/rkv/src/store/keys/encodables.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edwardpku/sparrow_db path: /src/storage/rocksdb_engine.rs
extern crate rocksdb;
use rocksdb::rocksdb_options::WriteOptions;
use rocksdb::DB;
use sparrow_db_model::proto::operation::{GetRequest, GetResponse, PutRequest, PutResponse};
use std::sync::Arc;
use super::storage_engine::storage_engine... | code_fim | medium | {
"lang": "rust",
"repo": "edwardpku/sparrow_db",
"path": "/src/storage/rocksdb_engine.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut resp = GetResponse::new();
match self.db.get(req.get_key()) {
Ok(Some(value)) => {
println!("retrived value {}", value.to_utf8().unwrap());
resp.set_value(value.to_vec());
Ok(resp)
}
Ok(None) => Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "edwardpku/sparrow_db",
"path": "/src/storage/rocksdb_engine.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct rocksdb_engine {
pub db: Arc<DB>,
}
pub struct rocksdb_engine_config {
pub path: String,
}
impl rocksdb_engine {
pub fn new(config: &rocksdb_engine_config) -> Self {
Self {
db: Arc::new(DB::open_default(&config.path).unwrap()),
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "edwardpku/sparrow_db",
"path": "/src/storage/rocksdb_engine.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn c_addr(&self) -> &[u8] {
assert!(
size_of::<libc::sa_family_t>() <= self.1 && self.1 <= size_of::<libc::sockaddr_un>()
);
// Safety. The slice is part of self.
unsafe {
let addr_ptr = (&self.0 as *const _ as *const u8).add(size_of_val(&self.0.... | code_fim | hard | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/socket/addr/c_sock_addr.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tatetian/ngo2 path: /src/libos/crates/async-io/src/socket/addr/c_sock_addr.rs
use std::mem::{size_of, size_of_val, MaybeUninit};
/// A trait for all C version of C socket addresses.
///
/// There are four types that implement this trait:
/// * `libc::sockaddr_in`
/// * `(libc::sockaddr_in, usiz... | code_fim | hard | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/socket/addr/c_sock_addr.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c_storage =
unsafe { MaybeUninit::<libc::sockaddr_storage>::uninit().assume_init() };
c_storage.ss_family = self.c_family();
let offset = size_of_val(&c_storage.ss_family);
let c_storage_len = offset + self.c_addr().len();
assert!(c_storage_len... | code_fim | hard | {
"lang": "rust",
"repo": "tatetian/ngo2",
"path": "/src/libos/crates/async-io/src/socket/addr/c_sock_addr.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aeradriel/checkout_rs path: /src/instrument.rs
use crate::{http::HttpHandler, result::CheckoutResult};
use reqwest::Method;
use serde::{Deserialize, Serialize};
<|fim_suffix|> let url = format!("{}/instruments", self.base_url());
let token = self.run_request(
Method::... | code_fim | hard | {
"lang": "rust",
"repo": "Aeradriel/checkout_rs",
"path": "/src/instrument.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait InstrumentHandler: HttpHandler {
fn create_instrument(&self, data: CreateInstrumentData) -> CheckoutResult<Instrument> {
let url = format!("{}/instruments", self.base_url());
let token = self.run_request(
Method::POST,
url.parse().expect("Invalid instr... | code_fim | medium | {
"lang": "rust",
"repo": "Aeradriel/checkout_rs",
"path": "/src/instrument.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nakakura/study path: /frp/future-stream/hold_snapshot/src/main.rs
extern crate console;
extern crate futures;
extern crate tokio_core;
use console::Term;
use futures::*;
use futures::prelude::*;
use futures::executor;
use futures::future::{err, ok};
use futures::stream::{empty, iter_ok, poll_fn... | code_fim | hard | {
"lang": "rust",
"repo": "nakakura/study",
"path": "/frp/future-stream/hold_snapshot/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("send messate to localhost:3333 instead for button click");
let (tx, rx): (mpsc::Sender<isize>, mpsc::Receiver<isize>) = mpsc::channel::<isize>(5);
let (minus_input, minus_output): (mpsc::Sender<isize>, mpsc::Receiver<isize>) = mpsc::channel::<isize>(5);
minus_output.map(|x| -1);... | code_fim | hard | {
"lang": "rust",
"repo": "nakakura/study",
"path": "/frp/future-stream/hold_snapshot/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 31 - (x | 1).leading_zeros()
}
let mut rice_history: u32 = config.mb as u32;
let rice_history_mult = (config.pb as u32 * pb_factor as u32) / 4;
let k_max = config.kb;
let mut sign_modifier = 0;
let mut i = 0;
while i < buf.len() {
// `k` has a minimum value of... | code_fim | hard | {
"lang": "rust",
"repo": "ebarnard/alac.rs",
"path": "/src/dec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebarnard/alac.rs path: /src/dec.rs
et.
if channel_index + element_channels > self.config.num_channels {
return Err(invalid_data("packet contains more channels than expected"));
}
let element_samples = decode_aud... | code_fim | hard | {
"lang": "rust",
"repo": "ebarnard/alac.rs",
"path": "/src/dec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if lpc_mode[i as usize] == 15 {
// the special "numActive == 31" mode can be done in-place
lpc_predict_order_31(mix_buf[i], chan_bits);
} else if lpc_mode[i as usize] == 0 {
if lpc_order[i] == 31 {
return Err(inval... | code_fim | hard | {
"lang": "rust",
"repo": "ebarnard/alac.rs",
"path": "/src/dec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cezarmathe/qrwcell path: /src/raw.rs
//! The raw quick read-write cell.
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering as AtomicOrdering;
use std::sync::Arc;
use std::sync::Weak;
use parking_lot::Mutex;
use parking_lot::Once;
use parking_lot::OnceState;
use parking_lot::Rw... | code_fim | hard | {
"lang": "rust",
"repo": "cezarmathe/qrwcell",
"path": "/src/raw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Update the cell, returning the old value.
pub(crate) fn update(&self, new: T) -> Arc<T> {
self.init.call_once(|| ());
let _update_lock = self.update_lock.lock();
let new_arc = Arc::new(new);
let selector = self.get_selector() ^ 1;
{
let mut c... | code_fim | hard | {
"lang": "rust",
"repo": "cezarmathe/qrwcell",
"path": "/src/raw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dvc94ch/smol-netsim path: /nat/src/packet.rs
use pnet_packet::ip::IpNextHeaderProtocols;
use pnet_packet::ipv4::{self, Ipv4Packet, MutableIpv4Packet};
use pnet_packet::tcp::{self, MutableTcpPacket, TcpPacket};
use pnet_packet::udp::{self, MutableUdpPacket, UdpPacket};
use pnet_packet::{MutablePa... | code_fim | hard | {
"lang": "rust",
"repo": "dvc94ch/smol-netsim",
"path": "/nat/src/packet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn protocol(&self) -> Protocol {
self.protocol
}
pub fn set_source(&mut self, addr: SocketAddrV4) {
let mut packet = MutableIpv4Packet::new(self.bytes).unwrap();
packet.set_source(*addr.ip());
match self.protocol {
Protocol::Udp => {
... | code_fim | hard | {
"lang": "rust",
"repo": "dvc94ch/smol-netsim",
"path": "/nat/src/packet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod export;
pub(crate) mod model;
pub(crate) mod persistence;
pub(crate) mod utils;
mod spawn;
pub(crate) use spawn::spawn;
mod engine;
pub use engine::run;
pub use prodash;<|fim_prefix|>// repo: aidanhs/criner path: /criner/src/lib.rs
#![allow(clippy::unneeded_field_pattern)]
#![deny(unsafe_code... | code_fim | medium | {
"lang": "rust",
"repo": "aidanhs/criner",
"path": "/criner/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aidanhs/criner path: /criner/src/lib.rs
#![allow(clippy::unneeded_field_pattern)]
#![deny(unsafe_code)]
<|fim_suffix|>#[macro_use]
extern crate quick_error;
#[cfg(feature = "migration")]
pub mod migration;
pub mod error;
pub use error::{Error, Result};
pub mod export;
pub(crate) mod model;
p... | code_fim | easy | {
"lang": "rust",
"repo": "aidanhs/criner",
"path": "/criner/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fantom-foundation/librevm-rs path: /src/instruction.rs
b struct Program(pub Vec<RevmInstruction>);
#[derive(Clone, Debug)]
pub enum RevmInstruction {
Fd {
name: String,
args: u64,
skip: u64,
},
Mov {
register: u8,
value: Value,
},
Ineg... | code_fim | hard | {
"lang": "rust",
"repo": "Fantom-foundation/librevm-rs",
"path": "/src/instruction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn parse_u32(stream: &mut dyn Iterator<Item = u8>) -> Result<u32, Error> {
let bytes: Vec<u8> = stream.take(4).collect();
if bytes.len() != 4 {
return Err(ParsingError::UnexpectedEndOfStream.into());
}
#[allow(clippy::transmute_ptr_to_ptr)]
let byte_... | code_fim | hard | {
"lang": "rust",
"repo": "Fantom-foundation/librevm-rs",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(1)
}
fn get_cycles(&self) -> Result<usize, Error> {
Ok(1)
}
}
impl RevmInstruction {
fn parse_fd(stream: &mut dyn Iterator<Item = u8>) -> Result<RevmInstruction, Error> {
let name = RevmInstruction::parse_string(stream)?;
let args = RevmInstruction::pars... | code_fim | hard | {
"lang": "rust",
"repo": "Fantom-foundation/librevm-rs",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dahliaOS/fuchsia-pi4 path: /src/storage/fxfs/src/server/file.rs
async fn test_empty_file() {
let fixture = TestFixture::new().await;
let root = fixture.root();
let file =
open_file_checked(&root, OPEN_FLAG_CREATE | OPEN_RIGHT_READABLE, MODE_TYPE_FILE, "foo"... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/storage/fxfs/src/server/file.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let status = file.truncate(len as u64).await.expect("FIDL call failed");
Status::ok(status).expect("File truncate was successful");
let mut expected_buf = vec![0 as u8; len];
expected_buf[..input.as_bytes().len()].copy_from_slice(input.as_bytes());
let buf = read_... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/storage/fxfs/src/server/file.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dahliaOS/fuchsia-pi4 path: /src/storage/fxfs/src/server/file.rs
ory>) {
// NOP
}
fn into_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
self
}
}
impl DirectoryEntry for FxFile {
fn open(
self: Arc<Self>,
scope: ExecutionScope,
... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/storage/fxfs/src/server/file.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sprite = SpriteBundle {
material: materials.add(Color::rgb(0.08, 0.58, 0.0).into()),
// the sprite vector is directly proportionate to the collider size.
// eg 1: a new vec of 'x: 1.0, y: 1.0' is the same exact size as the col... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewCS149/Blazing-Bevy",
"path": "/Blazing-Bevy/platformer/src/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndrewCS149/Blazing-Bevy path: /Blazing-Bevy/platformer/src/map.rs
use crate::SCALE;
use bevy::prelude::*;
use bevy_rapier2d::{
physics::{ColliderBundle, ColliderPositionSync},
prelude::*,
render::ColliderDebugRender,
};
use std::collections::HashMap;
pub struct MapPlugin;
impl Plug... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewCS149/Blazing-Bevy",
"path": "/Blazing-Bevy/platformer/src/map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pijul-scm/thrussh path: /src/cipher/clear.rs
// Copyright 2016 Pierre-Étienne Meunier
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/l... | code_fim | hard | {
"lang": "rust",
"repo": "pijul-scm/thrussh",
"path": "/src/cipher/clear.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl super::SealingKey for Key {
// Cleartext packets (including lengths) must be multiple of 8 in
// length.
fn padding_length(&self, payload: &[u8]) -> usize {
let block_size = 8;
let padding_len = block_size - ((5 + payload.len()) % block_size);
if padding_len < 4 {
... | code_fim | hard | {
"lang": "rust",
"repo": "pijul-scm/thrussh",
"path": "/src/cipher/clear.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deathlyfrantic/project-euler path: /4.rs
/* find the largest palindromic number from the product of two
* 3-digit numbers (100-999)
*/
fn main() {
let mut num1: i32 = 999;
let mut largest: (i32, i32, i32) = (0, 0, 0);
<|fim_suffix|> let s = n.to_string();
let mut fwd_s = s.cha... | code_fim | hard | {
"lang": "rust",
"repo": "deathlyfrantic/project-euler",
"path": "/4.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> num1 -= 1;
}
println!("largest palindromic num -> {} * {} = {}", largest.1, largest.2, largest.0);
}
fn is_palindrome(n: i32) -> bool {
let s = n.to_string();
let mut fwd_s = s.chars();
let mut rev_s = s.chars().rev();
let mut c = fwd_s.next();
while c != None {
... | code_fim | hard | {
"lang": "rust",
"repo": "deathlyfrantic/project-euler",
"path": "/4.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("largest palindromic num -> {} * {} = {}", largest.1, largest.2, largest.0);
}
fn is_palindrome(n: i32) -> bool {
let s = n.to_string();
let mut fwd_s = s.chars();
let mut rev_s = s.chars().rev();
let mut c = fwd_s.next();
while c != None {
if c != rev_s.next() {... | code_fim | medium | {
"lang": "rust",
"repo": "deathlyfrantic/project-euler",
"path": "/4.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>n USBDevIntSt (Section 13.10.3.2) is set."]
#[inline(always)]
pub fn frameset(&mut self) -> FRAMESET_W {
FRAMESET_W { w: self }
}
#[doc = "Bit 1 - 0 = No effect. 1 = The corresponding bit in USBDevIntSt (Section 13.10.3.2) is set."]
#[inline(always)]
pub fn ep_fastset(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/usb/devintset.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/usb/devintset.rs
#[doc = "Writer for register DEVINTSET"]
pub type W = crate::W<u32, super::DEVINTSET>;
#[doc = "Register DEVINTSET `reset()`'s with value 0"]
impl crate::ResetValue for super::DEVINTSET {
type Type = u32;
#[inline(always)]
fn reset_v... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/usb/devintset.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seanpianka/leetcode-rust path: /src/dp/triangle.rs
/// https://leetcode.com/problems/triangle/
/// 求从顶部到底层的最短路径,注意函数名的top_bottom并不是递归/分治法的top_down/bottom_up的含义,函数名仅仅表示遍历输入二维数组的方向
fn from_top_to_bottom(mut triangle: Vec<Vec<i32>>) -> i32 {
<|fim_suffix|> let test_cases = vec![(vec_vec![[2], [3... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/leetcode-rust",
"path": "/src/dp/triangle.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_cases = vec![(vec_vec![[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]], 11)];
for (input, output) in test_cases {
assert_eq!(from_top_to_bottom(input.clone()), output);
assert_eq!(from_bottom_to_top(input), output);
}
}<|fim_prefix|>// repo: seanpianka/leetcode-rust path: /src/... | code_fim | hard | {
"lang": "rust",
"repo": "seanpianka/leetcode-rust",
"path": "/src/dp/triangle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut context = create_ctx_without_session();
let (_, rc) = context.get_test_result().unwrap();
rc.unwrap();
}
}<|fim_prefix|>// repo: parallaxsecond/rust-tss-esapi path: /tss-esapi/tests/integration_tests/context_tests/tpm_commands/testing_tests.rs
// Copyright 2021 Contrib... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/rust-tss-esapi",
"path": "/tss-esapi/tests/integration_tests/context_tests/tpm_commands/testing_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod test_get_test_result {
use crate::common::create_ctx_without_session;
#[test]
fn test_get_test_result() {
let mut context = create_ctx_without_session();
let (_, rc) = context.get_test_result().unwrap();
rc.unwrap();
}
}<|fim_prefix|>// repo: parallaxsecond/rust... | code_fim | medium | {
"lang": "rust",
"repo": "parallaxsecond/rust-tss-esapi",
"path": "/tss-esapi/tests/integration_tests/context_tests/tpm_commands/testing_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct UpdateCellIterator {
input: PipelineIterator,
columns: Option<HashSet<String>>,
engine_state: EngineState,
stack: Stack,
block: Block,
redirect_stdout: bool,
redirect_stderr: bool,
span: Span,
}
impl Iterator for UpdateCellIterator {
type Item = Value;
fn n... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-cmd-extra/src/extra/filters/update_cells.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let span = call.head;
stack.with_env(&orig_env_vars, &orig_env_hidden);
// the columns to update
let columns: Option<Value> = call.get_flag(&engine_state, &mut stack, "columns")?;
let columns: Option<HashSet<String>> = match columns {
Some(val) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-cmd-extra/src/extra/filters/update_cells.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-cmd-extra/src/extra/filters/update_cells.rs
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::{Block, Call};
use nu_protocol::engine::{Closure, Command, EngineState, Stack};
use nu_protocol::{
Category, Example, IntoInterruptiblePipelineData, IntoPi... | code_fim | hard | {
"lang": "rust",
"repo": "nushell/nushell",
"path": "/crates/nu-cmd-extra/src/extra/filters/update_cells.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.