blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
8630407bea1fabfdb188257a1969127959625343 | Rust | NotGyro/Gestalt | /gestalt-core/src/client/client_config.rs | UTF-8 | 2,611 | 2.8125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use winit::window::Fullscreen;
pub const WINDOW_TITLE: &str = "Gestalt";
pub const CLIENT_CONFIG_FILENAME: &str = "client_config.ron";
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub enum WindowMode {
Windowed {
/// If windowed, can this be resized with the OS' drag-a... | true |
3cc07a1c903b07856d1d1146b145ec959731d174 | Rust | pwil3058/rs_ord_set_ops_iter | /ord_set_iter_set_ops/src/set_relationships.rs | UTF-8 | 6,463 | 2.921875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2023 Peter Williams <pwil3058@gmail.com> <pwil3058@bigpond.net.au>
#[macro_export]
macro_rules! are_disjoint {
($left_iter: expr, $right_iter: expr) => {{
loop {
if let Some(my_item) = $left_iter.peep() {
if let Some(other_item) = $right_iter.peep() {
... | true |
018bd19aa53e1d0fa484017a0f3e7cc9e1885c81 | Rust | hem6/atcoder-rs | /abc172/src/bin/b.rs | UTF-8 | 371 | 2.515625 | 3 | [] | no_license | #![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
fn main() {
input! {
s: Chars,
t: Chars,
}
let n = s.len();
let mut ans = 0;
for i in 0..n {
if s[i] != t[i] {
ans... | true |
a5a1d26277728ce456c616fc104b1a97baf8a3fe | Rust | osmosis-labs/wormhole | /terra/contracts/wormhole/src/error.rs | UTF-8 | 3,084 | 2.765625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use cosmwasm_std::StdError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ContractError {
/// Invalid VAA version
#[error("InvalidVersion")]
InvalidVersion,
/// Guardian set with this index does not exist
#[error("InvalidGuardianSetIndex")]
InvalidGuardianSetIndex,
/// Guardian s... | true |
53dae0c10f20c8c1808163c2256e1342e3b6801d | Rust | w23/alacritty | /alacritty/src/renderer/glyph.rs | UTF-8 | 13,810 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use super::math::*;
use crate::config::font::{Font, FontDescription};
use crate::config::ui_config::Delta;
use crate::config::Config;
use crate::cursor;
use alacritty_terminal::ansi::CursorStyle;
use alacritty_terminal::term::CursorKey;
use crossfont::{FontDesc, FontKey, Rasterize, Rasterizer, Size, Slant, Style, Weigh... | true |
689cb2fe3a2faff2bfe8a7552e7cb3be27a44201 | Rust | mahulst/advent-of-code-2018 | /day10/src/lib.rs | UTF-8 | 6,858 | 3.4375 | 3 | [] | no_license | use regex::Regex;
use std::str::FromStr;
use std::collections::HashMap;
use core::cmp;
#[derive(Debug, PartialEq, Clone)]
pub struct Point {
pub x: i32,
pub y: i32,
}
#[derive(Debug, PartialEq)]
pub struct Star {
pub velocity: Point,
pub position: Point,
}
pub fn input_to_stars(input: &str) -> HashMa... | true |
44fbd682a412237178b892193c1ec92b7f950d0e | Rust | MrMonotone/caper | /src/posteffect.rs | UTF-8 | 4,363 | 2.6875 | 3 | [
"MIT"
] | permissive | use glium::{ Surface, Program };
use glium::index::{ PrimitiveType, IndexBuffer };
use glium::vertex::VertexBuffer;
use glium::backend::{ Facade, Context };
use glium::framebuffer::{ SimpleFrameBuffer, DepthRenderBuffer };
use glium::texture::Texture2d;
use glium::texture::DepthFormat::I24;
use std::cell::RefCell;
use... | true |
e22e466d4446067bc3255123f711a7d39a303302 | Rust | solotzg/rs-hash-ord | /src/list.rs | UTF-8 | 4,752 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::ptr;
pub type ListHeadPtr = *mut ListHead;
#[derive(Copy, Clone)]
pub struct ListHead {
pub next: ListHeadPtr,
pub prev: ListHeadPtr,
}
impl Default for ListHead {
fn default() -> Self {
ListHead {
next: ptr::null_mut(),
prev: ptr::null_mut(),
}
}
}
i... | true |
bb1abb4b0816d3d1bc1e4ed5fc92c0fd8f29a64c | Rust | iCodeIN/basita | /src/game/entities/block.rs | UTF-8 | 850 | 2.578125 | 3 | [] | no_license | use basita::sdl2::pixels::Color;
use basita::{
core::{components::Transform, resources::LazyEvaluations},
math::Vector2,
physics::components::Collider,
renderer::components::Sprite,
};
use crate::MyGame;
pub struct BlockEntity {
pub transform: Transform,
pub sprite: Sprite,
pub collider: Collider,
}
pub fn n... | true |
f0a26d947e1178ae1dda0a005f6f0a42df1a0f82 | Rust | chinagxwei/rust-by-example | /src/example_18_error/example_18_4_multiple_error_types/example_18_4_5_wrap_error.rs | UTF-8 | 1,711 | 3.484375 | 3 | [] | no_license | use std::num::ParseIntError;
use std::fmt::{Formatter, Error};
#[derive(Debug)]
enum DoubleError {
EmptyVec,
Parse(ParseIntError),
}
type Result<T> = std::result::Result<T, DoubleError>;
impl std::fmt::Display for DoubleError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match *sel... | true |
6d42e53c9ea4b1aa6673b62e8986d7b192a0ae5e | Rust | tipeter/rust-dsp | /src/dproc.rs | UTF-8 | 1,574 | 3.078125 | 3 | [] | no_license | use std::sync::mpsc::{channel, Receiver, Sender, TryRecvError};
use std::thread;
use std::time::{Duration, Instant};
#[derive(Debug)]
pub enum DProcCommand {
SendData(Vec<f64>),
DoProcessing,
}
#[derive(Debug)]
pub enum DProcResponse {
Data(Vec<f64>),
ProcProgress(u8),
}
#[derive(Debug)]
pub struct D... | true |
a4b96089cab50716d3599b486900a98717ec5c76 | Rust | PizzasBear/Async-NEAT.rs | /src/neat/links.rs | UTF-8 | 406 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | pub(super) struct Links {
pub innovs: Vec<usize>,
pub enabled: Vec<bool>,
pub weights: Vec<f64>,
}
impl Links {
pub fn len(&self) -> usize {
self.innovs.len()
}
}
impl Clone for Links {
fn clone(&self) -> Self {
Self {
innovs: self.innovs.clone(),
enable... | true |
806657dd193723d1e34230cbd5c289495405b737 | Rust | mpapierski/guac_rs | /guac_core/src/transports/http/client.rs | UTF-8 | 14,622 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use actix_web::client;
use actix_web::client::ClientResponse;
use actix_web::client::Connection;
use actix_web::HttpMessage;
use channel_client::types::{Channel, UpdateTx};
use failure::Error;
use futures::Future;
use std::net::SocketAddr;
use tokio::net::TcpStream;
use transport_protocol::CounterpartyApi;
use transpor... | true |
ca1be3d50a682c9a29f3c5e253218e5eb623cd36 | Rust | FengchenX/orbtk-mirror | /src/bin/alg/alg/hash_table.rs | UTF-8 | 5,201 | 3.59375 | 4 | [
"MIT"
] | permissive | use orbtk::prelude::HashMap;
fn two_sum(nums: &[i32], target: i32 , result: &mut Vec<usize>) {
if nums.len() == 0 {
return;
}
let mut m = HashMap::new();
for i in 0..nums.len() {
let a = (target-nums[i]) as usize ;
if m.contains_key(&a) {
result.push(i);
match m.... | true |
dec8e1d5e4cc44e553b215f669b0865e6b5211a1 | Rust | KnaveAndVarlet/ADASS2019 | /crssub_unsafe.rs | UTF-8 | 3,985 | 3.140625 | 3 | [] | no_license | //
// c r s s u b _ u n s a f e . r s
//
// Summary:
// 2D array access test subroutine in Rust, using unsafe code.
//
// Introduction:
// This is a test routine written as part of a study into how well different
// languages handle accessing elements of 2D rectangular arrays. This ro... | true |
bd1f289332df8e77157c39ac43843bc82da26929 | Rust | JoelWilloughby/Adventofcode_2018 | /aoc_02/src/main.rs | UTF-8 | 1,044 | 3.234375 | 3 | [] | no_license |
use std::fs::File;
use std::io::{Read, BufReader, BufRead};
fn read<R: Read>(io: R) -> Vec<String> {
let br = BufReader::new(io);
br.lines().map(|l| l.unwrap()).collect()
}
fn num_diffs(s1 : &String, s2: &String) -> usize {
let mut num : usize = 0;
let b1 = s1.as_bytes();
let b2 = s2.as_bytes();
... | true |
717de3320fa1503c64a596bb7d682e3207513a73 | Rust | danieldulaney/windows-permissions-rs | /src/wrappers/convert_string_sid_to_sid.rs | UTF-8 | 1,253 | 3.0625 | 3 | [] | no_license | use crate::utilities::buf_from_os;
use crate::{LocalBox, Sid};
use std::ffi::OsStr;
use std::io;
use std::ptr::{null_mut, NonNull};
/// Wraps [`ConvertStringSidToSidW`](https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertstringsidtosidw).
///
/// ```
/// use windows_permissions::{Sid, wrappers::Conv... | true |
e4c03ccd13d9f1ba7faf7a7daea5f1827f7f632e | Rust | jdatcmd/pgx | /pgrx/src/datum/array.rs | UTF-8 | 33,032 | 2.5625 | 3 | [
"MIT"
] | permissive | /*
Portions Copyright 2019-2021 ZomboDB, LLC.
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <support@tcdi.com>
All rights reserved.
Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
use crate::array::RawArray;
use crate::datum::array::casper::ChaChaSli... | true |
3f61d4458fcb9c80288f80fa7d336d1e40add1d1 | Rust | barreiro/euler | /src/main/rust/euler/solver013.rs | UTF-8 | 714 | 2.640625 | 3 | [
"MIT"
] | permissive | // COPYRIGHT (C) 2017 barreiro. All Rights Reserved.
// Rust solvers for Project Euler problems
use algorithm::cast::Cast;
use algorithm::digits::first_digits;
use algorithm::io::load_default_data;
use euler::Solver;
/// Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
pub struc... | true |
e77b18a7705a958f7828729ba22efa9beef7ea9e | Rust | ZerQAQ/lexer-for-C | /src/main.rs | UTF-8 | 820 | 2.828125 | 3 | [] | no_license | mod lexer;
use lexer::Lexer;
use lexer::Token;
use std::fs;
fn main() {
let s = fs::read_to_string("test.c").unwrap();
let mut l = Lexer::new(&s);
loop{
let v = l.next_token().unwrap();
match v {
Token::Identifier(code) => {
print!("ID_{} ", l.identifier_ma... | true |
a02457b924c4c9db5b980f9da0f8d5f1817f117f | Rust | jamwaffles/gcodetools | /expression/src/evaluator.rs | UTF-8 | 11,234 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::{ArithmeticOperator, Context, Expression, ExpressionToken, Function};
use num_traits::Float;
fn shunting_yard<V>(tokens: Expression<V>, context: Option<&Context<V>>) -> Vec<ExpressionToken<V>>
where
V: Float + From<f32>,
{
let mut output: Vec<ExpressionToken<V>> = Vec::new();
let mut operators: ... | true |
b631831b16aa8440a16aa915090f96ab91e80851 | Rust | atsisy/torifune | /src/graphics/object/menu.rs | UTF-8 | 2,539 | 2.78125 | 3 | [
"MIT"
] | permissive | use ggez::graphics as ggraphics;
use crate::graphics::object::*;
use super::sub_screen;
use super::sub_screen::SubScreen;
pub struct VerticalMenu {
item_text: Vec<VerticalText>,
canvas: SubScreen,
}
///
/// 縦書きの文字列列挙を行うための構造体
///
impl VerticalMenu {
pub fn new(
ctx: &mut ggez::Context,
p... | true |
0fbf646eef3aec14673b05733920f441432cd8e1 | Rust | rowanras/micromouse | /firmware/src/time.rs | UTF-8 | 1,100 | 2.796875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use stm32f4xx_hal::stm32 as stm32f405;
static OVERFLOW_VALUE: u32 = 65535;
pub struct Time {
timer: stm32f405::TIM1,
last_time: u32,
overflows: u32,
}
impl Time {
pub fn setup(rcc: &stm32f405::RCC, timer: stm32f405::TIM1) -> Time {
// Enable clock for timer 4
rcc.apb2enr.modify(|_, w|... | true |
79d513833bacdfc53c0c283ef500e0238e06832c | Rust | alvaro-cuesta/advent-solutions | /src/advent2017/09-stream_processing.rs | UTF-8 | 9,618 | 3.6875 | 4 | [] | no_license | //! # [Day 9: Stream Processing](http://adventofcode.com/2017/day/9)
//!
//! A large stream blocks your path. According to the locals, it's not safe
//! to <span title=""Don't cross the streams!", they yell, even though
//! there's only one. They seem to think they're hilarious.">cross the
//! stream</span> a... | true |
d16bd48f6ef057cf92c0c717797d029cfc546471 | Rust | guo-wn/intspan | /src/cmd_ovlpr/paf2ovlp.rs | UTF-8 | 1,395 | 2.796875 | 3 | [
"MIT"
] | permissive | use clap::*;
use intspan::*;
use std::io::BufRead;
// Create clap subcommand arguments
pub fn make_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("paf2ovlp")
.about("Convert minimap .paf to overlaps")
.arg(
Arg::with_name("infiles")
.help("Sets the input fil... | true |
99ebc446eba7412c2533a09214f1f74c4b32a9ed | Rust | Leinnan/slavic_castles | /src/ui/button.rs | UTF-8 | 4,118 | 2.796875 | 3 | [] | no_license | use crate::consts;
use crate::ui::animations;
use quicksilver::{
combinators::result,
geom::{Rectangle, Shape, Transform, Vector},
graphics::{
Background::Blended, Background::Col, Background::Img, Color, Font, FontStyle, Image,
},
lifecycle::{run, Asset, Settings, State, Window},
Future... | true |
e4a31b47a4f6fd801750b198d5137e36199f91ff | Rust | iampiyush/sri-delhi-rust-libcss | /libwapcaplet/wapcaplet.rs | UTF-8 | 4,045 | 2.734375 | 3 | [] | no_license | #[link(name = "wapcaplet", vers = "1.0")];
#[crate_type = "lib"];
extern mod extra;
use std::hashmap::HashMap;
use std::str;
pub struct lwc_string {
id: uint,
string: @str,
insensitive: Option<uint>
}
pub struct lwc {
priv map: HashMap<@str, uint>,
priv vect:~[@mut lwc_string]
}
impl lwc {
... | true |
9ff73f687ac9acbbc03bc9dab1a983ff9433616a | Rust | bryanbrady/ray-tracing-in-one-weekend | /src/hittable/flip_face.rs | UTF-8 | 1,102 | 2.828125 | 3 | [] | no_license | use crate::hittable::{aabb::Aabb, HitRecord, Hittable, Hittables};
use crate::ray::Ray;
use rand::rngs::SmallRng;
#[derive(Debug, Clone)]
pub struct FlipFace {
pub object: Box<Hittables>,
}
impl FlipFace {
pub fn new(object: Hittables) -> Hittables {
Hittables::from(FlipFace {
object: Box:... | true |
45de1c68be0ff0d0ef3238256061105f5499b40d | Rust | CoinArcade/arena_keeper | /scripts/templates/window.rs | UTF-8 | 1,762 | 2.765625 | 3 | [] | no_license | use crate::agents::router;
use crate::generated::routes;
//use crate::classes::character::Character;
use yew::prelude::*;
pub struct {{WINDOW_NAME_CAPS}} {
is_open :bool,
route_worker: Box<Bridge<router::Worker>>,
}
pub enum Msg {
Toggle,
Close,
Router(router::Request)
}
#[derive(PartialEq, Clone)]
pub struct P... | true |
8cddd1a56dde6dcf20ec46641d55a86223d682df | Rust | RoflMalovski/yakuza-freecam | /yakuza0/src/main.rs | UTF-8 | 7,359 | 2.515625 | 3 | [
"MIT"
] | permissive | use common::external::{get_version, Camera, Injection};
use memory_rs::external::process::Process;
use std::f32;
use std::io::Error;
use std::rc::Rc;
use std::thread;
use std::time::{Duration, Instant};
use winapi::shared::windef::POINT;
use winapi::um::winuser;
use winapi::um::winuser::{GetAsyncKeyState, GetCursorPos,... | true |
c889fb50031b94d4ad559d6fc05716bc822d578e | Rust | lynn/sigbovik | /asdf/src/cdfbisect.rs | UTF-8 | 3,673 | 3.1875 | 3 | [] | no_license | use crate::sim::{
BisectAttempt,
BisectStrategy,
SimulationState,
};
// it just finds where the cdf crosses 0.5 or whatever
pub struct CdfBisect {
bisect_point: f64,
earliest_bug_seen: usize,
}
impl CdfBisect {
// TODO: make these `new()`s take a &SimulationState
// so you can initialize u... | true |
c909e329499e135835e58eaecee88f87f472a7ca | Rust | fyang93/rust-leetcode | /src/p0069_sqrt_x.rs | UTF-8 | 574 | 3.65625 | 4 | [] | no_license | // 二分法
pub fn my_sqrt(x: i32) -> i32 {
if x < 2 { return x; }
let (mut l, mut r) = (0, x);
while r - l > 1 {
let m = (r - l) / 2 + l;
if x / m < m {
r = m;
} else {
l = m;
}
}
l
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ... | true |
1f5f85a1c87bb03684516aa04df9b33fe76aa473 | Rust | yutiansut/sonnerie | /tests/normal.rs | UTF-8 | 3,058 | 2.9375 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive |
use sonnerie::Writer;
use sonnerie::Reader;
use std::io::BufWriter;
use byteorder::*;
#[test]
fn basic1()
{
let t = tempfile::TempDir::new().unwrap();
{
let w = std::fs::File::create(t.path().join("w")).unwrap();
let w = BufWriter::new(w);
let mut w = Writer::new(w);
w.add_record("ab", "u", b"... | true |
dc3875a3bbc8549b9322fa93fae216b6f8b5bef8 | Rust | dsbrgg/exercises | /rust/shortest_word/src/main.rs | UTF-8 | 924 | 3.453125 | 3 | [] | no_license | fn main() {
returns_expected();
}
fn find_short(s: &str) -> u32 {
s.split_whitespace()
.fold(100, |acc, word| match (word.len() as u32) < acc {
true => word.len() as u32,
false => acc
})
}
// better implementations
fn first(s: &str) -> u32 {
s.split_whitespace().map(str::len).min().unwrap()
}
fn se... | true |
2d6d3a284685ba7b2ab832ef69046bc00f0f0fbc | Rust | geropl/rust-go-node | /rust-lib-wasm/src/lib.rs | UTF-8 | 902 | 3.140625 | 3 | [] | no_license | use wasm_bindgen::prelude::*;
use rust_lib;
use js_sys;
#[wasm_bindgen]
pub fn concatenate_strings(a: String, b: String) -> Result<String, JsValue> {
let a = Some(a.as_str());
let b = Some(b.as_str());
rust_lib::concatenate_strings(&a, &b)
.or_else(map_to_js_error)
}
fn map_to_js_error(_err: rust... | true |
a2fb45ebee71178b837b3c06943dfd02f3ac14fa | Rust | CohenArthur/rustc_codegen_cranelift | /src/toolchain.rs | UTF-8 | 4,666 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Locating various executables part of a C toolchain.
use std::path::PathBuf;
use rustc_middle::bug;
use rustc_session::Session;
use rustc_target::spec::LinkerFlavor;
/// Tries to infer the path of a binary for the target toolchain from the linker name.
pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str... | true |
47fb81c7bf3874ba36e7d3cfbee6e87687623bf4 | Rust | mjonuschat/mtp-transfer | /src/mtp/utils/filetree.rs | UTF-8 | 2,155 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::Result;
use indicatif::ProgressBar;
use libmtp_rs::device::MtpDevice;
use libmtp_rs::object::{filetypes::Filetype, Object};
use libmtp_rs::storage::{Parent, Storage};
use ptree::item::StringItem;
use crate::helpers;
use crate::mtp::Device;
use crate::types::DeviceSelector;
pub fn filetree(selector: Device... | true |
16464b3745941ac1ce7d66e6422cf19cfea94534 | Rust | filmor/eir | /compiler/src/ir/lir/pass/promote_tail_calls.rs | UTF-8 | 3,704 | 2.84375 | 3 | [] | no_license | use ::eir::{ SSAVariable, Source };
use ::eir::cfg::{ FunctionCfg, EdgeN, LabelN };
use ::eir::op::{ OpKind };
use std::collections::HashSet;
fn does_return_val(cfg: &FunctionCfg, in_edge: EdgeN, val: SSAVariable) -> bool {
let label = cfg.graph.edge_to(in_edge);
let block_container = &cfg.graph[label];
le... | true |
0c6eb700d57bf774086b6413603a753c6b84c46d | Rust | MaskRay/99-problems-rust | /24.rs | UTF-8 | 192 | 2.984375 | 3 | [] | no_license | use std::rand::{thread_rng, sample};
fn lotto_select(k: usize, n: usize) -> Vec<usize> {
sample(&mut thread_rng(), range(0, n), k)
}
fn main() {
println!("{:?}" , lotto_select(3, 5));
}
| true |
3510885f9b96d39f2d7e396256974fd799513187 | Rust | MaterializeInc/rust-decimal | /fuzzer/src/main.rs | UTF-8 | 2,151 | 2.890625 | 3 | [
"MIT"
] | permissive | mod command;
use clap::{crate_authors, crate_version, App, Arg, SubCommand};
use std::path::Path;
use std::str::FromStr;
fn main() -> std::result::Result<(), String> {
// Command line:
// 1. Generate fuzz file of size (this generates expected)
// 2. Take fuzz file and check results
let matches = Ap... | true |
5b8e9250430abf7ea07f62f1b509d32baa205a09 | Rust | david415/cryptocomrade | /rust/src/sikes.rs | UTF-8 | 670 | 2.75 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #[cfg(test)]
mod tests {
extern crate rust_sike;
use self::rust_sike::KEM;
#[test]
fn basic_sike_test() {
let params = rust_sike::sike_p751_params(None, None).unwrap();
let kem = KEM::setup(params);
// Alice runs keygen, publishes pk3. Values s and sk3 are secret
l... | true |
2aa9c0112e70794bbdfcb8e8bfdfd1b68ae92001 | Rust | honestold3/myrust | /borrow_proj/src/main.rs | UTF-8 | 677 | 4.0625 | 4 | [] | no_license | fn main() {
//kankan()
//kankan1()
kankan2()
}
fn kankan(){
let s1 = String::from("hello");
let len = calculate_length(&s1);
println!("The length of '{} is {}'",s1,len);
}
fn calculate_length(s: &String) -> usize {
s.len()
}
//-------------------------------------
fn kankan1(){
let s... | true |
ede5e235a9eda48d3528a61c9717d227200dbfb7 | Rust | vdinovi/json_parser | /src/main.rs | UTF-8 | 866 | 3.03125 | 3 | [] | no_license | mod token;
mod parser;
use std::env;
use std::path::PathBuf;
use std::io::BufReader;
use std::fs::File;
use token::tokenize;
use token::token::Token;
use parser::types::Value;
use parser::parse;
fn main() -> Result<(), Box<std::error::Error>> {
const USAGE: &str = "usage: json_parser path/to/json/file";
let a... | true |
7a1fb8a47c3403aed1660931f82a71559308e5b1 | Rust | FumiyukiKato/succinct-trie | /src/louds_dense.rs | UTF-8 | 4,713 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use crate::builder::Builder;
use crate::cache::Cache;
use crate::config::*;
use crate::rank::BitvectorRank;
const K_NODE_FANOUT: position_t = 256;
const K_RANK_BASIC_BLOCK_SIZE: position_t = 512;
pub struct LoudsDense {
height: level_t,
label_bitmaps: BitvectorRank,
child_indicator_bitmaps: BitvectorRank,... | true |
d23742d2fd285a7be7e271cddf37ae94d3cf893d | Rust | teervo/soi | /src/traits/mutex_unwrap.rs | UTF-8 | 368 | 2.796875 | 3 | [
"CC0-1.0"
] | permissive | use std::sync::Mutex;
use std::sync::MutexGuard;
/// This trait provides a `lockk()` method for Mutex to be used
/// as a shorthand for the boilerplate `lock().unwrap()`.
pub trait UnwrappedMutex<T> {
fn lockk(&self) -> MutexGuard<'_, T>;
}
impl<T> UnwrappedMutex<T> for Mutex<T> {
fn lockk(&self) -> MutexGuar... | true |
c0a907e00b2ccaa0e0662cc2d81ea69849680675 | Rust | cjschneider2/novluno | /core_compat/src/entity/rmd_image.rs | UTF-8 | 926 | 2.875 | 3 | [
"Unlicense"
] | permissive | use geometry::rectangle::Rectangle;
use geometry::size::Size;
use geometry::point::Point;
#[derive(Debug)]
pub struct RmdImage {
pub source_x1: i32,
pub source_y1: i32,
pub source_x2: i32,
pub source_y2: i32,
pub empty_1: i32,
pub empty_2: i32,
pub render_z: i32,
pub dest_x... | true |
6b17ca2d646be7756d2624a9589c4e301850a339 | Rust | pierrechevalier83/unicode_types | /src/generated/specials.rs | UTF-8 | 2,430 | 3.671875 | 4 | [
"LicenseRef-scancode-unicode"
] | permissive |
/// An enum to represent all characters in the Specials block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Specials {
/// \u{fff9}: ''
InterlinearAnnotationAnchor,
/// \u{fffa}: ''
InterlinearAnnotationSeparator,
/// \u{fffb}: ''
InterlinearAnnotationTerminator,
/// \u{ff... | true |
45cc72eaeb0316cc7c0e580ec2d37e855c0c8f4d | Rust | jonathanstrong/rust-autograd | /src/ndarray_ext.rs | UTF-8 | 10,597 | 2.75 | 3 | [
"MIT"
] | permissive | /// small extension of rust-ndarray for convenience
extern crate ndarray;
/// type alias for convenience
pub type NdArray = ndarray::Array<f32, ndarray::IxDyn>;
/// type alias for convenience
pub type NdArrayView<'a> = ndarray::ArrayView<'a, f32, ndarray::IxDyn>;
/// exposes array_gen
pub use array_gen::*;
#[inline... | true |
b729db93e51656fb0f01f8f7f8e44a716fe41375 | Rust | zeta0134/rusticnes-core | /src/apu/length_counter.rs | UTF-8 | 929 | 3.34375 | 3 | [
"MIT"
] | permissive | pub struct LengthCounterState {
pub length: u8,
pub halt_flag: bool,
pub channel_enabled: bool,
}
impl LengthCounterState{
pub fn new() -> LengthCounterState {
return LengthCounterState {
length: 0,
halt_flag: false,
channel_enabled: false,
}
}
... | true |
1800d966b71ba80bc40ef0783cf1e061ff408ad4 | Rust | iCodeIN/rocket-lamb | /tests/path_tests.rs | UTF-8 | 2,794 | 2.671875 | 3 | [
"MIT"
] | permissive | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
use lambda_http::{Body, Handler, Request};
use lambda_runtime::Context;
use rocket::http::uri::Origin;
use rocket_lamb::{BasePathBehaviour, RocketExt};
use std::error::Error;
use std::fs::File;
#[catch(404)]
fn not_found(req: &rocket::Requ... | true |
5a788ae36bcfa3e81b619d9147e5fe88c79adc0c | Rust | kmeisthax/retrogram | /src/arch/traits.rs | UTF-8 | 10,548 | 3.03125 | 3 | [] | no_license | //! Architecture trait
use crate::analysis::{Disasm, Mappable, RequisiteSet, Result, Trace};
use crate::arch::ArchName;
use crate::ast::Literal;
use crate::cli::Nameable;
use crate::maths::{Numerical, Popcount};
use crate::memory::{Memory, Offset, Pointer, PtrNum};
use crate::reg::{Bitwise, State};
use num::Bounded;
u... | true |
101d242c84d5cfc296df432949065e0f37fca7da | Rust | rsaihe/gemini-bot | /src/commands/fun.rs | UTF-8 | 2,926 | 3.25 | 3 | [
"MIT"
] | permissive | use rand::seq::SliceRandom;
use serenity::framework::standard::macros::{command, group};
use serenity::framework::standard::{Args, CommandResult};
use serenity::model::prelude::*;
use serenity::prelude::*;
use unicode_segmentation::UnicodeSegmentation;
static EIGHT_BALL_RESPONSES: [&str; 20] = [
"It is certain.",
... | true |
167a128e925d4405fadcee30b932c66ba3c08e27 | Rust | oberien/dilobo | /src/bot/handle/channel.rs | UTF-8 | 4,000 | 2.671875 | 3 | [] | no_license | use std::collections::HashMap;
use bot::Bot;
use modelext::{MergeIntoMap, Diff, ChannelUpdateDiff};
use discord::model::{
Channel,
};
use errors::*;
impl Bot {
pub fn handle_channel_create(&mut self, channel: Channel) -> Result<()> {
if let Channel::Public(channel) = channel {
self.chann... | true |
ae417cfc4c519c15eed491a3b367c34ecdcdf3aa | Rust | Phoenix-Chen/wifi-rs | /src/platforms/mod.rs | UTF-8 | 1,358 | 3.0625 | 3 | [] | no_license | #[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod osx;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "linux")]
pub use self::linux::{Connection, Linux as WiFi};
#[cfg(target_os = "macos")]
pub use self::osx::{Connection, Osx as WiFi};
#[cfg(target_os = "windows")]
pub use self::wind... | true |
7fdd945067591e1d94a6186e4206ac3f28d3f1a2 | Rust | precambrien/alis-bot-rs | /src/main.rs | UTF-8 | 10,531 | 2.765625 | 3 | [
"Beerware"
] | permissive | use alis_bot_rs::*;
use clap::{App, Arg, ArgMatches};
use failure::Error;
use futures::prelude::*;
use glob::glob;
use irc::client::prelude::*;
use log::{debug, error, info};
use std::path::PathBuf;
use std::sync::mpsc::channel;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use tokio::runtime::Runtime;
#[macro... | true |
7ec5898b6cc4e04b99436feb2eeecdf68a81291f | Rust | pisolved/perpetual | /src/db/recipient_dao.rs | UTF-8 | 1,275 | 2.6875 | 3 | [
"MIT"
] | permissive | use mongodb::{
bson::{doc, oid::ObjectId},
Client,
};
use serde::{Deserialize, Serialize};
use gregorian::Date;
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Recipient {
pub gifting_user: ObjectId,
#[serde(flatten)]
pub data: RecipientProto,
}
#[der... | true |
1cdeedf8277ba9bd9d6968ecf07a48ad6805e4a4 | Rust | tokio-rs/tokio | /tokio/src/io/util/fill_buf.rs | UTF-8 | 2,004 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::io::AsyncBufRead;
use pin_project_lite::pin_project;
use std::future::Future;
use std::io;
use std::marker::PhantomPinned;
use std::pin::Pin;
use std::task::{Context, Poll};
pin_project! {
/// Future for the [`fill_buf`](crate::io::AsyncBufReadExt::fill_buf) method.
#[derive(Debug)]
#[must_use ... | true |
49f9d1622a67da983db19626b1ce770f9792ae0c | Rust | mattcl/meanderer | /src/algorithms.rs | UTF-8 | 14,896 | 3.03125 | 3 | [] | no_license | use data::cell::MazeCell;
use data::grid::{Grid, MazeGrid};
use data::pos::{MazePosition, Position};
use linked_hash_set::LinkedHashSet;
use rand;
use rand::{Rng, ThreadRng};
use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
pub fn binary(grid: &mut Grid) {
let mut rng = rand::thread_rng();
... | true |
25aab0319d04dadd98588b121bc9a962a20d408a | Rust | cheako/smithay | /src/wayland/shell/legacy/mod.rs | UTF-8 | 10,558 | 2.984375 | 3 | [
"MIT"
] | permissive | //! Utilities for handling shell surfaces with the `wl_shell` protocol
//!
//! This module provides automatic handling of shell surfaces objects, by being registered
//! as a global handler for `wl_shell`. This protocol is deprecated in favor of `xdg_shell`,
//! thus this module is provided as a compatibility layer wit... | true |
5eb683d59fa96d9680ef36964e0dbb51691f0cd6 | Rust | nimiq/core-rs-albatross | /utils/src/file_store.rs | UTF-8 | 1,512 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use std::{
fs,
fs::OpenOptions,
io::{BufWriter, Error as IoError, Write},
path::{Path, PathBuf},
};
use nimiq_serde::{Deserialize, DeserializeError, Serialize};
use thiserror::Error;
pub struct FileStore {
path: PathBuf,
}
impl FileStore {
pub fn new<P: AsRef<Path>>(path: P) -> Self {
... | true |
523e5bccef8338cf5a74068fd1f7ae3fc80093eb | Rust | 2-complex/ruler | /src/rule.rs | UTF-8 | 70,530 | 3.359375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt;
use crate::ticket::Ticket;
pub struct Rule
{
pub targets : Vec<String>,
pub sources : Vec<String>,
pub command : Vec<String>,
}
/* When a rule is first parsed, it goes into this struct, the targets,
sources and command are s... | true |
a18c6248132e6b75ebe09b1623bd9aeb6ea39e2c | Rust | UvRoxx/rust-optimizer | /build_workspace/src/main.rs | UTF-8 | 1,609 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use glob::glob;
use serde::Deserialize;
use std::{
fs::{self, canonicalize},
process::Command,
};
const CARGO_PATH: &str = "cargo";
const PACKAGE_PREFIX: &str = "contracts/";
#[derive(Deserialize, Debug)]
pub struct CargoToml {
workspace: Workspace,
}
#[derive(Deserialize, Debug)]
pub struct Workspace {
... | true |
475e1d512acbaf454603b423f1a5819c2638ffe3 | Rust | naftulikay/nfty | /src/cli/project/conform.rs | UTF-8 | 1,454 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | mod ansible;
use crate::project::templates::license;
use git2::Repository;
use log::error;
use std::path::PathBuf;
use std::process::exit;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct Conform {
/// Project should be assumed to be private rather than the default, which is public.
#[stru... | true |
62e5a89e65b0c270c3cb0ea521c4d3bba5998d6c | Rust | yin939/Exercism | /rust/triangle/src/lib.rs | UTF-8 | 903 | 3.671875 | 4 | [] | no_license | use std::ops::Add;
pub struct Triangle<T> {
a: T,
b: T,
c: T,
}
impl<T> Triangle<T>
where
T: Default + PartialOrd + Add<Output = T> + Copy,
{
pub fn build(sides: [T; 3]) -> Option<Triangle<T>> {
let a = &sides[0];
let b = &sides[1];
let c = &sides[2];
if *a + *b <= ... | true |
c9316e373570ae315341159d92016520ca1e361c | Rust | enowars/enowars5-service-activitytracker | /service/src/activitytracker/src/views/friends.rs | UTF-8 | 1,233 | 2.9375 | 3 | [
"MIT"
] | permissive | use rocket_dyn_templates::Template;
use rocket::request::FlashMessage;
use rocket::response::{Flash, Redirect};
use rocket::form::Form;
use rocket_auth::User;
use serde_json::json;
use crate::models::users::get_user_id;
use crate::models::friends::create_friend;
#[get("/friends")]
pub async fn new(user: User, flash... | true |
0ed59a0b21ad15af60e9bd645faf0e3ac51d0377 | Rust | nickpapciak/Springwood-CLI | /src/main.rs | UTF-8 | 4,670 | 2.65625 | 3 | [] | no_license | use std::io;
use crossterm::{
event::{self, Event, KeyCode},
terminal::{disable_raw_mode, enable_raw_mode},
};
use tui::{
backend::CrosstermBackend,
layout::{Constraint, Direction, Layout},
Terminal,
};
// TOOD: make `Chunks` more advanced by having it store a list of layouts and having a split ... | true |
dd5a592e1c971021c80d5b6dcedce6820e0527ea | Rust | umatbro/p-tutorials | /rust/rust-book/15_pointers/src/main.rs | UTF-8 | 4,719 | 2.9375 | 3 | [] | no_license | use crate::List::{Cons, Nil};
use crate::RcList::{RcCons, RcNil};
use std::{ops::Deref, char::MAX};
use std::iter::Iterator;
use std::fmt::Debug;
use std::rc::Rc;
mod messenger;
mod cons_rc_refcell;
mod mem_leak;
mod tree;
fn main() {
let b = Box::new(5);
println!("b = {}", b);
let list = Cons(1, Box::new... | true |
6ab346a6c8cd2cc21f71bb04afe7ceed57c7af4a | Rust | acmcarther/cargo-raze-examples | /bazel/complicated_cargo_library/cargo/vendor/tuple_utils-0.2.0/src/lib.rs | UTF-8 | 18,279 | 3.40625 | 3 | [
"Apache-2.0"
] | permissive | //! A simple set of utility traits for working with tuples
/// Helper trait to allow Appending of tuples
pub trait Append<T> {
type Output;
/// Append T onto the end of the tuple returning
/// a new tuple with the existing elements and T
fn append(self, T) -> Self::Output;
}
/// Helper trait to allow ... | true |
b0ed0c86d71917e057f73afec589756ef98ab6d5 | Rust | kpsuperplane/boba | /src/main.rs | UTF-8 | 2,386 | 3 | 3 | [] | no_license | extern crate pancurses;
use pancurses::{initscr, endwin, Input, noecho, Window};
use std::collections::{VecDeque};
fn render(window: &Window, lines: &VecDeque<String>) {
window.clear(); // lol please change this later
let len = lines.len();
for line in 0 .. len {
window.mvprintw(line as i32, 0, &lines[line]... | true |
311b245ab578d3d5384a8e8adbb3f746e2f6eb47 | Rust | IsaacWoods/teensy_kbd | /src/sim.rs | UTF-8 | 1,822 | 2.578125 | 3 | [
"MIT"
] | permissive | use bit_field::BitField;
use volatile::Volatile;
pub enum ClockGate {
PortB,
PortC,
Uart0,
}
#[repr(C, packed)]
pub struct Sim {
sopt1: Volatile<u32>,
sopt1_cfg: Volatile<u32>,
_pad0: [u8; 4092],
sopt2: Volatile<u32>,
_pad1: [u8; 4],
sopt4: Volatile<u32>,
sopt5: Volatile<u32>,
... | true |
5916a0ed5061152fdaa04df586212f059abf740e | Rust | DoumanAsh/sec-store | /src/lib.rs | UTF-8 | 7,523 | 3.1875 | 3 | [
"BSL-1.0"
] | permissive | //!Minimalistic encrypted storage for arbitrary values.
#![warn(missing_docs)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::style))]
use std::collections::BTreeMap;
use xxhash_rust::xxh3::xxh3_128;
use core::ptr;
mod enc;
///Secure storage API
///
///Values are stored in memory encrypted, user can save stor... | true |
1fb7a2f0f19d1be42eb5c399478aa8d8aab406a9 | Rust | kevinwilde/spelling_correctors | /bktree/src/main.rs | UTF-8 | 3,073 | 3.46875 | 3 | [] | no_license | #[doc="
Input:
* Constructs a BK Tree using the words in the given training file. Words in the
training file are handled based on the rules specified in the input module.
* The program then reads words from stdin. If the word was in the training
file, it is assumed to be spelled correctly. If the word was not in th... | true |
2bd190827fcb56624d2f80287ac691473162e0a7 | Rust | U007D/rsos | /src/vga/color/mod.rs | UTF-8 | 1,258 | 3.078125 | 3 | [] | no_license | #[cfg(test)]
mod unit_tests;
use core::convert::TryFrom;
use super::Error;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Color {
Black = 0x0,
Blue,
Green,
Cyan,
Red,
Magenta,
Brown,
LightGray,
DarkGray,
LightBlue,
LightGreen,
LightCyan,
LightRed,... | true |
2de7f22d67dd896e70354ebb83e581f19773f0cb | Rust | Jonathan-Ngondi/service-testing-rust | /src/main.rs | UTF-8 | 2,599 | 2.625 | 3 | [] | no_license | use std::ptr::null_mut;
use bindings::{
Windows::Win32::System::Diagnostics::Debug::{
GetLastError,
},
Windows::Win32::Security::SC_HANDLE,
Windows::Win32::System::Services::{
QueryServiceStatusEx,
OpenServiceA,
OpenSCManagerA,
CloseServiceHandle,
StartServiceA,
SERVICE_S... | true |
ba7cc9a928dee8a1ac89b20be68146ec2411193f | Rust | mozilla/gecko-dev | /third_party/rust/wasm-encoder/src/core/tables.rs | UTF-8 | 2,535 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::{encode_section, ConstExpr, Encode, RefType, Section, SectionId};
/// An encoder for the table section.
///
/// Table sections are only supported for modules.
///
/// # Example
///
/// ```
/// use wasm_encoder::{Module, TableSection, TableType, RefType};
///
/// let mut tables = TableSection::new();
/// tab... | true |
3121f9f84853a4378c403462bd27441f9a07aea6 | Rust | zaksky7/Rust-project | /src/year2018/day05.rs | UTF-8 | 562 | 3.203125 | 3 | [] | no_license | fn react(s: &str) -> usize {
let mut chs: Vec<char> = Vec::new();
for c in s.chars() {
if !chs.is_empty()
&& chs[chs.len() - 1] != c
&& chs[chs.len() - 1].to_ascii_lowercase() == c.to_ascii_lowercase()
{
chs.pop();
} else {
chs.push(c);
... | true |
fd4eecbaed30809538860d2c5814c4ec8debfd60 | Rust | gremenne/AdventOfCode2020 | /day2/src/main.rs | UTF-8 | 1,736 | 3.078125 | 3 | [] | no_license | #[macro_use] extern crate lazy_static;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use regex::Regex;
struct Rule {
letter: char,
password: String,
min: usize,
max: usize,
}
fn extract_rule(line: &String) -> Rule {
lazy_static! {
static ref RE: Regex = Regex::new(r... | true |
203f14f978e48a5b378f9fce4c2bf8caadfc250e | Rust | sugyan/adventofcode | /2022/rust/src/bin/day25.rs | UTF-8 | 2,118 | 3.34375 | 3 | [] | no_license | use std::io::{BufRead, BufReader};
use aoc2022::Solve;
struct Solution {
numbers: Vec<String>,
}
impl Solve for Solution {
type Answer1 = String;
type Answer2 = String;
fn new(r: impl std::io::Read) -> Self {
Self {
numbers: BufReader::new(r).lines().filter_map(Result::ok).collec... | true |
d6c8548106ab3fab772552a9a5c4ef9cd61d0b1e | Rust | rust-lang/rust | /tests/ui/closures/supertrait-hint-cycle.rs | UTF-8 | 1,322 | 2.609375 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // edition:2021
// check-pass
#![feature(type_alias_impl_trait)]
#![feature(closure_lifetime_binder)]
use std::future::Future;
trait AsyncFn<I, R>: FnMut(I) -> Self::Fut {
type Fut: Future<Output = R>;
}
impl<F, I, R, Fut> AsyncFn<I, R> for F
where
Fut: Future<Output = R>,
F: FnMut(I) -> Fut,
{
type... | true |
38ae42adb266b786c520bbe231770359fa32d5e9 | Rust | mariot/mozika_scraper_rust | /src/lib.rs | UTF-8 | 4,601 | 2.859375 | 3 | [
"MIT"
] | permissive | extern crate reqwest;
extern crate select;
use select::document::Document;
use select::predicate::{Attr, Class, Name, Predicate, Text};
pub struct Artist {
pub id: i32,
pub name: String,
pub url: String,
pub songs_id: i32,
pub number_of_songs: i32,
}
pub struct Song {
pub id: i32,
pub tit... | true |
7e508d889490e424871eba24484a6179767f8ee0 | Rust | nickclare/jacaranda | /src/tree.rs | UTF-8 | 5,512 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::BTreeMap;
use std::collections::VecDeque;
#[derive(Ord, Eq, PartialEq, PartialOrd, Copy, Clone, Debug)]
pub struct NodeIndex(usize);
#[derive(Debug)]
pub struct Tree<T> {
nodes: BTreeMap<NodeIndex, Node<T>>,
root: NodeIndex,
next_idx: NodeIndex,
}
pub enum SearchResult<R> {
Cont... | true |
be0fdd6736c8b8b32e8c3951183b7cfeaa94ec35 | Rust | reinterpretcat/vrp | /vrp-core/src/construction/features/locked_jobs.rs | UTF-8 | 5,712 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | //! A feature to lock specific jobs to specific vehicles.
#[cfg(test)]
#[path = "../../../tests/unit/construction/features/locked_jobs_test.rs"]
mod locked_jobs_test;
use super::*;
use crate::models::problem::{Actor, Fleet};
use crate::models::{Lock, LockOrder, LockPosition};
use hashbrown::{HashMap, HashSet};
use st... | true |
56cb5d7bcd90bab225866fdd6fe536019e6abbf5 | Rust | servo/rust-layers | /src/texturegl.rs | UTF-8 | 6,199 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ... | true |
3fbc86a6b8342facffba4ebe2d1c7525fddf40e6 | Rust | rufus-stone/remote-couch-co-op | /libs/consoles/src/controller/controlpad.rs | UTF-8 | 1,287 | 3.25 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::controller::platform::*;
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct ControlPad {
pub platform: Platform,
pub buttons: Vec<u8>,
}
impl ControlPad {
pub fn buttons(&self) -> &[u8] {
&self.buttons
}
}
#[derive(Clone)]
pub struc... | true |
6ec1502dff8126072a4c0d955c1a0a9a62f92be4 | Rust | incker2/luno-rust | /src/orders.rs | UTF-8 | 5,695 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::future::Future;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
use crate::client;
use crate::TradingPair;
/// Represents the type of the limit order.
#[derive(EnumString, Display)]
pub enum LimitOrderType {
ASK,
BID,
}
/// Represents the... | true |
c3277e0f24ac56cd984adecc2d95b700992d1a2c | Rust | CarlColglazier/telegram-rust | /src/bot/types/post/mod.rs | UTF-8 | 1,775 | 2.71875 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | mod chataction;
mod getme;
pub use self::chataction::{Action, ChatAction};
pub use self::getme::GetMe;
pub trait FormUrlEncode {
fn to_urlencoded_str(&self) -> String;
}
pub struct SendMessage {
chat_id: usize,
text: String,
// TODO: disable_web_page_preview
// TODO: reply_to_message_id
// TO... | true |
d2de17fce140d007ee3658ab653f7ae0f7a41fca | Rust | abdulbasit01/sum-crate | /main.rs | UTF-8 | 1,153 | 3.53125 | 4 | [] | no_license | fn main(){
println!("Check" );
sum()
}
use std::io;
fn sum (){
println!("How many numbers you want to add");
let mut a = String::new();
io::stdin().read_line(&mut a);
let number : i32 =a.trim().parse().unwrap();
let mut i =0;
while i !=number{
let mut a = String::new();
... | true |
4872d296c705866c75d78049e5e7f0ca0cae40b9 | Rust | alexozer/learn-rust | /hello_world/main.rs | UTF-8 | 100 | 2.96875 | 3 | [] | no_license | fn main() {
let (x, y, z) = ("hi there", false, 0.42);
println!("({}, {}, {})", x, y, z);
}
| true |
19443770cc207e4b57c8cab7d1b92d8a76089c68 | Rust | weslien/cartel | /src/client/process.rs | UTF-8 | 2,558 | 2.578125 | 3 | [] | no_license | use crate::client::module::{
CheckDefinition, ServiceOrTaskDefinition, ShellDefinition,
SuggestedFixDefinition,
};
use crate::command_builder::CommandBuilder;
use crate::path;
use anyhow::{bail, Context, Result};
use std::process::ExitStatus;
pub fn run_task(task_definition: &ServiceOrTaskDefinition) -> Result... | true |
e9e6a452a274c1732a98540de620d5ddb03e3d70 | Rust | neuroradiology/amethyst | /amethyst_ui/src/format.rs | UTF-8 | 1,740 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use glyph_brush::rusttype::Font;
use serde::{Deserialize, Serialize};
use amethyst_assets::{Asset, Format, Handle, ProcessableAsset, ProcessingState};
use amethyst_core::ecs::prelude::VecStorage;
use amethyst_error::{format_err, Error, ResultExt};
/// A loaded set of fonts from a file.
#[derive(Clone)]
#[allow(missin... | true |
43e6cfd4f238ea189a81664634b071cca105ba40 | Rust | wao/android_system_bt | /gd/rust/topshim/tests/bdaddr.rs | UTF-8 | 1,407 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
mod tests {
use bt_topshim::btif::RawAddress;
#[test]
fn from_string_invalid() {
assert!(RawAddress::from_string("").is_none());
assert!(RawAddress::from_string("some invalid string").is_none());
assert!(RawAddress::from_string("aa:bb:cc:dd:ee:ff:00").is_none());
... | true |
dd5d8e0d08c3f0a64006a9286a35153e72da0367 | Rust | IGBC/CUE | /bifrost/src/window/mod.rs | UTF-8 | 1,519 | 2.609375 | 3 | [] | no_license | pub mod socketbackend;
use std::collections::HashMap;
use status;
use cursive::{backend, theme, view, views};
use cursive::backend::Backend;
use cursive::event::{Callback, Event};
pub struct Window {
theme: theme::Theme,
root_widget: Box<view::View>,
application_callbacks: HashMap<Event, Vec<Callback>>,... | true |
0cf3ce8449d4f4a983ed096af355ea2d3aa16450 | Rust | youyangy/GraphScope | /research/gaia/pegasus/pegasus/src/api/concise/reduce/accum.rs | UTF-8 | 11,120 | 2.578125 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-elastic-license-2018",
"LicenseRef-scancode-other-permissive"
] | permissive | //
//! Copyright 2020 Alibaba Group Holding Limited.
//!
//! 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/licenses/LICENSE-2.0
//!
//! Unless required by a... | true |
1a3562ab59fd148f25c5524bc3324898084be12a | Rust | fdumontmd/adventofcode | /2019/day-17/src/main.rs | UTF-8 | 10,951 | 3.171875 | 3 | [] | no_license | use std::{fmt::Display, ops::Index, str::FromStr};
use anyhow::{bail, Error};
use intcode::Computer;
static INPUT: &str = include_str!("input.txt");
struct View {
view: Vec<u8>,
width: usize,
height: usize,
}
impl FromStr for View {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Er... | true |
1ed005421716f4f8b3d1acdb9482a376e9cc3296 | Rust | frapa/roast | /src/operation/mod.rs | UTF-8 | 2,568 | 2.6875 | 3 | [
"MIT"
] | permissive | use super::*;
use std::collections::HashMap;
use uuid;
pub trait GetTensor {
fn get_tensor<T>(tensor: Tensor<T>) -> Tensor<T>
where
T: num::Num + Copy + 'static,
Self: Sized,
{
tensor
}
}
impl<T> GetTensor for Tensor<T>
where
T: num::Num + Copy + 'stat... | true |
958c60bf487760e08a0bce4b440df3930d547dbc | Rust | chipbuster/protein-stability | /compressor/rustcompressor/src/bin/encode_file_to_lzproto.rs | UTF-8 | 2,580 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::env;
use std::process;
use std::io::Write;
//use compressor::deflate::DeflateStream;
use compressor::deflate::{
lz77::encoder::{LZMaximums, LZRules},
*,
};
use prost::Message;
// Parse the maximum limits on a string
fn parse_maxopt(params: &[String]) -> LZMaximums {
match params.len() {
1 => matc... | true |
c011601c766f4218da64f65f56245ca89a6126b3 | Rust | rust-lang/rust | /tests/ui/parser/issue-68987-unmatch-issue-3.rs | UTF-8 | 263 | 2.96875 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // the `{` is closed with `)`, there is a missing `(`
fn f(i: u32, j: u32) {
let res = String::new();
let mut cnt = i;
while cnt < j {
write!&mut res, " "); //~ ERROR mismatched closing delimiter
}
} //~ ERROR unexpected closing delimiter
| true |
d19cb1c93a3e58e409c475d99b88394e8a37c3fa | Rust | nielsandriesse/session-open-group-server | /src/onion_requests.rs | UTF-8 | 5,498 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use log::warn;
use serde::{Deserialize, Serialize};
use warp::{http::StatusCode, reply::Reply, reply::Response, Rejection};
use super::crypto;
use super::errors::Error;
use super::models;
use super::rpc;
#[derive(Deserialize, Serialize, Debug)]
struct OnionRequestPayload {
pub cipherte... | true |
e5eda1e071e6b916c6b8a17786ead12b8bbbdf3f | Rust | Vanderkast/leetcode_rust | /guessing_game_player/src/main.rs | UTF-8 | 1,933 | 3.625 | 4 | [] | no_license | /**
* Forward declaration of guess API
* @param num your gues
* @return -1 if num is lower than the guess numbe
* 1 if num is higher than the guess numbe
* otherwise return
* unsafe fn guess(num: i32) -> i32 {
*/
struct Solution {}
impl Solution {
unsafe fn guessNumber(mut ... | true |
0f5f9d60911a14f7f373623d01185a5aac51c9bd | Rust | mipli/exercism | /word-count/src/lib.rs | UTF-8 | 428 | 3.3125 | 3 | [] | no_license | use std::collections::HashMap;
/// Count occurrences of words.
pub fn word_count(words: &str) -> HashMap<String, u32> {
words.chars()
.filter(|c| c.is_alphanumeric() || c.is_whitespace())
.collect::<String>()
.to_lowercase()
.split_whitespace()
.fold(HashMap::new(), |mut cou... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.