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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
df374bac81098ea1ba4c7f25dbc3432e0e70c67c | Rust | burzek/katas | /AdventOfCode2021/src/day3.rs | UTF-8 | 1,797 | 3.15625 | 3 | [] | no_license | use std::collections::HashSet;
pub fn day3_task1(mut input: String) {
input.retain(|c| c != '\n');
const PACKET_LEN: usize = 12;
let packets = input.len() / PACKET_LEN;
let mut gamma = String::new();
for i in 0..PACKET_LEN {
let mut zero_count = 0;
for j in 0..packets {
... | true |
58959d18efda71793737875d1074e75c6ecd071a | Rust | Tetrergeru/opengl-rust-0 | /src/drawing/shaders.rs | UTF-8 | 1,659 | 2.796875 | 3 | [] | no_license | use gl::types::{GLenum, GLuint};
use gl::Gl;
use std::ffi::CStr;
use super::create_whitespace_cstring;
pub struct Shader {
gl: Gl,
id: GLuint,
}
impl Shader {
pub(super) fn id(&self) -> GLuint {
self.id
}
pub fn from_source(gl: Gl, source: &CStr, kind: GLenum) -> Result<Shader, String> {... | true |
d0b43dd6c7682a36ac529acb46e1c1d0509afe78 | Rust | ferrous-systems/imxrt1052 | /src/ccm_analog/misc2_clr/mod.rs | UTF-8 | 44,590 | 2.78125 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::MISC2_CLR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... | true |
91b37e6accee5c17ed3daf4316b5c52d46a0de4e | Rust | nhatvu148/rustlang | /src/print.rs | UTF-8 | 638 | 3.703125 | 4 | [] | no_license | pub fn run() {
// Print to console
println!("Hello! from the print.rs file");
// Basic formatting
println!("Number {} is number of {}", 1, "Vu");
// Positional arguments
println!("{0} is from {1} and {0} is {2}!", "Vu", "Vietnam", "cool");
// Named arguments
println!(
"{name} ... | true |
71b0ef00686353ff8619143e6f90d16d7f90bb0c | Rust | jallen02/deuterium | /src/predicate/and.rs | UTF-8 | 516 | 2.640625 | 3 | [
"MIT"
] | permissive | use super::ToSharedPredicate;
#[derive(Clone, Debug)]
pub struct AndPredicate {
pub left: super::SharedPredicate,
pub right: super::SharedPredicate
}
pub trait ToAndPredicate {
fn and(&self, val: super::SharedPredicate) -> super::SharedPredicate;
}
impl ToAndPredicate for super::SharedPredicate {
fn ... | true |
bb73c75dee766758b09dcfe33ba6d49c233161b2 | Rust | hidva/waitforgraph | /src/bin/subgraph/main.rs | UTF-8 | 1,778 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::anyhow;
use std::collections::{HashMap, HashSet};
use std::io::{self, BufRead};
use waitforgraph::graph::dot;
use waitforgraph::lock::SessionId;
fn add_graph(graph: &mut HashMap<SessionId, Vec<SessionId>>, line: &str) -> anyhow::Result<()> {
let mut spliter = line.split("->");
let left = spliter.ne... | true |
ab32cbc128e8cf14b9a252ae9b116f6a496c76ad | Rust | kebab-mai-haddi/substrate-api-client | /src/examples/example_contract.rs | UTF-8 | 7,372 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | /*
Copyright 2019 Supercomputing Systems AG
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law ... | true |
0641bda0ff7a60a0e8c9be185864570afe61afa5 | Rust | serbe/rsp | /src/sites/freeproxylistcom.rs | UTF-8 | 1,154 | 2.546875 | 3 | [
"MIT"
] | permissive | use super::netutils::crawl;
use crate::error::RspError;
use regex::Regex;
pub async fn get() -> Result<Vec<String>, RspError> {
let urls = vec![
"https://free-proxy-list.com/?page=1",
"https://free-proxy-list.com/?page=2",
"https://free-proxy-list.com/?page=3",
"https://free-proxy-l... | true |
101c6bda42621589194ce89a80fa3f2df1e70af3 | Rust | sile/dotgraph | /src/graph.rs | UTF-8 | 3,490 | 3.421875 | 3 | [] | no_license | use std::io::{self, Write};
use node;
#[derive(Debug)]
pub struct Graph {
name: String,
properties: GraphProperties,
nodes: Vec<Node>,
edges: Vec<Edge>,
}
impl Graph {
pub fn new<T: Into<String>>(name: T) -> Self {
Graph {
name: name.into(),
properties: GraphPropert... | true |
93b09f6b115caee24e3b4dee41efc70719a89962 | Rust | BogdanFloris/leetcode-rust | /src/fizz_buzz.rs | UTF-8 | 795 | 3.734375 | 4 | [] | no_license | #[allow(dead_code)]
pub fn fizz_buzz(n: i32) -> Vec<String> {
let mut sol: Vec<String> = vec![];
for i in 1..=n {
if i % 3 == 0 && i % 5 == 0 {
sol.push(String::from("FizzBuzz"));
} else if i % 3 == 0 {
sol.push(String::from("Fizz"));
} else if i % 5 == 0 {
... | true |
0bdffbff67c98dcb464bada62981877395db0f80 | Rust | kb10uy/uv-remapper | /src/main.rs | UTF-8 | 2,501 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | mod remapper;
mod scripting;
use crate::remapper::Remapper;
use std::{error::Error, fs::File, io::BufReader};
use clap::Clap;
use log::{error, info};
use rlua::prelude::*;
#[derive(Clap)]
#[clap(name = "UV Remapper", version, author, about)]
struct Arguments {
/// 実行する Lua スクリプトのパス
script: String,
/// 出... | true |
3093a1b1502179417c7fd03d47e87652bbda1f33 | Rust | christian-blades-cb/aoc-2018 | /day9/src/main.rs | UTF-8 | 3,938 | 3.15625 | 3 | [] | no_license | #[macro_use]
extern crate nom;
use nom::digit;
use std::io::prelude::*;
fn main() -> Result<(), std::io::Error> {
use std::fs::File;
let mut file = File::open("input-day9")?;
let mut buf = String::new();
file.read_to_string(&mut buf)?;
let (n_players, last_marble) = parse_input(&buf).unwrap().1;... | true |
6a5dc5ba615206f1abd7a57550314bf61e0bf66c | Rust | royaltm/rust-ym-file-parser | /src/ym.rs | UTF-8 | 12,329 | 2.703125 | 3 | [] | no_license | use core::time::Duration;
use core::num::NonZeroU32;
use core::fmt;
use core::ops::Range;
use chrono::NaiveDateTime;
pub mod flags;
pub mod effects;
mod parse;
mod player;
use flags::*;
use effects::*;
pub const MAX_DD_SAMPLES: usize = 32;
pub const MFP_TIMER_FREQUENCY: u32 = 2_457_600;
const DEFAULT_CHIPSET_FREQUE... | true |
86bbd839be256d61ba32ce65b3c3af12966b6d65 | Rust | brianloveswords/learn-rust | /002: Even Fibonacci numbers/1-first-attempt.rs | UTF-8 | 1,053 | 3.953125 | 4 | [] | no_license | /// For my first attempt, I went at it without really looking up too
/// much. I knew I wanted my `fib` function to be generic, with the
/// logic around figuring out the the sum separate. I also wanted to use
/// a generator, but very quickly figured out that though "yield" is a
/// reserved keyword, it doesn't actual... | true |
23cf4349123df1836865f41bd82e2af3a4aa8272 | Rust | hzkazmi/Batch6_34_Quarter1 | /may_03_2020_imran/variable/src/main.rs | UTF-8 | 1,350 | 3.890625 | 4 | [] | no_license | fn main() {
let age = 33; //declare and initialize a variable
println!("welcome in Live Review Class");
//printing value of a variable
println!("The data in age variable is : {}",age);
println!("Hello, world!");
//declare and initialize a tuple
let data = (137816,"Inayat",1500,80.88);
... | true |
5129466ed5a539f20ddd39f08dfb726c2b3be23b | Rust | rschristian/rust-rocket-template | /src/db/auth_repository.rs | UTF-8 | 988 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::db::Conn;
use crate::models::user::{InsertableUser, User};
use crate::schema::users;
use diesel::prelude::*;
use diesel::result::{DatabaseErrorKind, Error};
pub enum UserCreationError {
DuplicatedEmail,
}
impl From<Error> for UserCreationError {
fn from(err: Error) -> UserCreationError {
i... | true |
d3f3108830e405d0b74ae898b110eec226fc138c | Rust | Rodrigodd/gameroy | /core/src/gameboy.rs | UTF-8 | 16,904 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::cell::{Cell, RefCell};
use crate::{
disassembler::Trace,
save_state::{LoadStateError, SaveState, SaveStateContext, SaveStateHeader},
};
pub mod cartridge;
pub mod cpu;
pub mod ppu;
pub mod serial_transfer;
pub mod sound_controller;
pub mod timer;
use self::{
cartridge::Cartridge, cpu::Cpu, ppu::... | true |
827c929b014d9b77789e911b5e70edeb0e52a04a | Rust | southpawgeek/perlweeklychallenge-club | /challenge-109/laurent-rosenfeld/rust/ch-1.rs | UTF-8 | 259 | 3.09375 | 3 | [] | no_license | fn chowla(n : i32) -> i32 {
let mut sum = 0;
for i in 2..=n/2 {
if n % i == 0 {
sum += i
}
}
return sum
}
fn main() {
for n in 1..20 {
print!("{}, ", chowla(n));
}
println!("{} ", chowla(20));
}
| true |
5754a13a5a68fce1bfc849da09d53211e1b5b40b | Rust | EmbarkStudios/symbolicator | /src/utils/futures.rs | UTF-8 | 3,288 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::future::Future;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use futures::channel::oneshot;
use futures::{FutureExt, TryFutureExt};
use tokio::runtime::Runtime as TokioRuntime;
static IS_TEST: AtomicBool = AtomicBool::new(false);
/// Enables test mode of all thread pools and remote thr... | true |
f7bb7413f18501f2c00b4692abd2796dba73a280 | Rust | awsdocs/aws-doc-sdk-examples | /rust_dev_preview/examples/lambda/src/bin/list-all-function-runtimes.rs | UTF-8 | 3,198 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#![allow(clippy::result_large_err)]
use aws_sdk_lambda::Error;
use clap::Parser;
use lambda_code_examples::{make_client, make_config, Opt as BaseOpt};
#[derive(Debug, Parser)]
struct Opt {
#[struc... | true |
0151395427588566c951494d39499f2651d1b4c9 | Rust | Fergus-Molloy/Advent_of_Code_2020 | /day_5/src/main.rs | UTF-8 | 1,845 | 3.484375 | 3 | [] | no_license | use std::fs;
fn main() {
let contents = fs::read_to_string("input").expect("unable to read file");
let lines: Vec<&str> = contents.lines().collect();
println!("Part One: {}", part_one(&lines));
println!("Part Two: {}", part_two(&lines));
}
pub fn part_one(lines: &Vec<&str>) -> u32 {
let mut big = ... | true |
10f714c3fd4446a0eccdf2ae448d34aaa2875894 | Rust | songlinshu/winsafe | /src/gui/very_unsafe_cell.rs | UTF-8 | 792 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::cell::UnsafeCell;
use std::ops::Deref;
/// Syntactic sugar to `UnsafeCell`.
///
/// **Extremely** unsafe, intended only to provide less verbose internal
/// mutability within the `gui` module.
pub(crate) struct VeryUnsafeCell<T>(UnsafeCell<T>);
unsafe impl<T> Send for VeryUnsafeCell<T> {}
unsafe im... | true |
197ab54006bdbfc061cbcb3d9dd260ff854d7b0e | Rust | wasmup/insert-per-second | /rust-byte1024-Uniform/src/main.rs | UTF-8 | 807 | 3.09375 | 3 | [] | no_license | use rand::distributions::{Distribution, Uniform};
use std::collections::HashMap;
use std::time::Instant;
fn main() {
const N: usize = 1024;
const MAX: usize = N * N;
let mut m = HashMap::with_capacity(MAX);
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".as_bytes();
let between... | true |
3057633f186b19691fa1dc4923084035d9b2b4e7 | Rust | casey/RustRoguelike | /roguelike_core/src/messaging.rs | UTF-8 | 6,990 | 2.90625 | 3 | [] | no_license | use std::collections::VecDeque;
use serde::{Serialize, Deserialize};
use crate::types::*;
use crate::map::*;
use crate::movement::{Movement, MoveType, MoveMode, Action};
use crate::ai::Behavior;
pub struct MsgLog {
pub messages: VecDeque<Msg>,
pub turn_messages: VecDeque<Msg>,
}
impl MsgLog {
pub fn ne... | true |
6c6b3b641a3c0e8959dc027c5e59549accb5f48d | Rust | ganmacs/playground | /rust/tbin/src/gen.rs | UTF-8 | 408 | 3.5 | 4 | [] | no_license | use std::fmt::Debug;
trait HaveArea {
fn area(&self) -> f64;
}
#[derive(Debug)]
struct Foo {
length: f64,
width: f64,
}
impl HaveArea for Foo {
fn area(&self) -> f64 { self.length * self.width }
}
fn print_debug<T: Debug>(f: &T) {
println!("{:?}", f);
}
fn main() {
let f = Foo { length: 10... | true |
9e49d25a920ebb7f1202bf7bc9546741e815a0cd | Rust | tempbottle/rhai | /src/fn_register.rs | UTF-8 | 4,105 | 2.640625 | 3 | [] | no_license | use std::any::TypeId;
use crate::any::{Any, Dynamic};
use crate::engine::{Engine, EvalAltResult, FnCallArgs};
pub trait RegisterFn<FN, ARGS, RET> {
fn register_fn(&mut self, name: &str, f: FN);
}
pub trait RegisterDynamicFn<FN, ARGS> {
fn register_dynamic_fn(&mut self, name: &str, f: FN);
}
pub struct Ref<A>... | true |
f8cd784cdefa8f6959814db86c372e4405a3e7d3 | Rust | thomasantony/bobbin-sdk | /mcu/bobbin-kinetis/mke02z4/src/spi.rs | UTF-8 | 23,701 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | ::bobbin_mcu::periph!( SPI0, Spi0, SPI0_PERIPH, SpiPeriph, SPI0_OWNED, SPI0_REF_COUNT, 0x40076000, 0x00, 0x14);
::bobbin_mcu::periph!( SPI1, Spi1, SPI1_PERIPH, SpiPeriph, SPI1_OWNED, SPI1_REF_COUNT, 0x40077000, 0x01, 0x15);
#[derive(Clone, Copy, PartialEq, Eq)]
#[doc="SPI Peripheral"]
pub struct SpiPeriph(pub usize); ... | true |
e7663bb700a021679e74371dcc2920093d7a8bf0 | Rust | alexbensimon/advent-of-code-2020 | /src/day_01/mod.rs | UTF-8 | 1,014 | 3.078125 | 3 | [] | no_license | use crate::utils::lines_from_file;
use std::time::Instant;
pub fn main() {
let start = Instant::now();
let entries: Vec<i32> = lines_from_file("src/day_01/input.txt")
.iter()
.map(|line| line.parse::<i32>().unwrap())
.collect();
// println!("{:?}", part_1(entries));
println!(... | true |
bcbfb18cbf7fd8cda2b4d38cefc51a0c764538c4 | Rust | placrosse/rust-hdbconnect | /src/types_impl/lob/blob.rs | UTF-8 | 6,296 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::conn_core::AmConnCore;
use crate::protocol::server_resource_consumption_info::ServerResourceConsumptionInfo;
use crate::types_impl::lob::fetch_a_lob_chunk;
use crate::{HdbError, HdbResult};
use serde_derive::Serialize;
use std::cell::RefCell;
use std::cmp;
use std::io::{self, Write};
/// BLob implementation... | true |
9e3718681bdc3a4d4d10298ca5639346bf7b9734 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/tokio/src/runtime/task/join.rs | UTF-8 | 7,766 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use
crate
:
:
runtime
:
:
task
:
:
RawTask
;
use
std
:
:
fmt
;
use
std
:
:
future
:
:
Future
;
use
std
:
:
marker
:
:
PhantomData
;
use
std
:
:
panic
:
:
{
RefUnwindSafe
UnwindSafe
}
;
use
std
:
:
pin
:
:
Pin
;
use
std
:
:
task
:
:
{
Context
Poll
Waker
}
;
cfg_rt
!
{
/
/
/
An
owned
permission
to
join
on
a
task
(
await
... | true |
f474802e8abaf7ca0b069de9a27120f2d2ede9aa | Rust | co42/bevy_tilemap | /src/chunk/render/mod.rs | UTF-8 | 5,374 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::lib::*;
macro_rules! build_chunk_pipeline {
($handle: ident, $id: expr, $name: ident, $file: expr) => {
/// The constant render pipeline for a chunk.
pub(crate) const $handle: HandleUntyped =
HandleUntyped::weak_from_u64(PipelineDescriptor::TYPE_UUID, $id);
/// Build... | true |
ebb4d64ca01f64f591f21dd2e14f464d083b525b | Rust | TechniMan/rldev-does-the-tutorial-2020-rust | /src/map.rs | UTF-8 | 6,425 | 3.03125 | 3 | [] | no_license | use std::cmp::{ max, min };
use specs::prelude::*;
use rltk::{ Rltk, RandomNumberGenerator, Point, Algorithm2D, BaseMap };
use super::{ Rect, COLOURS };
#[derive(PartialEq, Copy, Clone)]
pub enum TileType {
Wall,
Floor
}
pub struct Map {
pub tiles : Vec<TileType>,
pub explored_tiles: Vec<bool>,
pu... | true |
add7dba7976b170b12471223ec2e8a0c09c39335 | Rust | tearne/library | /rust/04_Ferrous/src/bin/testing.rs | UTF-8 | 5,326 | 3.203125 | 3 | [] | no_license | #![allow(unused)]
type Result<T> = std::result::Result<T, ()>;
// Things representing data
#[derive(Debug, PartialEq)]
struct Parameter { }
#[derive(Debug, PartialEq)]
struct Record { property: u32 }
#[derive(Debug, PartialEq, Clone)]
struct ProcessedRecord { }
// Components that work with data
struct Database {}
st... | true |
fe622d6dd3d8b91f4a2a34e74fe425c2e3e50967 | Rust | Geal/rustmu | /net.rs | UTF-8 | 8,506 | 2.953125 | 3 | [] | no_license | use std::comm::{Port, Chan, Select};
use std::io;
use std::io::{Acceptor, Listener, IoResult};
use std::io::net::tcp::{TcpListener, TcpStream};
use std::io::net::ip::{SocketAddr, Ipv4Addr};
use std::str;
use std::task;
use std::vec;
mod telnet;
#[deriving(Eq)]
pub enum ID {
Unassigned,
Unconnected(uint),
... | true |
fe68d73a2e4d7468b956bdccfbc19ca59105d47e | Rust | kernelmethod/libfixers | /src/wasm.rs | UTF-8 | 4,360 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | //! WebAssembly bindings for the `libfixers` crate.
use crate::{
exif::{self, IFDDataContents, IFDDataFormat, IFDTag},
JPEGFile,
};
use base64;
use std::convert::TryFrom;
use wasm_bindgen::prelude::*;
/// Perform some preprocessing on the IFD entries extracted by the Exif parser so that they're
/// easier to ... | true |
aefa4d2aad2c0a181eb68a14a7bc19e78a533ca6 | Rust | SimonOsaka/my_adventures_api | /src/domain/tests/helpers/generate.rs | UTF-8 | 861 | 2.796875 | 3 | [
"MIT"
] | permissive | //! Functions for generating test data
use fake::fake;
pub enum With<T> {
Value(T),
Random,
}
pub fn article_content() -> realworld_domain::ArticleContent {
realworld_domain::ArticleContent {
title: fake!(Lorem.sentence(4, 10)).to_string(),
description: fake!(Lorem.paragraph(3, 10)),
... | true |
65cb6ff54829559728b3df4fe8114c2be9198d1b | Rust | isgasho/ligen | /src/ir/project/arguments.rs | UTF-8 | 1,420 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | //! Arguments definition module.
use crate::prelude::*;
use crate::generator::BuildType;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
/// Arguments passed from `cargo-ligen`.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Arguments {
/// The name of the crate
pub ... | true |
9bc3de9abd4a6fa7bf739a0c9be89c630d5acbed | Rust | kofj/font2png | /src/main.rs | UTF-8 | 2,844 | 2.875 | 3 | [] | no_license | use colors_transform::{Color, Rgb};
use image::{Rgba, RgbaImage};
use imageproc::drawing::draw_text_mut;
use rusttype::{Font, Scale};
use std::path::Path;
use std::vec::Vec;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(
name = "font2img",
version = "v1.0.0",
about = "A tool for convert... | true |
a4655b6edf345b89e9265b08fecc3ee5a2cdee69 | Rust | BurraAbhishek/page_replacement_algorithms_demo.rs | /src/page.rs | UTF-8 | 2,282 | 3.703125 | 4 | [
"MIT"
] | permissive | #[path = "input.rs"]
mod input;
use input as other_input;
pub struct Page {
pub page_string: Vec<String>,
}
impl Default for Page {
fn default() -> Page {
Page {
page_string: Vec::<String>::new(),
}
}
}
impl Page {
fn sequentially(mut self) -> Page {
println!("Ente... | true |
f831cfacefdba95ce8bdc62b421e4b3e79bb6705 | Rust | keeperofdakeys/asn1-rs | /asn1-utils/src/ber-json-decode.rs | UTF-8 | 3,405 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate asn1_cereal;
extern crate argparse;
extern crate serde_json;
use asn1_cereal::{tag, byte};
use asn1_cereal::ber::stream;
use std::io;
use std::io::Read;
use std::fs;
use std::path::Path;
use std::collections::BTreeMap;
use argparse::{ArgumentParser, StoreTrue, StoreOption};
use serde_json::value::Value;
... | true |
40cbc492a177544b4bcb5684db89cdbeeb964008 | Rust | reem/rust-http2parse | /src/lib.rs | UTF-8 | 3,599 | 2.734375 | 3 | [
"MIT"
] | permissive | #![cfg_attr(test, deny(warnings))]
#![cfg_attr(test, feature(test))]
#![allow(non_upper_case_globals)]
// #![deny(missing_docs)]
//! # http2parse
//!
//! An HTTP2 frame parser.
//!
#[macro_use]
extern crate bitflags;
extern crate byteorder;
#[cfg(test)]
extern crate test;
#[cfg(any(test, feature = "random"))]
extern... | true |
d978ce655172123479dc43664f65534929e66a62 | Rust | purposed/binman | /src/binlib/state.rs | UTF-8 | 3,301 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::fs;
use std::io::{BufWriter, Write};
use std::ops::Add;
use std::path::Path;
use anyhow::{ensure, Result};
use semver::Version;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StateEntry {
pub name: String,
pub... | true |
fe63bc6733d8299730b65a210e330d1086c742ce | Rust | johnyenter-briars/gentle_intro_to_rust | /structs_enums_matching/enums1.rs | UTF-8 | 911 | 3.640625 | 4 | [] | no_license | #[derive(Debug,PartialEq)]
enum Direction {
Up,
Down,
Left,
Right
}
impl Direction {
fn as_str(&self) -> &'static str {
//normally we dont need the dereference pointer
//normally rust can asume self.first_name without (*self).first_name
match *self { //*self has type Direction
Direction::Up => "Up",
D... | true |
3a0ec20970670fb516dda983bd4f852eff7c79a4 | Rust | vext01/yk_pv | /ykutil/src/addr.rs | UTF-8 | 7,978 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Address utilities.
use crate::obj::{PHDR_OBJECT_CACHE, SELF_BIN_PATH};
use cached::proc_macro::cached;
use libc::{self, c_void, Dl_info};
use std::mem::MaybeUninit;
use std::{
convert::{From, TryFrom},
ffi::CStr,
path::{Path, PathBuf},
};
/// A Rust wrapper around `libc::Dl_info` using FFI types.
///
... | true |
6fd065c3fbc959082d47583bc52e924302841f0c | Rust | taravancil/passkeeper | /src/io.rs | UTF-8 | 4,499 | 2.984375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | // std
use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::{ Error, ErrorKind, stdin };
use std::io::prelude::*;
use std::path::{ PathBuf };
// passkeeper
use vault;
// external
extern crate serde;
extern crate serde_json;
/// Creates $HOME/.passkeeper/
pub fn create_passkeeper_dir() -> Result<(),... | true |
7ce7d3b7bac18b519631d30d8fb0ddf9699d5423 | Rust | esovm/wast | /fuzz/fuzz_targets/wasm-opt-ttf.rs | UTF-8 | 2,762 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Same as `binary.rs` fuzzing, but use `wasm-opt` with the input data to
//! generate a wasm program using `-ttf` instead of interpreting `data` as a
//! wasm program.
//!
//! Additionally assert that parsing succeeds since we should be able to parse
//! everything `wasm-opt` generates.
#![no_main]
use libfuzzer_sy... | true |
7a21438c7a0cafd30c85d88aa7132bc0de594017 | Rust | chorddown/chordr | /chordr-runner/src/configuration/reader.rs | UTF-8 | 7,801 | 2.953125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::configuration::Configuration;
use crate::error::*;
use std::error::Error as StdError;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
pub struct Reader {}
impl Reader {
pub fn read_configuration_from_file(path: &Path) -> Result<Configuration, Error> {
match path.extension() {
... | true |
6dbed0518752f5e42a2e2c9f8f29c3a9d601f828 | Rust | lenscas/arena_keeper_quick | /src/structs/character.rs | UTF-8 | 7,409 | 2.8125 | 3 | [] | no_license | use super::{grid::Field, point::Point};
use crate::modules::structs::ModulesContainer;
use crate::{
assets::loaded::Images,
modules::structs::SpeciesType,
structs::{BuyableCharacter, CameraWork, SimpleContext},
};
use pathfinding::{directed::astar::astar, prelude::absdiff};
use rand::prelude::*;
use serde::... | true |
a70db4a3765f774e98a0b7cd539cc2036af59af5 | Rust | tocklime/aoc-rs | /aoc/src/solutions/y2019/day11.rs | UTF-8 | 2,399 | 2.90625 | 3 | [] | no_license | use utils::points::*;
use aoc_harness::aoc_main;
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::mpsc;
use std::thread;
use utils::intcode::Computer;
use utils::ocr::OcrString;
aoc_main!(2019 day 11, part1 [p1] => 2160, part2 [p2] => "LRZECGFE");
const WHITE: char = '█';
const BLACK: char = ' ';
... | true |
78e4b74b9acd1f6633854e4300a818bc8a73821a | Rust | nbari/dbpulse | /src/queries.rs | UTF-8 | 2,823 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | use anyhow::{anyhow, Context, Result};
use chrono::prelude::*;
use chrono::{DateTime, Utc};
use mysql_async::prelude::*;
use rand::Rng;
use uuid::Uuid;
pub async fn test_rw(opts: mysql_async::OptsBuilder, now: DateTime<Utc>) -> Result<String> {
let mut conn = mysql_async::Conn::new(opts).await?;
// create tab... | true |
31ea33326c3ab29e9e2b2610c70bc01103ca62b9 | Rust | dminor/walden | /src/lexer.rs | UTF-8 | 17,394 | 3.53125 | 4 | [] | no_license | use std::collections::LinkedList;
use std::error::Error;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Token {
Bar,
Colon,
ColonEqual,
Dot,
LeftBracket,
RightBracket,
LeftParen,
RightParen,
Plus,
Minus,
Star,
Slash,
Less,
LessEqual,
Equal,
NotEqual,
... | true |
4dd1440a6047bc5aa80e7bbbd427bbde7c2990e5 | Rust | ExcaliburZero/quickbms-lsp | /src/server/server.rs | UTF-8 | 7,449 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::io::{BufRead, Write};
use std::str::from_utf8;
use std::sync::{Arc, Mutex};
use jsonrpc_core::{IoHandler, Params};
use lsp_types::{
DidChangeTextDocumentParams, DidOpenTextDocumentParams, DocumentSymbolParams,
GotoDefinitionParams, GotoDefinitionResponse, HoverParams, HoverProviderCapabi... | true |
2d9dfc5fb4d96faf7ae1fd44567316ff32a886dd | Rust | maxastyler/square_sandpile | /src/main.rs | UTF-8 | 5,363 | 2.765625 | 3 | [] | no_license | #[macro_use]
extern crate ndarray;
extern crate image;
extern crate rayon;
use ndarray::{Array, Array2, ArrayView2, ArrayViewMut2};
use rayon::prelude::*;
fn topple(mut pile: ArrayViewMut2<i64>) {
// Topples a sandpile, using the edges as sinks.
let dim = (pile.shape()[0], pile.shape()[1]);
let mut collap... | true |
994e7224eff195d3e3f41778a0c82b0e66eca312 | Rust | kino00/Rust-zipper | /src/lib.rs | UTF-8 | 25,800 | 3.140625 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::io::{Error};
use std::fs::metadata;
use chrono::prelude::*;
/*
デバッグ用に出力を制御するためのもの
*/
const PRINT_DEBUG: bool = false;
const MAX_BUFFER_SIZE: usize = 1024; // 1回の入力で受けつける最大のバイト
const MAX_MATCH_LEN: usize = 258; // 最大でどれだけ一致するかのサイズ
const MIN_MATCH_LEN: usize =... | true |
ce1c25467dabbb70b581c2d354c4837dcbde20bb | Rust | scottnm/snm_rand_utils | /src/test_utils.rs | UTF-8 | 341 | 2.671875 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
use crate::range_rng::RangeRng;
/// sample_gen_range_caller is used to exercise different implementations of the RangeRng
/// trait being passed to a function via trait reference.
#[cfg(test)]
pub fn sample_gen_range_caller<T: PartialOrd>(rng: &mut dyn RangeRng<T>, lower: T, upper: T) -> T {
rng.gen_r... | true |
89e6c21e9b0c3df251b71d91543b00a0c6300e80 | Rust | addam128/cextractor | /src/analyzers/title_finder.rs | UTF-8 | 2,123 | 2.84375 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use json::JsonValue;
use crate::utils;
use super::traits::Analyzer;
pub(crate) struct TitleFinder {
_title_regexes: [Regex; 7],
_title: String
}
impl TitleFinder {
pub(crate) fn new() -> Result<Self, utils::Error> {
Ok(
Self{
_title: String::new(),
... | true |
28e8fde20ee1acc254e304d6b371761f4270a388 | Rust | ytakasugi/workspace | /Rust_workspace/introduction/section15/intro_1504/intro_1504_06/src/main.rs | UTF-8 | 1,698 | 3.78125 | 4 | [] | no_license | // ジェネリック型に境界(bound)を与え、特定のトレイトを実装していることを保証できるのと同様、
// ライフタイム(それ自身ジェネリック型)にも境界を与えることができます。
// ここでは多少異なる意味を持ちますが`+`は同じです。以下の構文の意味をチェックしてください。
//
// 1.T: 'a: T内の 全ての 参照は'aよりも長生きでなくてはならない
// 2.T: Trait + 'a: 上に加えてTはTraitという名のトレイトを実装してなくてはならない。
//
// 上記の構文を実際に動く例で見ていきましょう。whereキーワードの後に注目してください。
// ライフタイムを紐付けるトレイト
use ... | true |
46307c652529734828950d7abe5ff2354cdad6f9 | Rust | JayThomason/rays | /src/material.rs | UTF-8 | 2,831 | 3.109375 | 3 | [] | no_license | use crate::hittable::HitRecord;
use crate::ray::Ray;
use crate::vec3::{Color, Vec3, reflect, refract};
use rand::Rng;
pub trait Material {
fn scatter(&self, r_in: &Ray, rec: &HitRecord) -> Option<(Ray, Color)>;
}
#[derive(Debug, Copy, Clone)]
pub struct Lambertian {
pub albedo: Color,
}
unsafe impl Send for ... | true |
537ea4b5c4f60a885ebf1c7679ed61fa24896abb | Rust | s4i/cargo-rls-install | /examples/rustup.rs | UTF-8 | 1,182 | 2.765625 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use std::process::Command;
fn main() {
let output = if cfg!(target_os = "windows") {
String::from_utf8(
Command::new("cmd")
.args(&["/C", "rustup show"])
.output()
.expect("failed to execute process")
.stdout,
... | true |
8d35769ec91919bd4274e5a81fb7783477963b1e | Rust | simmons/cbm | /src/disk/chain.rs | UTF-8 | 12,572 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashSet;
use std::io::{self, Write};
use crate::disk::bam::BamRef;
use crate::disk::block::{BlockDeviceRef, Location, BLOCK_SIZE};
use crate::disk::directory::DirectoryEntry;
use crate::disk::error::DiskError;
/// A "zero" chain link is a link that indicates that this is a tail block, and
/// it... | true |
4952e57a0f1cb9dd9d6d55b3482e243f74d43a96 | Rust | rustwasm/wasm-bindgen | /tests/wasm/option.rs | UTF-8 | 1,437 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen(module = "tests/wasm/option.js")]
extern "C" {
pub type MyType;
#[wasm_bindgen(constructor)]
fn new() -> MyType;
fn take_none_byval(t: Option<MyType>);
fn take_some_byval(t: Option<MyType>);
fn return_undef_byval() -> Optio... | true |
0c9c74fb15d344aa23a7a395e7ab8ec945300032 | Rust | aandrews-amu/American-Road-Trip-Path-Finding-Project | /final-project/src/sat.rs | UTF-8 | 1,493 | 3.125 | 3 | [] | no_license | use super::{Constraint, PartialValuation, ValueType, Var};
/// A SAT literal: a `Var` appears either positively or negatively.
pub enum Lit {
Pos(Var),
Neg(Var),
}
impl ValueType for bool {}
/// A SAT clause constraint, comprising a vec of literals; the clause
/// is satisfied if any literal is satisfied.
pub ... | true |
862995d5b425620240bbb1bbda32e3e23b599787 | Rust | you-win/bevy | /crates/bevy_text/src/pipeline.rs | UTF-8 | 3,830 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"Zlib"
] | permissive | use ab_glyph::{PxScale, ScaleFont};
use bevy_asset::{Assets, Handle, HandleId};
use bevy_ecs::component::Component;
use bevy_ecs::system::Resource;
use bevy_math::Vec2;
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use bevy_utils::HashMap;
use glyph_brush_layout::{FontId, SectionText};
use crate::{
... | true |
b92b700ce38b8f243a922a7cc4a927d4557efd51 | Rust | wibbe/organizer | /src/app.rs | UTF-8 | 544 | 2.78125 | 3 | [] | no_license |
use ::ui::*;
use ::doc::*;
use ::glutin;
pub struct App<'a> {
ui: UI,
window: &'a glutin::Window,
doc: Box<Document>,
}
impl<'a> App<'a> {
pub fn new(mut ui: UI, window: &'a glutin::Window) -> App {
ui.print(10, 10, "Hello World", Color::new(230, 230, 230), Color::new(30, 40, 50));
App {
... | true |
a055019bc2028f0c322951290486ab5777dcd155 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/past202104-open/src/bin/l.rs | UTF-8 | 2,068 | 2.6875 | 3 | [] | no_license | use ordered_float::NotNan;
use proconio::input;
fn prim(e: &[Vec<(usize, NotNan<f64>)>], s: usize) -> NotNan<f64> {
let n = e.len();
let mut used = vec![false; n];
let mut d = NotNan::new(0_f64).unwrap();
let mut pq = std::collections::BinaryHeap::new();
pq.push(std::cmp::Reverse((NotNan::new(0_f64... | true |
73e850162115b6767ee7aa14204fde96d287a018 | Rust | panoptesDev/tari-crypto | /src/signatures/schnorr.rs | UTF-8 | 4,669 | 3.21875 | 3 | [] | no_license | //! Schnorr Signature module
//! This module defines generic traits for handling the digital signature operations, agnostic
//! of the underlying elliptic curve implementation
use crate::keys::{PublicKey, SecretKey};
use serde::{Deserialize, Serialize};
use std::{
cmp::Ordering,
ops::{Add, Mul},
};
use tari_ut... | true |
40b6c5e6605f3f2fa61f05ad5066a8e3e2321f4d | Rust | makepad/makepad | /libs/toml_parser/src/toml.rs | UTF-8 | 13,801 | 3.125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap};
use std::str::Chars;
#[derive(Default)]
pub struct TomlParser {
pub cur: char,
pub pos: usize,
}
#[derive(PartialEq, Debug, Clone)]
pub struct TomlSpan{
pub start:usize,
pub len:usize
}
#[derive(PartialEq, Debug)]
pub struct TomlTokWithSpan{
pub span: TomlSpan,
... | true |
11f264fdd64a0e7dc1297fef7397aedb3dd71b3b | Rust | fits/try_samples | /rust/wasm-bindgen/graphql_sample/src/lib.rs | UTF-8 | 2,163 | 2.625 | 3 | [] | no_license | use juniper::{execute_sync, EmptySubscription, FieldError, FieldResult, Variables};
use wasm_bindgen::prelude::*;
use std::collections::HashMap;
use std::sync::RwLock;
#[derive(Default, Debug)]
struct Store {
store: RwLock<HashMap<String, Item>>,
}
impl juniper::Context for Store {}
#[derive(Debug, Clone, junip... | true |
d1c2f19d1f7c260b06c6424ec038e0eca3db4448 | Rust | aeshirey/h3rs | /src/vec3d.rs | UTF-8 | 2,145 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | pub struct Vec3d {
/// x component
pub x: f64,
/// y component
pub y: f64,
/// z component
pub z: f64,
}
/// Square of a number
fn _square(x: f64) -> f64 {
x * x
}
impl Vec3d {
pub const fn new(x: f64, y: f64, z: f64) -> Self {
Vec3d { x, y, z }
}
/// Calculate the squ... | true |
1ca6b994a201028efc60106004eec1c8de4ee38d | Rust | input-output-hk/jorup | /src/commands/setup.rs | UTF-8 | 7,952 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::Cmd;
use crate::{common::JorupConfig, utils::download};
use std::{
env::{self, consts::EXE_SUFFIX},
fs, io,
path::{Path, PathBuf},
};
use structopt::StructOpt;
use thiserror::Error;
/// Operations for 'jorup'
#[derive(Debug, StructOpt)]
pub enum Command {
Install(Install),
Update,
Un... | true |
80f5dd0fcfa69e905b5b6a1b1c8d98c9dea95793 | Rust | ajscholl/mqs | /mqs-common/src/router/handler.rs | UTF-8 | 7,255 | 2.890625 | 3 | [
"BSD-3-Clause"
] | permissive | use http::version::Version;
use hyper::{
header::{HeaderValue, CONNECTION, CONTENT_TYPE, SERVER},
Body,
Request,
Response,
};
use crate::{read_body, router::Router, Status};
/// Handle a single request using the given router.
///
/// If the given connection is `None`, an error response is returned.
//... | true |
f3e8935e2936b2ebfc7f0c0834e7851d76358b82 | Rust | lighter/Leetcode-Rust | /n0168. Excel Sheet Column Title/main.rs | UTF-8 | 387 | 2.703125 | 3 | [
"MIT"
] | permissive | // Author: Netcan @ https://github.com/netcan/Leetcode-Rust
// Zhihu: https://www.zhihu.com/people/netcan
impl Solution {
pub fn convert_to_title(mut n: i32) -> String {
let mut title = String::new();
while n != 0 {
title = ((((n - 1) % 26) as u8 + 'A' as u8) as char).to_string() + &tit... | true |
d55ad682d27ec30e0b1a52951cf3f1c4adf32a7f | Rust | sifyfy/iris-rs | /src/log.rs | UTF-8 | 15,068 | 2.921875 | 3 | [] | no_license | //! # iris::log
//!
//! ## Usage
//!
//! In app:
//! ```
//! iris::log::Tracer::builder()
//! .format_for_app_simple()
//! .init()
//! .unwrap();
//!
//! iris::log::error!("Error");
//! ```
//!
//! In server:
//! ```
//! iris::log::Tracer::builder()
//! .format_for_server()
//! .init()
//! .unwr... | true |
41d73b40c2039afdccb87b32c3acac889530ed07 | Rust | ranon-rat/nysh | /src/tools/sql_for_autocompletition.rs | UTF-8 | 1,196 | 2.765625 | 3 | [] | no_license | use rusqlite::{params, Connection};
// select the last command use it with a resemblance
pub fn update_commands(val: String) {
let conn = Connection::open("src/database/database.db").unwrap();
let sql = "UPDATE commands SET last_time_used=strftime('%f', 'now')+ strftime('%s', 'now') WHERE command=?1;";
con... | true |
95a88648c97fb567ab2fcb56da30593106b2dc49 | Rust | collinpeters/rust-clippy | /tests/ui/string_lit_as_bytes.rs | UTF-8 | 470 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // run-rustfix
#![allow(dead_code, unused_variables)]
#![warn(clippy::string_lit_as_bytes)]
fn str_lit_as_bytes() {
let bs = "hello there".as_bytes();
let bs = r###"raw string with three ### in it and some " ""###.as_bytes();
// no warning, because this cannot be written as a byte string literal:
le... | true |
d4a66090a04693aa62f95aa369caaa6967aa3479 | Rust | optozorax/simple_rustc_tokenizer | /src/lib.rs | UTF-8 | 12,436 | 2.90625 | 3 | [] | no_license | use std::ops::Range;
pub mod peg;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum Token<'a> {
// Idents
Ident(&'a str),
RawIdent(&'a str),
Lifetime(&'a str),
// Comments
LineComment(&'a str),
BlockComment(&'a str),
// String and char
UnescapedString(String),
Char(char),
Bytes(Vec<u8>),
Byte(u8),... | true |
de9d3a7d988bb572ee596a636a8331a9a623a4ec | Rust | tokio-rs/axum | /examples/rest-grpc-multiplex/src/main.rs | UTF-8 | 2,282 | 2.609375 | 3 | [] | no_license | //! Run with
//!
//! ```not_rust
//! cargo run -p example-rest-grpc-multiplex
//! ```
use self::multiplex_service::MultiplexService;
use axum::{routing::get, Router};
use proto::{
greeter_server::{Greeter, GreeterServer},
HelloReply, HelloRequest,
};
use std::net::SocketAddr;
use tonic::{Response as TonicRespo... | true |
cd7c576c11bb50906c123a7f237def0e4eb4dcfd | Rust | nouvadam/pathtracer | /src/material/metalic.rs | UTF-8 | 1,231 | 3 | 3 | [
"MIT"
] | permissive | use crate::hit::Hit;
use crate::material::*;
use crate::misc::ZeroPdf;
use crate::ray::Ray;
use crate::V3;
/// Metalic material.
#[derive(Clone)]
pub struct Metalic {
/// Color of metalic surface.
pub albedo: V3<f32>,
/// Irregularity of surface.
pub fuzz: f32,
}
impl MaterialTrait for Metalic {
f... | true |
69105b192688a60bc46e8ffb48b749c8c83cf280 | Rust | OIdiotLin/LeetCode-Solutions | /354/solution.rs | UTF-8 | 815 | 2.859375 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn max_envelopes(envelopes: Vec<Vec<i32>>) -> i32 {
if envelopes.len() == 0 {
return 0;
}
let mut pairs = envelopes.clone();
pairs.sort();
let mut f = vec![1; pairs.len()];
let mut res = 1;
for i in 1..f.len()... | true |
94e33533766c3189222b1b0ab2c3937c5f1e37a4 | Rust | graphql-rust/graphql-client | /graphql_client/tests/operation_selection.rs | UTF-8 | 1,916 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use graphql_client::GraphQLQuery;
#[derive(GraphQLQuery)]
#[graphql(
query_path = "tests/operation_selection/queries.graphql",
schema_path = "tests/operation_selection/schema.graphql",
response_derives = "Debug, PartialEq, Eq"
)]
pub struct Heights;
#[derive(GraphQLQuery)]
#[graphql(
query_path = "tes... | true |
8cf63bfe1dafbfbfa2798af33aefee1f63dde0bc | Rust | Peter229/SEngine | /src/network_game.rs | UTF-8 | 9,881 | 2.625 | 3 | [] | no_license | use crate::mario;
use crate::online_mario;
use crate::level;
use crate::shader;
use crate::camera;
use crate::sound;
use crate::network;
use std::net::{UdpSocket, SocketAddr, IpAddr, Ipv4Addr};
use std::io::{self, Read, Error, stdin, stdout, Write, ErrorKind};
use std::collections::HashMap;
use cgmath;
use s... | true |
236646db2d0876cb02bb3f4d531fb68679b1255e | Rust | mchesser/gdbstub | /src/target/ext/catch_syscalls.rs | UTF-8 | 1,917 | 3.015625 | 3 | [
"MIT"
] | permissive | //! Enable or disable catching syscalls from the inferior process.
use crate::arch::Arch;
use crate::target::{Target, TargetResult};
/// Target Extension - Enable and disable catching syscalls from the inferior
/// process.
///
/// Implementing this extension allows the target to support the `catch syscall`
/// GDB c... | true |
140016a49bbbd19c0c945a4ce7a5c955ef56a9bf | Rust | bolipus/rustcodewars | /src/main.rs | UTF-8 | 21,520 | 3.359375 | 3 | [] | no_license | use std::collections::HashMap;
use std::fmt;
use std::mem;
use std::str::FromStr;
mod codewars;
fn literals_operator() {
println!("1 + 2 = {}", 1i32 + 2);
println!("0011 ^ 0110 = {:04b}", 0b0011u32 ^ 0b0110u32);
println!("0011 << 2 = {:04b}", 0b0011u32 << 2);
println!("0011 >> 2 = {:04b}", 0b0011u3... | true |
aa0b76ef332a75c346c8ed6f3e857795f72241c0 | Rust | niofis/raybench | /bench.rs | UTF-8 | 9,305 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env run-cargo-script
//! Install cargo-script first:
//! cargo install cargo-script
//! cargo script bench.rs -- run c -m
//!
//! ```cargo
//! [dependencies]
//! time = "0.1"
//! clap = "2"
//! ```
extern crate clap;
extern crate time;
use clap::{App, AppSettings, Arg, SubCommand};
use std::fs::File;
use st... | true |
f580fcaba6976d9fff1a9b74c84dfe076aae429f | Rust | tuxmark5/north | /north_core/src/util/dyn_traits.rs | UTF-8 | 2,104 | 3.109375 | 3 | [] | no_license | use {
std::{
any::Any,
cmp::PartialEq,
hash::{Hash, Hasher},
}
};
////////////////////////////////////////////////////////////////////////////////////////////////
pub struct Dyn<T: ?Sized>(pub T);
pub struct DynBox<T: ?Sized>(pub Box<T>);
/*impl<T: ?Sized> Borrow<Dyn<T>> for Box<Dyn<T>> {
fn borrow... | true |
b661504f70faba19eb5a7900cd14ae8d857cf190 | Rust | littleroys/leetcode-rs | /src/algebra/k_closest_point.rs | UTF-8 | 610 | 3.234375 | 3 | [] | no_license | // 973 find k-th close points
struct Solution;
impl Solution {
pub fn k_closest(points: Vec<Vec<i32>>, k: i32) -> Vec<Vec<i32>> {
let mut points: Vec<Vec<i32>> = points;
points.sort_by(|a, b| (a[0].pow(2) + a[1].pow(2)).cmp(&(b[0].pow(2) + b[1].pow(2))));
points.drain(..k as usize).collect... | true |
bbec31ad78e4ccddba1899a36f10eba12860d89b | Rust | foleyj2/rust-examples | /rust-book/09-error_handling/src/main.rs | UTF-8 | 3,466 | 3.234375 | 3 | [
"MIT"
] | permissive | // Example code from Rust Book Chapter 9
// https://doc.rust-lang.org/book/ch09-00-error-handling.html
use std::error::Error;
use std::fs;
use std::fs::File;
use std::io;
use std::io::ErrorKind;
use std::io::Read;
fn main() {
//println!("Hello, world!");
println!("Error handling examples");
//panic_basic(... | true |
7d71d08a4e8c04b0208c0b4a463da3855d26f0ea | Rust | ergoplatform/sigma-rust | /ergotree-interpreter/src/eval/coll_by_index.rs | UTF-8 | 2,659 | 2.765625 | 3 | [
"CC0-1.0"
] | permissive | use ergotree_ir::mir::coll_by_index::ByIndex;
use ergotree_ir::mir::constant::TryExtractInto;
use ergotree_ir::mir::value::Value;
use crate::eval::env::Env;
use crate::eval::EvalContext;
use crate::eval::EvalError;
use crate::eval::Evaluable;
impl Evaluable for ByIndex {
fn eval(&self, env: &Env, ctx: &mut EvalCo... | true |
0bec9b5a17a6d086813910bf7c112c7b09796698 | Rust | maniflames/insync | /src/system/input.rs | UTF-8 | 1,543 | 2.765625 | 3 | [] | no_license | use recs::{EntityId, component_filter};
use crate::*;
pub fn run(mut window: &mut three::Window, mut store: &mut Ecs) {
let component_filter = component_filter!(Position, GameObject);
let mut entities: Vec<EntityId> = Vec::new();
store.collect_with(&component_filter, &mut entities);
for enti... | true |
a860f5df10ef528689f2b5ab1ad92d97fbeed390 | Rust | Voxelot/transaction-processor | /src/domain/engine/tests/deposit.rs | UTF-8 | 2,639 | 2.65625 | 3 | [] | no_license | use crate::domain::engine::tests::test_helpers::{
TestContext, TEST_CLIENT_ID, TEST_TRANSACTION_ID_1,
};
use crate::domain::model::{AmountInMinorUnits, Deposit, Transaction};
use crate::domain::ports::Engine;
#[tokio::test]
async fn deposit_increases_client_available_funds_by_deposit_amount() {
// test setup
... | true |
20b7e38db6761b3e788d12a60c15a18009bc1e97 | Rust | szabo137/ptarmigan | /src/input/types.rs | UTF-8 | 3,730 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive |
//! YAML-readable types
use std::convert::TryFrom;
use yaml_rust::yaml::Yaml;
use meval::Context;
/// Types that can be parsed from a YML-formatted file
pub trait FromYaml: Sized {
type Error;
/// Attempt to parse the YML field as the specified type, using the supplied Context for named variables and constan... | true |
2b07db33421424d36cd37d9a97ba2bc4d4ca0015 | Rust | MatusT/master-thesis | /lod_creator/src/main.rs | UTF-8 | 4,843 | 2.609375 | 3 | [
"MIT"
] | permissive | use kmeans;
use nalgebra_glm::*;
use rpdb::{molecule::Molecule, molecule::MoleculeLod, FromRon, ToRon};
fn sphere_sreen_space_area(projection: Mat4, dimensions: Vec2, center: Vec3, radius: f32) -> f32 {
let d2 = dot(¢er, ¢er);
let a = (d2 - radius * radius).sqrt();
// view-aligned "right" vector (... | true |
9f937835b35be26abab8b9e28ff2825af1d39dc8 | Rust | john-terrell/mantle | /src/scenegraph/geometry/vector.rs | UTF-8 | 1,747 | 3.8125 | 4 | [] | no_license | #[derive(Copy, Clone)]
pub struct Vector {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vector {
pub fn add(lhs: Vector, rhs: Vector) -> Vector {
return Vector{
x: lhs.x + rhs.x,
y: lhs.y + rhs.y,
z: lhs.z + rhs.z,
}
}
pub fn subtract(lhs: Vect... | true |
19e94d93bff2fa263843f1ca2828617fe75a8ea8 | Rust | Orange-OpenSource/hurl | /packages/hurl/src/report/tap/testcase.rs | UTF-8 | 2,924 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Hurl (https://hurl.dev)
* Copyright (C) 2023 Orange
*
* 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 ... | true |
7d7e4578d0262954e55e3e26b6b12dee809be981 | Rust | andygrove/hmc5883l-rs | /src/lib.rs | UTF-8 | 1,516 | 2.953125 | 3 | [] | no_license | use std::f32;
use std::thread;
use std::time::Duration;
extern crate i2cdev;
use self::i2cdev::core::*;
use self::i2cdev::linux::{LinuxI2CDevice, LinuxI2CError};
pub struct HMC5883L {
dev: Box<LinuxI2CDevice>
}
impl HMC5883L {
pub fn new(filename: &'static str, address: u16) -> Result<Self, Box<LinuxI2CErro... | true |
81ca867a8b731d222254db6158028680ffa0d4f7 | Rust | rodya-mirov/palladium | /main/src/systems/update/breathe.rs | UTF-8 | 3,623 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use std::collections::HashMap;
use components::{Breathes, CanSuffocate, HasPosition, OxygenContainer};
use resources::{Callbacks, NpcMoves};
fn safe_subtract(start: usize, subtraction: usize) -> usize {
if start > subtraction {
start - subtraction
} else {
0
}
}
fn add_and_... | true |
7fe0ac8efd60a45b1692c2aa421ff350433286bc | Rust | standard-ai/hedwig-rust | /src/topic.rs | UTF-8 | 509 | 3 | 3 | [
"Apache-2.0"
] | permissive | /// A message queue topic name to which messages can be published
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Topic(&'static str);
impl std::fmt::Display for Topic {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.0, f)
... | true |
878f5a400b280ca03072fe1fee4f8c30acac14dc | Rust | Rodrigodd/gameroy | /src/rom_loading/wasm.rs | UTF-8 | 3,410 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::borrow::Cow;
use gameroy::gameboy::cartridge::CartridgeHeader;
use wasm_bindgen::{closure::Closure, JsCast, JsValue};
pub fn load_roms(_roms_path: &str) -> Result<Vec<RomFile>, String> {
Ok(Vec::new())
}
pub fn load_boot_rom() -> Option<[u8; 256]> {
None
}
pub fn load_file(file_name: &str) -> Result... | true |
6da1383d69284fb5246bae246f003487c127b4eb | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/nom/src/internal.rs | UTF-8 | 10,226 | 2.828125 | 3 | [
"CC0-1.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
self
:
:
Needed
:
:
*
;
use
crate
:
:
error
:
:
{
self
ErrorKind
}
;
use
crate
:
:
lib
:
:
std
:
:
fmt
;
use
core
:
:
num
:
:
NonZeroUsize
;
pub
type
IResult
<
I
O
E
=
error
:
:
Error
<
I
>
>
=
Result
<
(
I
O
)
Err
<
E
>
>
;
pub
trait
Finish
<
I
O
E
>
{
fn
finish
(
self
)
-
>
Result
<
(
I
O
)
E
>
;
}
impl
<
I
O
E
>... | true |
974a9d95546e8ea4c1feeb24bb6a8fb91d17a2ae | Rust | smokku/emerald | /src/world/emerald_world.rs | UTF-8 | 4,200 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::rendering::components::Camera;
use crate::EmeraldError;
use hecs::*;
#[cfg(feature = "physics")]
use crate::world::physics::*;
#[cfg(feature = "physics")]
use rapier2d::dynamics::*;
pub struct EmeraldWorld {
#[cfg(feature = "physics")]
pub(crate) physics_engine: PhysicsEngine,
pub(crate) inner... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.