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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a12e178110c81ded1b44714947216fede98ce817 | Rust | alexcrichton/xz2-rs | /tests/xz.rs | UTF-8 | 1,816 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use xz2::read;
use xz2::stream;
use xz2::write;
#[test]
fn standard_files() {
for file in Path::new("lzma-sys/xz-5.2/tests/files").read_dir().unwrap() {
let file = file.unwrap();
if file.path().extension().and_then(|s| s.to_str()) !=... | true |
3c781b5ad8f8ef41ca449a921919b5f89fe6cd0a | Rust | anowell/kubeclient-rs | /examples/get-secret.rs | UTF-8 | 973 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate kubeclient;
use std::env;
use kubeclient::prelude::*;
use kubeclient::errors::*;
fn get_secret(name: &str) -> Result<bool> {
// filename is set to $KUBECONFIG if the env var is available.
// Otherwise it falls back to "admin.conf".
let filename = env::var("KUBECONFIG").ok();
let filename =... | true |
2533da01f0b5bc908ec3bc4069d12663541eef03 | Rust | mathiasmagnusson/wrath | /wrath-engine/src/platform/glutin_window.rs | UTF-8 | 9,411 | 2.5625 | 3 | [] | no_license | use crate::{events::*, input::get_mouse_position, Button, Event, Window, WindowProps};
use whm::Float;
pub struct GlutinWindow {
win_ctx: glutin::WindowedContext<glutin::PossiblyCurrent>,
evt_loop: glutin::EventsLoop,
title: String,
close_requested: bool,
}
impl GlutinWindow {
pub fn new(props: WindowProps) -> ... | true |
dbc1853b104f514c381de2c9c18885e0628e83e2 | Rust | Gachapen/lsystem | /src/glp.rs | UTF-8 | 8,124 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
use na::UnitQuaternion;
use kiss3d::window::Window;
use kiss3d::camera::Camera;
use rand;
use rand::Rng;
use rand::distributions::{IndependentSample, Range};
use lsys;
use lsys::Rewriter;
use lsys::param;
use lsys::param::Param;
use lsys3d;
const LETTER_BEGIN: u8 = 65;
const LETT... | true |
290eea8646a98d8fe0710a0b553cf611d3cee82f | Rust | jugglerchris/rust-html2text | /src/ansi_colours.rs | UTF-8 | 1,640 | 3.375 | 3 | [
"MIT"
] | permissive | //! Convenience helper for producing coloured terminal output.
//!
//! This optional helper applies terminal colours (or other effects which
//! can be achieved using inline characters sent to the terminal such as
//! underlining in some terminals).
use crate::{parse, RichAnnotation, RichDecorator};
use std::fmt::Writ... | true |
441b2ecd323b947b29f5f6a2cddc41642aeb4577 | Rust | dollarkillerx/RUST-Newcomer-Development-Program | /s01/s01_8/src/main.rs | UTF-8 | 916 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::mem;
fn main() {
test1();
test2();
test3();
test4();
}
fn apply<F>(f: F)
where F: FnOnce() {
f();
}
fn test1() {
let greeting = "hello";
let diary = || {
println!("I said {}.", greeting); // Fn
};
apply(diary);
}
fn test2() {
// 不可复制的类型。
// `to_ow... | true |
3d08d671c6f4a5d2e8c8d5f3066bcd52bdb065a8 | Rust | hskang9/cosmwasm | /packages/vm/src/errors.rs | UTF-8 | 18,335 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt::{Debug, Display};
use snafu::Snafu;
#[derive(Debug, Snafu)]
#[non_exhaustive]
pub enum VmError {
#[snafu(display("Cache error: {}", msg))]
CacheErr {
msg: String,
backtrace: snafu::Backtrace,
},
#[snafu(display("Error in guest/host communication: {}", source))]
Commun... | true |
e742852da0dcfebc1aa3119d5c35c4bec88e4811 | Rust | knutin/traildb-benchmark | /rust/benchmark.rs | UTF-8 | 891 | 2.703125 | 3 | [
"MIT"
] | permissive | extern crate traildb;
use traildb::Db;
use std::path::Path;
fn main() {
let db_path = Path::new("/mnt/data/wikipedia-history-small.tdb");
let db = Db::open(db_path).unwrap();
let mut user_edits = 0;
let mut ip_edits = 0;
let mut fields = Vec::new();
for i in 1..db.num_fields() as traildb::Field... | true |
e3153df98c901ec885d0a7da5405cab596471d45 | Rust | itang/tests | /test-stomp-rs/src/main.rs | UTF-8 | 629 | 2.71875 | 3 | [] | no_license | extern crate stomp;
use stomp::frame::Frame;
use stomp::subscription::{Ack, AckOrNack, Client};
fn main() {
let mut session = match stomp::connect("127.0.0.1", 61613){
Ok(session) => session,
Err(error) => fail!("Could not connect to the server: {}", error)
};
fn on_message(frame: Frame) -> AckOrNack {
... | true |
d9111657cccb9c732248f3d292034634f02cb124 | Rust | prince-pascoe/easigrow | /src/main.rs | UTF-8 | 15,907 | 2.515625 | 3 | [
"MIT"
] | permissive | /// easiGrow
///
/// by Paul White (Nov 2014--2017)
/// written in rust (www.rust-lang.org)
///
/// A program to match crack growth predictions to measurements.
///
/// The program calculates fatigue crack growth rates and finds the
/// optimum parameters of a crack growth model to match predictions
/// with measuremen... | true |
b875039c2920b71747665a44e9d0f2e920f30c28 | Rust | geo-engine/geoengine | /datatypes/benches/grid_updates.rs | UTF-8 | 5,537 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use criterion::{black_box, criterion_group, criterion_main, Criterion};
use geoengine_datatypes::raster::{
Grid, GridIdx, GridIdx1D, GridIdx2D, GridShape, UpdateIndexedElements,
UpdateIndexedElementsParallel,
};
#[allow(clippy::unit_arg)]
fn update_indexed_elements_1d_simple(c: &mut Criterion) {
let grid_s... | true |
6d8b875afac6e8918e1cac2f91fd3eeabc6066d6 | Rust | kanagasabai-Hub/rust-programs-practised | /collections and hashmaps/hashmap.rs | UTF-8 | 1,439 | 4.28125 | 4 | [] | no_license | // A map is a collection of key-value pairs (called entries).
// No two entries in a map can have the same key.
// In short, a map is a lookup table.
// A HashMap stores the keys and values in a hash table.
// The entries are stored in an arbitrary order.
// The key is used to search for values in the HashMap.
// T... | true |
6cac1b6ee68e5517619e21a30712d66a68af9cda | Rust | MarcusTL12/opengltest-rust | /src/vertex_buffer_layout.rs | UTF-8 | 1,924 | 3.40625 | 3 | [] | no_license | use gl;
pub struct VertexBufferElement {
pub el_type: u32,
pub count: i32,
pub normalized: bool,
}
impl VertexBufferElement {
pub fn type_size(&self) -> i32 {
match self.el_type {
gl::FLOAT => 4,
gl::UNSIGNED_INT => 4,
gl::UNSIGNED_BYTE => 1,
_ =... | true |
cdd0294f17598e76dcf36f017990ca24f50fdf11 | Rust | landersson/aoc2018 | /day4/src/lib.rs | UTF-8 | 2,226 | 2.96875 | 3 | [] | no_license | #![allow(dead_code)]
#[macro_use]
extern crate lazy_static;
extern crate chrono;
extern crate regex;
use chrono::NaiveDateTime;
use chrono::Timelike;
use regex::Regex;
use std::boxed::Box;
use std::error;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
pub type Result<T> = ::std::result::Re... | true |
05516c9b6372b06b99026fb9a0fbc9d7cc193f98 | Rust | RexTremendae/AdventOfCode | /archive/Source/2019/Day2_1.rs | UTF-8 | 2,472 | 3.46875 | 3 | [] | no_license | use std::vec::Vec;
type Instruction = i32;
type Address = usize;
fn main()
{
let mut program = Program::new(vec![1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6,1,19,2,19,9,23,1,23,5,27,2,6,27,31,1,31,5,35,1,35,5,39,2,39,6,43,2,43,10,47,1,47,6,51,1,51,6,55,2,55,6,59,1,10,59,63,1,5,63,67,2,10,67,71,1,6,71,75,1,5,75,79,1,10,79... | true |
579d8a0e814702ea5b816286aba88798d769ef2a | Rust | stefan-blair/prefix_scan | /src/util/ranged_vector.rs | UTF-8 | 1,470 | 3.671875 | 4 | [] | no_license |
#[derive(Clone, Debug)]
pub struct Range<T> {
start: usize,
end: usize,
value: T,
index: usize,
}
impl<T> Range<T> {
fn new(start: usize, end: usize, value: T, index: usize) -> Self {
Self { start, end, index, value }
}
pub fn value(&self) -> &T {
&self.valu... | true |
d11b3c9d07116ec63350309e4ee3ac5611f122dd | Rust | ErikBuer/Integer-Array | /src/utility.rs | UTF-8 | 5,085 | 3.5625 | 4 | [
"MIT"
] | permissive | use fixed::traits::Fixed;
/// Rase integer to an integer-valued power.
/// base^power.
pub fn powi( base:i32, power:usize ) -> i32 {
let mut temp:i32 = base;
for _i in 0..power-1 {
temp = temp*base;
}
return temp;
}
/// Rase float number to an integer-valued power.
/// - `base^power`.
pub fn f... | true |
5d4f452b36f7e35baf70eb3c20cfa05f3e2bd5bf | Rust | molikto/nolex | /src/editor/widget.rs | UTF-8 | 23,690 | 2.609375 | 3 | [] | no_license | use druid::piet::{FontBuilder, Text, TextLayoutBuilder, TextLayout, PietFont, PietText};
use druid::widget::prelude::*;
use druid::{Point, Color, Rect};
use druid::text::{Selection, BasicTextInput, TextInput, EditAction, EditableText, offset_for_delete_backwards, Movement, movement};
use tree_sitter::{Parser, Node, Tre... | true |
314befbf9c59b612e871d0f0ce2f3fefd8d12cff | Rust | thlorenz/crisscross | /src/ray.rs | UTF-8 | 13,887 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use crate::{
angle::{DirectionX, DirectionY},
grid::Grid,
position::{SignedTilePosition, TilePosition, WorldCoords},
util::floats_equal,
AngleRad,
};
fn normalize_zeros(tp: &mut SignedTilePosition) {
// Avoid (-0.0)
if floats_equal(tp.rel_x, 0.0) {
tp.rel... | true |
10f1beb5d1a8fe72e63c2b4d8d263691c7edb0ea | Rust | SaadDAHMANI/mlsolver | /src/pipe.rs | UTF-8 | 1,889 | 3.140625 | 3 | [
"MIT"
] | permissive |
#[derive(Debug, Clone)]
pub struct Pipe {
id : usize,
name : Option<String>,
start : usize,
end : usize,
length : f64,
diameter : f64,
c_hw : f64,
flow : Option<f64>,
//velocity : Option<f64>,
state : LinkStatus,
check_valve : bool,
}
impl Pipe {
fn headloss(&self)-> ... | true |
b48a8b64170ed2ddc63ba5eefe765dc962d9ae3f | Rust | lukexor/pix-engine | /src/event.rs | UTF-8 | 15,461 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! User and system [Event]s.
use bitflags::bitflags;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{
fmt,
ops::{Deref, DerefMut},
};
/// System or User `Event`.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub en... | true |
6148264b6ffdf146810a51bb927cb4338638424b | Rust | rust-lang/glacier | /fixed/67883.rs | UTF-8 | 285 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![feature(const_generics)]
struct Caca<const A: &'static str> {
s: String
}
impl<const A: &str> Default for Caca<A> {
fn default() -> Self {
let a = Self::A;
Self {
s: A.to_string()
}
}
}
fn main() {
println!("Hello, world!");
}
| true |
f4804947a6913f1f8c4baed5ccf3000627956d78 | Rust | zhaofengli/attic | /server/src/access/http.rs | UTF-8 | 3,389 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! HTTP middlewares for access control.
use axum::{http::Request, middleware::Next, response::Response};
use sea_orm::DatabaseConnection;
use tokio::sync::OnceCell;
use crate::access::{CachePermission, Token};
use crate::database::{entity::cache::CacheModel, AtticDatabase};
use crate::error::ServerResult;
use crate:... | true |
2d9498bee1321d4c0f2d9fb019cf1420bbaeff07 | Rust | charlescerisier/tempest | /tempest-source-redis/examples/topology-redis-stream/src/main.rs | UTF-8 | 4,687 | 2.53125 | 3 | [
"MIT"
] | permissive | use tempest::prelude::*;
use tempest_source_redis::prelude::*;
use pretty_env_logger;
static TOPOLOGY_NAME: &'static str = "TopologyExample";
static T1: &'static str = "T1";
static T2: &'static str = "T2";
static T3: &'static str = "T3";
static T4: &'static str = "T4";
// Define a source builder type
type Source = R... | true |
15639c5cf9ebd0d2701a102b9a718382a5bbd53c | Rust | finegeometer/four-dimensions-2 | /src/model/four_camera.rs | UTF-8 | 2,003 | 3.359375 | 3 | [] | no_license | pub struct FourCamera {
pub position: nalgebra::Vector4<f32>,
pub orientation: Orientation,
fov: f32,
}
impl Default for FourCamera {
fn default() -> Self {
Self {
position: nalgebra::Vector4::zeros(),
orientation: Orientation::default(),
fov: 1.57,
}... | true |
ed6a535d2c175c6d908fc4ff78fd57dceef1908b | Rust | wusyong/iota-compress-rust | /iota-compress/benches/benchmark.rs | UTF-8 | 1,085 | 2.984375 | 3 | [] | no_license | #[macro_use]
extern crate criterion;
extern crate rand;
use criterion::Criterion;
use iota_compress::{compress, decompress};
use rand::Rng;
const PACKET_SIZE: usize = 2673;
fn generate_random() -> String {
let tryte_alphabet: Vec<char> = vec!['9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', ... | true |
e7d6f81944d00fb370404559d330ed4df7f173c1 | Rust | IvanInAporia/Kata | /BinarySearch/BinarySearch.rs | UTF-8 | 1,549 | 3.390625 | 3 | [] | no_license |
fn chop(item: i32, array: &[i32]) -> i32 {
let mut location = -1;
if array.len() == 1
{
if array[0] == item
{
location = 0;
}
}
else if array.len() > 1
{
let middle = (array.len() / 2) as usize;
if array[middle] == item
{
... | true |
2acf1b27a9af8bbbf112a2fb41a171ea325ccad9 | Rust | MggMuggins/code_runner | /src/handler.rs | UTF-8 | 6,460 | 2.890625 | 3 | [] | no_license | use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::{File, read_dir};
use std::io::{Read, Write};
use std::path::PathBuf;
use std::process::{Command, Output};
use failure::Error;
use serenity::model::channel::Message;
use serenity::model::event::MessageUpdateEvent;
use serenity::model::id::ChannelId;
use ... | true |
9b94e14b0fab8d1a3581aebbcda6bd86abfe7f44 | Rust | GGalizzi/learningopengl | /src/component.rs | UTF-8 | 3,070 | 3.171875 | 3 | [] | no_license | use std::ops;
use vek::{Quaternion, Vec3};
use crate::util::quat_from_ypr;
#[derive(Clone)]
pub struct Position {
vector: Vec3<f32>,
}
impl Position {
pub fn new(x: f32, y: f32, z: f32) -> Position {
Position {
vector: Vec3::new(x, y, z),
}
}
pub fn from_vector(vector: Ve... | true |
8a46c5ef7b5167a9174720be4e1c3f7524f2bfbc | Rust | wreganpdx/ApeRust | /src/pdx/ape/owner_collision.rs | UTF-8 | 2,177 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::vector::Vector;
#[derive(Default, Debug)]
pub struct OwnerCollision {
pub mtd: Vector,
pub vel: Vector,
pub n: Vector,
pub d: f64,
pub o: i32,
pub owner_rect: i64,
pub owner_constraint: i64,
pub sibling1: i64,
pub sibling2: i64,
pub collider: i64,
}
impl OwnerCollisi... | true |
7050c7b8a74e6b0cca932f9c0b8bc8a4cd2a9430 | Rust | danielhstahl/cf_functions_rust | /src/affine_process.rs | UTF-8 | 17,156 | 3.125 | 3 | [] | no_license | use num_complex::Complex;
/// Returns log of moment generating function for Cox Ingersoll Ross process evaluated at complex argument.
///
/// # Remarks
/// Useful for time changed levy processes. "psi" can be a characteristic function of a levy process
/// evaluated at a given "u".
///
/// # Examples
///
/// ```
/// e... | true |
66d1b2bdf6cd42e80fcf2a879dba98182228ac24 | Rust | ArtificialEvolvingWorld/entendre-rust | /src/neural_net_consecutive.rs | UTF-8 | 7,192 | 3.15625 | 3 | [] | no_license | use std::collections::HashMap;
use crate::neural_net::*;
#[derive(Debug)]
enum NodeValue {
Accumulator(f32),
Activated(f32),
}
#[derive(Debug)]
struct Node {
value: NodeValue,
node_type: NodeType,
func: ActivationFunction,
}
impl Node {
fn get_val(&mut self) -> f32 {
match self.value... | true |
1dc1246128a7e37c65c4e29aa82a78fee4972fbc | Rust | Carlton-Perkins/aoc-2020 | /day5-p2/src/main.rs | UTF-8 | 2,627 | 3.140625 | 3 | [] | no_license | /*
--- Part Two ---
Ding! The "fasten seat belt" signs have turned on. Time to find your seat.
It's a completely full flight, so your seat should be the only missing boarding pass in your list. However, there's a catch: some of the seats at the very front and back of the plane don't exist on this aircraft, so they'll ... | true |
874fcae5a2eeb03dd2cd3509cd121ae604913245 | Rust | Bitcoin-ABC/bitcoin-abc | /chronik/bitcoinsuite-core/src/bytes.rs | UTF-8 | 2,137 | 3.234375 | 3 | [
"MIT"
] | permissive | // Copyright (c) 2023 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//! Module for [`read_bytes`] and [`read_array`].
use bytes::Bytes;
use crate::error::DataError;
/// Read `num_bytes` bytes from the... | true |
460c3926819323b950eb18488a92b3e49fc210ce | Rust | cnruby/learn-rust-by-crates | /hello-trait/lib-hello/examples/trait_with_default_method.rs | UTF-8 | 943 | 3.484375 | 3 | [] | no_license | mod trait_exerci {
#[derive(Debug)]
pub struct StructType {
pub data: u32,
}
pub trait TraitCanal {
fn new(data: u32) -> StructType;
fn init() -> StructType { StructType{data:0} }
fn get_data(&self) -> u32;
fn set_data(&mut self, data: &u32);
}
impl Trai... | true |
5e40360149b620a02ab8e06cbcd82b4e893d4772 | Rust | jbethune/rust-pushrod | /src-old/core/widget_store.rs | UTF-8 | 17,766 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | // Window Container
// Contains a PistonWindow and a list of widgets
//
// 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 |
b63ba548c642a855af6c9ac096c61b1f2ad3e286 | Rust | hiszd/kiibohd-core | /kiibohd-keyscanning/src/state.rs | UTF-8 | 6,857 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2021 Zion Koyl
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to tho... | true |
74aadaeac0256a345997f5ed8065f7eb6d4180f7 | Rust | Avokadoen/tdt4230_project_raytracing | /src/utility/mod.rs | UTF-8 | 681 | 2.796875 | 3 | [] | no_license | use cgmath::Vector3;
pub mod chronos;
pub mod ply_point_loader;
pub enum Direction {
Front,
Back,
Rigth,
Left,
Up,
Down,
}
impl Direction {
pub fn into_vector3(self) -> Vector3::<f32> {
match self {
Direction::Front => Vector3::<f32>::new( 0.0, 0.0, -1.0),
... | true |
d40a41be1fd9815a6fc83008c99dea0303589a68 | Rust | ohsayan/dockinfo | /src/main.rs | UTF-8 | 4,166 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | use std::env;
use std::process;
/// EXIT CODE: SUCCESS
const EXIT_OK: i32 = 0x0000;
/// EXIT CODE: FAILURE
const EXIT_ERR: i32 = 0x0100;
/// Help message
const MSG_USAGE: &'static str = "Run dockinfo --help for usage";
/// The docker inspect syntax for getting the IP address
const CMD_DOCKER_INSPECT: &'static str =
... | true |
e070e652a72c5ac6d3f42471623a2e658db7f904 | Rust | Nikheln/advent-of-code-2020 | /src/bin/day09.rs | UTF-8 | 3,775 | 3.296875 | 3 | [] | no_license | use std::collections::VecDeque;
mod helpers;
fn main() {
let filename: &str = "day09.txt";
let input = helpers::input_helpers::read_input(&filename).unwrap();
task_1(&input);
task_2(&input);
}
fn task_1(input: &[String]) {
println!("Task 1: {}", task_1_internal(input, 25));
}
fn task_1_internal... | true |
77bfc563b88c78effd434e4ece92a9a631a3960f | Rust | marionauta/bspc | /src/main.rs | UTF-8 | 2,261 | 3.15625 | 3 | [
"MIT"
] | permissive | //! BSPC command to control BSPWM
extern crate libc;
extern crate unix_socket;
use libc::{EXIT_FAILURE, EXIT_SUCCESS};
use std::env;
use std::io::{Read, Write};
use std::process;
use unix_socket::UnixStream;
const BUFSIZ: usize = libc::BUFSIZ as usize;
const FAILURE_MESSAGE: i32 = 7;
const SOCKET_ENV_VAR: &'static s... | true |
3e3212ef0ff796a4281ebac88025dcc9f6b52734 | Rust | XuShaohua/nc | /src/calls/write.rs | UTF-8 | 768 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | /// Write to a file descriptor.
///
/// # Example
///
/// ```
/// let path = "/tmp/nc-write";
/// let ret = unsafe { nc::openat(nc::AT_FDCWD, path, nc::O_CREAT | nc::O_WRONLY, 0o644) };
/// assert!(ret.is_ok());
/// let fd = ret.unwrap();
/// let msg = "Hello, Rust!";
/// let ret = unsafe { nc::write(fd, msg.as_ptr() a... | true |
33ea31d16ec10782469f48b200349ed4a3279f44 | Rust | jbaldwin/game_of_life.rust | /main.rs | UTF-8 | 1,187 | 2.828125 | 3 | [
"MIT"
] | permissive | extern mod extra;
use std::os;
use std::path;
use extra::getopts::{getopts, reqopt, optflag, Opt};
use grid::{Grid, Printable};
use util::console;
use util::thread;
mod util;
mod grid;
fn print_usage(program_name: &str, _opts: &[Opt]) {
println!("Usage: {:s} [options]", program_name);
println(" -i\t\t-> Path to i... | true |
9d054bbb25bd0b3ec28191cb3189e0d1f818e268 | Rust | PatiPavanSai/rust-cardano | /cardano/src/util/hex.rs | UTF-8 | 3,110 | 3.78125 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! simple implementation of hexadecimal encoding and decoding
//!
//! # Example
//!
//! ```
//! use cardano::util::hex::{Error, encode, decode};
//!
//! let example = b"some bytes";
//!
//! assert!(example.as_ref() == decode(&encode(example)).unwrap().as_slice());
//! ```
//!
use std::{result, fmt};
const ALPHABET : ... | true |
b28ef7fe80ba1a344b387f59d515b9609af96c37 | Rust | at-tran/twitch-youtube-sync | /src/download/mod.rs | UTF-8 | 2,423 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::video::Video;
use regex::Regex;
use reqwest::blocking::{self, Client};
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use std::process::{Command, Stdio};
pub fn download_twitch_video<P: AsRef<Path>>(video_id: &str, save_folder: P) -> Video {
let path = save_folder.as_ref().join(video_i... | true |
fc6c5848fdf3513cbbe363d34040899ab105f3b7 | Rust | muzudho/tomboy-toml-dom | /src/model/layer210/non_ascii.rs | UTF-8 | 723 | 3.03125 | 3 | [
"MIT"
] | permissive | //! Non ascii model.
//! 非アスキー・モデル。
use crate::model::layer210::NonAscii;
use std::fmt;
impl NonAscii {
pub fn new(chr: char) -> Self {
NonAscii { character: chr }
}
pub fn get_character(&self) -> char {
self.character.clone()
}
pub fn to_debug_string(&self) -> String {
... | true |
e855d5ce35fd4b70a60e3eef209a64383ec4d437 | Rust | ipinmi/modmultinverse | /src/main.rs | UTF-8 | 2,565 | 3.984375 | 4 | [] | no_license | // The function takes in the following variables, a As the integer, x as the modular multiplicative inverse of the integer and m as the modulo
// whole numbers can either be represented as signed integers as i32 or i64,
// isize will be used to create a memory address for these values which would be "pointed" to/ ref... | true |
25e190ee0cf5668a1ec9a11760903efe551da20d | Rust | newAM/r3 | /src/r3_test_suite/src/kernel_tests/compute_round_robin.rs | UTF-8 | 6,543 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Performs a compute-intensive task in multiple tasks that run in a
//! round-robin fashion, and validates the output of each run.
//!
//! The intent of this test to detect bugs in the saving and restoring of
//! registers during a context switch. To this end, the task is designed to
//! utilize as many floating-poin... | true |
eb40488f42009301ba185c5269a87fd9314cc2d6 | Rust | rick68/rust-trace | /libcore/intrinsics/roundf64.rs | UTF-8 | 1,112 | 3.5625 | 4 | [
"MIT"
] | permissive | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::roundf64;
// pub fn roundf64(x: f64) -> f64;
// Round half away from zero:
//
// The other tie-breaking method commonly taught and used is the round half
// away from zero (or round half towar... | true |
f7b94c28ead8e891987669232ba25f1b048ca3e7 | Rust | igortoliveira/i2p-rust | /src/parsers.rs | UTF-8 | 1,493 | 2.6875 | 3 | [
"MIT"
] | permissive | use nom::{space, alphanumeric};
fn is_space(chr: char) -> bool {
chr == ' ' || chr == '\t'
}
fn is_next_line(chr: char) -> bool {
chr == '\n'
}
fn is_space_or_next_line(chr: char) -> bool {
is_space(chr) || is_next_line(chr)
}
named!(key_value <&str, (&str, &str)>,
chain!(
space? ... | true |
ae98efa22118e0ee19a7dac94a26fb0dc2ed3260 | Rust | yiannis/rust-in-motion | /course/U01/src/main.rs | UTF-8 | 3,347 | 3.828125 | 4 | [] | no_license | use std::io;
fn main() {
let one;
let two;
one = 1;
two = 2;
println!("Hello, {}{} world!", one, two);
if false {
m4_types();
m6_flow();
}
m8_structs();
}
fn m4_types() {
// *Bool*
let cold = true;
let hot = false;
if cold && !hot {
print... | true |
c8e41b935d6a4b2ef0c781e92e9e22943291bb63 | Rust | siku2/trunk | /src/config/manifest.rs | UTF-8 | 1,424 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use anyhow::{anyhow, Result};
use async_std::task::spawn_blocking;
use cargo_metadata::{Metadata, MetadataCommand, Package};
/// A wrapper around the cargo project's metadata.
#[derive(Clone, Debug)]
pub struct CargoMetadata {
/// The metadata parsed from the cargo project.
pub metadat... | true |
5e17ee8b556918af557cb37a6511eb0dbb6e0eb2 | Rust | andyyu2004/l-lang | /src/lc-ast/src/error.rs | UTF-8 | 137 | 2.5625 | 3 | [] | no_license | use thiserror::Error;
#[derive(Debug, Error)]
pub enum AstError {
#[error("functions must have a body")]
FunctionWithoutBody,
}
| true |
8fecc36d0d634e38e37400be4c1eeb1effd7376c | Rust | ibuystuff/differential-datalog | /rust/template/tests/interact_dump_error.rs | UTF-8 | 782 | 2.84375 | 3 | [
"MIT"
] | permissive | // Note that this file should only contain a single test. The test in
// here invokes itself and having multiple test running in parallel
// while that is happening is probably a bad idea.
extern crate cmd_parser;
use cmd_parser::Command;
mod common;
fn handler(command: Command, interactive: bool) -> (i32, bool) {
... | true |
5ff2b02edd19132c6fb29e240188ad548127fbb6 | Rust | wenewzhang/examples | /rand-demo/src/main.rs | UTF-8 | 1,050 | 4.0625 | 4 | [
"Apache-2.0"
] | permissive | // import commonly used items from the prelude:
use rand::prelude::*;
fn main() {
// We can use random() immediately. It can produce values of many common types:
let x: u8 = random();
println!("{}", x);
if random() { // generates a boolean
println!("Heads!");
}
// If we want to be a b... | true |
a3ae2d301d1cab6dbac5e4176adbc41d128cc0cc | Rust | will14smith/RustyPhotography | /photography-processing/src/thumbnail.rs | UTF-8 | 1,894 | 3 | 3 | [] | no_license | use std::sync::Arc;
use image::GenericImageView;
use crate::{ImageProcessor, ImageStorage, ImageData};
pub struct Thumbnail {
width: Option<u32>,
height: Option<u32>,
}
impl Thumbnail {
pub fn new(width: Option<u32>, height: Option<u32>) -> Thumbnail {
Thumbnail {
width,
he... | true |
4727f32fc46ec4c0f3c9ed233df31bf4c7b4ebc5 | Rust | hubris-lang/hubris | /src/hubris/core/binder.rs | UTF-8 | 2,680 | 3.3125 | 3 | [
"MIT"
] | permissive | use super::name::Name;
use super::term::Term;
use super::super::pretty::*;
#[derive(Debug, Copy, Clone, PartialEq, Hash, Eq)]
pub enum BindingMode {
Implicit,
Explicit
}
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
pub struct Binder {
pub name: Name,
pub ty: Box<Term>,
pub mode: BindingMode,
}
i... | true |
66a96816be2ed8600b1405013dab20ff9c4cf52d | Rust | admwrd/blogr | /notes/Old Code/old cache module Cachable trait code.rs | UTF-8 | 4,307 | 2.53125 | 3 | [
"MIT"
] | permissive |
/*
pub trait Cachable {
type Index;
type StateType;
// type Output;
fn new(Self::Index) -> Self;
// fn retrieve(self, State<Self::StateType>, Option<&DbConn>) -> Option<Self::Output>;
fn retrieve(self, State<Self::StateType>, Option<&DbConn>) -> Express;
}
pub struct SingleArticle(u32);
... | true |
08738972631c7e742f29ca03e7a300b3b30fd144 | Rust | l4l/flow | /flowrlib/src/input.rs | UTF-8 | 992 | 3.21875 | 3 | [
"MIT"
] | permissive | use serde_json::Value as JsonValue;
use std::mem::replace;
#[derive(Deserialize, Serialize)]
pub struct Input {
#[serde(default = "default_depth", skip_serializing_if = "is_default")]
depth: usize,
#[serde(skip)]
received: Vec<JsonValue>,
}
fn is_default(depth: &usize) -> bool {
*depth == default_... | true |
935d7e051dd82941668f256838030ec6bf00d019 | Rust | sgeos/InterviewQuestions | /rust/src/question/duplicate_encode.rs | UTF-8 | 2,213 | 3.734375 | 4 | [
"CC0-1.0"
] | permissive | // USAGE EXAMPLES:
//
// cargo run duplicate_encode
// cargo run duplicate_encode -s Civic
// cargo run duplicate_encode --string 悪魔の黒魔術
// STRING=")) @" cargo run duplicate_encode
//
// PROBLEM: Duplicate Encoder
// The goal of this exercise is to convert a string to a new string
// where each character in... | true |
468df6f9be20f3694b069c19b9e7e0d650344405 | Rust | alamont/rustray | /src/scenes/random_scene_light.rs | UTF-8 | 4,532 | 2.546875 | 3 | [] | no_license | use nalgebra::Vector3;
use rand::{thread_rng, Rng};
use hsl::HSL;
use std::sync::Arc;
use crate::hittable::{HittableList, Hittable};
use crate::camera::Camera;
use crate::material::{Dielectric, Lambertian, Metal, Environment, DiffuseLight};
use crate::sphere::Sphere;
use crate::aarect::{AARect, AARectType::*}... | true |
78679717d997f39d50a5591a8d551ddfe7823547 | Rust | Kamefrede/scabra-crm-backend | /src/routes/person.rs | UTF-8 | 2,250 | 2.65625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::{rocket_status_from_response, CustomJsonResponse, JsonWebToken};
use crate::db::CrmDbConn;
use crate::models::person::PersonEntity;
use crate::services::person;
use rocket::http::RawStr;
use rocket_contrib::json::Json;
#[get("/person")]
pub fn find_all(token: JsonWebToken, conn: CrmDbConn) -> CustomJsonResp... | true |
5cd01c33ebfdea611885301bcc4b5cafa41f42ea | Rust | IThawk/rust-project | /rust-master/src/test/ui/rcvr-borrowed-to-region.rs | UTF-8 | 566 | 3.203125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait get {
fn get(self) -> isize;
}
// Note: impl on a slice; we're checking that the pointers below
// correctly get borrowed to `&`. (similar to impling for `isize`, with
// `&self` instead of `self`.)
impl<'a> get for &'a isize {
fn get(... | true |
776bb5110c5530a1eabada2ad44db270662d4c0b | Rust | sb89/pushover | /src/requests/message/send_message.rs | UTF-8 | 7,613 | 3.03125 | 3 | [
"MIT"
] | permissive | use reqwest::Method;
use serde::Deserialize;
use url::Url;
use crate::requests::base::{add_optional_param, RawResponse, Request};
use crate::types::{Priority, Sound};
/// Send a message
///
/// Return type is [SendMessageResponse](struct.SendMessageResponse.html).
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub st... | true |
dc323423eef76ddd9eb5e377701edf24f2eb5c5c | Rust | PoorlyDefinedBehaviour/blockchain_2 | /src/account.rs | UTF-8 | 3,172 | 3.625 | 4 | [] | no_license | use crate::transaction::PublicKey;
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
pub struct Account {
accounts: HashSet<PublicKey>,
balances: HashMap<PublicKey, i64>,
}
#[derive(Debug, PartialEq)]
pub enum AccountError {
AccountNotFound(PublicKey),
}
impl Account {
pub fn new() -> Self {
Sel... | true |
a75bd880a2e77a71825dddb9004c6aa38d06f77d | Rust | ryanpbrewster/advent-of-code-2018 | /src/day1.rs | UTF-8 | 847 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
fn find_first_duplicate(xs: &[i32]) -> i32 {
let mut cur = 0;
let mut seen = HashSet::new();
loop {
for x in xs {
if seen.contains(&cur) {
return cur;
}
seen.insert(cur);
cur += x;
}
}
}
#[cf... | true |
fc4c8de3e8893f11651c4a55b560ffde1f43b854 | Rust | mygnu/blog-server | /src/app/like_handler.rs | UTF-8 | 2,745 | 2.953125 | 3 | [] | no_license | use actix::{Handler, Message};
use actix_web::{Error, HttpResponse, ResponseError, web::Data, web::Path};
use diesel::prelude::*;
use futures::Future;
use serde::Deserialize;
use crate::db::models::{AppData, DbExecutor, Post};
use super::errors::ServiceError;
#[derive(Debug, Default, Deserialize)]
pub struct AddLike... | true |
4230220b123258b76b614c2ffb3c97f3f715f885 | Rust | 4lDO2/tcp-channel | /examples/src/greeting-client.rs | UTF-8 | 946 | 2.875 | 3 | [
"MIT"
] | permissive | extern crate tcp_channel;
extern crate serde;
#[macro_use] extern crate serde_derive;
use std::net::TcpStream;
use tcp_channel::{ChannelSend, SenderBuilder, ChannelRecv, ReceiverBuilder};
mod common;
use common::{ClientToServer, ServerToClient};
fn main() {
let address = std::env::args().nth(1).unwrap();
le... | true |
cce1a1ec47f8df438c69408dd233fdad20234ef5 | Rust | beshaya/wavesuit | /base/src/color.rs | UTF-8 | 1,353 | 3.71875 | 4 | [
"MIT"
] | permissive | use std::ops;
use serde::{Serialize, Deserialize};
// A single RGB color.
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl Color {
// Construct a new color from a 24 bit RGB hex code.
pub fn new(hex_code: i32) -> Color {
let r... | true |
0db444bfa9bed7a6fd15a54464e16c3c46a19bca | Rust | shanegibbs/haumaru | /api/src/index/backup_set.rs | UTF-8 | 1,245 | 3.046875 | 3 | [] | no_license | use std::slice::Iter;
use Node;
pub struct BackupSetController {
current: Option<BackupSet>,
}
/// Holds all records of a backup set and then persists to the index on close.
pub struct BackupSet {
index: u64,
in_memory: Vec<Node>,
}
impl BackupSetController {
pub fn new() -> Self {
BackupSet... | true |
3d7c3a09592740009a44d1abf68dd1f5d9374fcb | Rust | ActorExpose/fuzzysearch | /src/utils.rs | UTF-8 | 4,057 | 2.625 | 3 | [] | no_license | use crate::models::DB;
use crate::types::*;
#[macro_export]
macro_rules! rate_limit {
($api_key:expr, $db:expr, $limit:tt, $group:expr) => {
rate_limit!($api_key, $db, $limit, $group, 1)
};
($api_key:expr, $db:expr, $limit:tt, $group:expr, $incr_by:expr) => {{
let api_key = match crate::mo... | true |
212b18eca09f6b889985363f747440846d44ef66 | Rust | swift-school/google-cloud-rs | /google-cloud/src/vision/likelihood.rs | UTF-8 | 1,389 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::convert::TryFrom;
use crate::vision::api;
/// Enum representing a likelihood.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Likelihood {
/// Unknown likelihood.
Unknown,
/// It is very unlikely.
VeryUnlikely,
/// It is unlikely.
Unlikely,
/// It is possible.
Possible,
... | true |
99d66389306372ee68c32a40a92d10dff51419ea | Rust | djeedai/druid | /druid/src/widget/progress_bar.rs | UTF-8 | 3,236 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 The Druid Authors.
//
// 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 or agreed... | true |
bdb3ca547840abaf0660b3f0e203bcde440319f0 | Rust | cpjreynolds/cube | /src/player.rs | UTF-8 | 3,674 | 2.625 | 3 | [] | no_license | use glium::backend::Facade;
use glium::{
Surface,
Program,
};
use glium::texture::SrgbTexture2d;
use glium::uniforms::{
Uniforms,
Sampler,
SamplerWrapFunction,
MinifySamplerFilter,
MagnifySamplerFilter,
};
use gel::{
Mat4,
Vec3,
Normalize,
Cross,
};
use config::PlayerParams;... | true |
47d353b59b73d496b6b59f4278212a40187566b2 | Rust | radicle-dev/bitcoins-rs | /bitcoins/src/builder.rs | UTF-8 | 6,838 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Implementations of the `TxBuilder` for Bitcoin transactions. This builder automatically
//! selects between Legacy and Witness transactions based on its inputs. The user may also specify
//! the desired type using `build_legacy` or `build_witness`.
//!
//! This means that the caller doesn't typically need to worry ... | true |
80af66b6947469bf96e44f76d6e95d1b9e79cbfd | Rust | JulianSchmid/etherparse | /etherparse/src/transport/tcp_header.rs | UTF-8 | 64,887 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use arrayvec::ArrayVec;
use crate::err::{ValueTooBigError, ValueType};
use super::super::*;
/// Deprecated use [`TcpHeader::MIN_LEN`] instead.
#[deprecated(since = "0.14.0", note = "Use `TcpHeader::MIN_LEN` instead")]
pub const TCP_MINIMUM_HEADER_SIZE: usize = 5 * 4;
/// Deprecated use [`TcpHeader::MIN_DATA_OFFSET`... | true |
d4be527b0dfcf083df6c47a7707a7d36e93d9de9 | Rust | grounzero/juniper | /tests/integration/tests/issue_925.rs | UTF-8 | 1,772 | 2.890625 | 3 | [
"BSD-2-Clause"
] | permissive | //! Checks that `FieldError` doesn't lose its extensions while being implicitly
//! converted from user defined subscription errors.
//! See [#925](https://github.com/graphql-rust/juniper/issues/925) for details.
use futures::stream::BoxStream;
use juniper::{
graphql_object, graphql_subscription, graphql_value, gr... | true |
f4b3c42287d706481d9adbae8b99264911416da5 | Rust | yoshihitoh/project-euler | /src/sudoku/printer.rs | UTF-8 | 2,552 | 3.0625 | 3 | [] | no_license | use crate::sudoku::board::ItemPosition;
use crate::sudoku::candidate::Candidate;
use crate::sudoku::{Board, Square};
use std::fmt::Debug;
pub trait Printer {
fn show(&self);
}
pub struct BoardPrinter<'a, T: Debug + Clone> {
board: &'a Board<T>,
}
impl<'a, T: Debug + Clone> BoardPrinter<'a, T> {
pub fn ne... | true |
cd9c9a1f5eda056ef02ecfef8df678ef2b0e6a71 | Rust | Aimnos/Dcoder-Challenges | /Easy/Rust/Exponentia!.rs | UTF-8 | 487 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::io;
fn main() {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
let n: i16 = buf.trim().parse().unwrap();
let mut power_of_two: f32 = 1.0;
if n < 0 {
print!("1.0");
for _ in n..0 {
power_of_two /= 2.0;
print!(",{}", power_of_tw... | true |
e849abe194d6d86ae30505b33ba1f943b9ad638a | Rust | OpenTrustGroup/fuchsia | /garnet/lib/rust/fidl_fuchsia_net_policy_ext/src/lib.rs | UTF-8 | 2,485 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use fidl_fuchsia_net_policy as fidl;
pub struct InterfaceInfo {
name: String,
properties: fidl_fuchsia_net_stack_ext::InterfaceProperties,
}
impl... | true |
fec83b3e8feb76e8fecbb2d5edb9460b6bfa977f | Rust | itsananderson/advent-of-code-2020 | /rust/src/bin/10-solution1.rs | UTF-8 | 1,049 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::env;
use std::fs;
use std::string::String;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
println!("Looking at file {}", filename);
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file");
let mut split... | true |
b47f7b3b9a9314fc90d59b3f42bf92b56120b6c0 | Rust | slyedoc/dolly | /src/transform.rs | UTF-8 | 805 | 3.578125 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use glam::{Quat, Vec3};
/// A thin wrapper over a `Vec3` and a `Quat`
#[derive(Clone, Copy)]
pub struct Transform {
pub position: Vec3,
pub rotation: Quat,
}
impl Transform {
///
pub fn from_position_rotation(position: Vec3, rotation: Quat) -> Self {
Self { position, rotation }
}
///
... | true |
3682e89ae03c7cd2a71bdef2d0acb8251cc9a56f | Rust | olback/autoplank | /src/plank.rs | UTF-8 | 1,703 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::process::{Command, Child, Stdio};
use sysinfo::{ProcessExt, SystemExt};
const DCONF_KEY: &str = "/net/launchpad/plank/docks/dock1/monitor";
pub struct Plank {
child: Child
}
impl Plank {
pub fn new() -> Self {
Self {
child: Self::spawn()
}
}
pub fn set_monitor(&... | true |
51be2b27e0a92ede4786ae9016b036182f1fa24c | Rust | fredlim/canvas | /packages/canvas/src-native/canvas-native/canvas-core/src/common/context/transformations.rs | UTF-8 | 1,889 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use std::f32::consts::PI;
use std::os::raw::c_float;
use skia_safe::{M44, Matrix, Point};
use crate::common::context::Context;
impl Context {
pub fn get_transform(&mut self) -> Matrix {
self.surface.canvas().local_to_device_as_3x3()
}
pub fn rotate(&mut self, angle: c_float) {
self.surfa... | true |
294df7fd0bac709e3b73cdc9910684ed672c25b0 | Rust | weaveworks-experiments/deployer | /src/instrumentation.rs | UTF-8 | 2,846 | 2.765625 | 3 | [] | no_license | extern crate iron;
extern crate prometheus;
extern crate router;
use std::time::{Instant, Duration};
use iron::prelude::*;
use iron::middleware::{AroundMiddleware, Handler};
use iron::mime::Mime;
use iron::status;
use prometheus::{Encoder, HistogramVec, TextEncoder};
/// Serve the /metrics page.
pub struct Prometheu... | true |
5470f279592037160162db553908e69d02c10323 | Rust | thePalindrome/aoc | /4/main.rs | UTF-8 | 2,351 | 3.4375 | 3 | [] | no_license | use std::collections::HashMap;
struct Guard {
total_time: u32,
id: usize,
minutes: [u32; 60],
}
fn find_max(arr: [u32; 60]) -> usize {
let mut minute = 0;
let mut acc = 0;
for i in 0..60 {
if arr[i] > acc {
acc = arr[i];
minute = i;
}
}
acc as us... | true |
aa60de90cfe77f260a125f04da582ef110cc18c3 | Rust | attilahorvath/advent-of-code-2017 | /day08/src/lib.rs | UTF-8 | 7,615 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::str::FromStr;
#[derive(Debug, PartialEq)]
pub enum Operation {
Inc(i32),
Dec(i32),
}
#[derive(Debug, PartialEq)]
pub enum Condition {
Gt(i32),
Lt(i32),
Ge(i32),
Le(i32),
Eq(i32),
Ne(i32),
}
#[derive(Debug, PartialEq)]
pub struct InstructionParse... | true |
a19231d3359537099d28c230782fedbf9fee6fe9 | Rust | dimforge/rapier | /src/data/pubsub.rs | UTF-8 | 5,264 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | //! Publish-subscribe mechanism for internal events.
use std::collections::VecDeque;
use std::marker::PhantomData;
/// A permanent subscription to a pub-sub queue.
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[derive(Clone)]
pub struct Subscription<T> {
// Position on the cursor array... | true |
3a343fd53bd966d81195c301dd53b13540c49053 | Rust | ilkkahanninen/boenthoe | /src/engine/transform.rs | UTF-8 | 978 | 2.875 | 3 | [
"MIT"
] | permissive | use cgmath::*;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Transform(Matrix4<f32>);
#[allow(dead_code)]
impl Transform {
pub fn new() -> Self {
Self(Matrix4::<f32>::identity())
}
pub fn translate(&self, x: f32, y: f32, z: f32) -> Self {
Self(self.0 * Matrix4::from_translation(Vect... | true |
74bff06382b16c1b0f7842a7c20e2423a4218a4a | Rust | dragonrider7225/advent_of_code_rust | /src/main.rs | UTF-8 | 1,364 | 3.03125 | 3 | [
"MIT"
] | permissive | //! An executable wrapper around (my) advent of code solutions.
use advent_of_code as aoc;
use clap::{App, Arg};
use std::io;
fn main() -> io::Result<()> {
let matches = App::new("Advent of Code")
.version("0.1.0")
.author("Kevin M. <dragonrider7225@gmail.com>")
.about("Runs one day of on... | true |
a997bb55a61e9d32c82a54c74d6be31bc619cd4a | Rust | Codadillo/l-system | /src/default_execution_rules.rs | UTF-8 | 7,219 | 3 | 3 | [] | no_license | use crate::{turtle::*, LSystemExecutor};
use serde::de::DeserializeOwned;
// I like the macro but hate this file
macro_rules! make_builder {
( $struct_name:ident, $( $function:ident, )+ ) => {
#[derive(Default)]
pub struct $struct_name {
$( pub $function: Option<String>, )+
}
... | true |
1e272a981d1436ed929304361c9accd982498b4b | Rust | antiochp/cuckoo-miner | /cuckoo-sys/plugins/common/lib.rs | UTF-8 | 18,056 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 The Grin Developers
//
// 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 or agree... | true |
621ff2c303d837a0af12e2aac70c16b49fccfb69 | Rust | amirhosseinab/inin | /src/lib.rs | UTF-8 | 2,418 | 3.609375 | 4 | [] | no_license | use std::convert::TryFrom;
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::ops::Deref;
#[derive(PartialOrd, PartialEq, Debug)]
pub struct NationalId(String);
impl TryFrom<&str> for NationalId {
type Error = NationalIdError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
l... | true |
bfb260ac067fd86e52052925cdad414d86d529b7 | Rust | youngspe/gramma | /src/lib.rs | UTF-8 | 2,642 | 3.28125 | 3 | [
"MIT"
] | permissive | //! A library for parsing type-safe context-free grammars with arbitrary lookahead.
//!
//! The `tokens!` and `grammar!` macros are used to define the language and
//! automatically implement parsers.
//!
//! Some tokens, like `Eof` and `StringToken` are provided in the `lex` module.
//!
//! ```
//! use gramma::{gramma... | true |
6a4c3e5dc1d864ccfe1367adb8c8c8b773c50632 | Rust | dalance/svlint | /src/syntaxrules/explicit_case_default.rs | UTF-8 | 1,787 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::config::ConfigOption;
use crate::linter::{SyntaxRule, SyntaxRuleResult};
use sv_parser::{unwrap_node, NodeEvent, RefNode, SyntaxTree};
#[derive(Default)]
pub struct ExplicitCaseDefault {
under_always_construct: bool,
}
impl SyntaxRule for ExplicitCaseDefault {
fn check(
&mut self,
_... | true |
035b497a44af0dc6fa4e190e7c4e2293e74c8d0a | Rust | pola-rs/polars | /crates/polars-core/src/chunked_array/ndarray.rs | UTF-8 | 9,067 | 2.9375 | 3 | [
"MIT"
] | permissive | use ndarray::prelude::*;
use rayon::prelude::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::prelude::*;
use crate::POOL;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum IndexOrder {
C,
#[default]
... | true |
030ad95dabaef5bac4ad08dd1be23009bfa36f1f | Rust | Atul9/lud | /src/question.rs | UTF-8 | 5,183 | 2.765625 | 3 | [] | no_license | use crate::utils::{byte_combine, extract_name};
use std::convert::{AsRef, From, TryFrom};
use std::error;
use std::fmt;
// TODO: inherit, in some way, the RRTypes
#[derive(Debug, Clone, Copy)]
pub enum QType {
A, // 1 a host address
NS, // 2 an authoritative name server
MD, // 3 a mail destinatio... | true |
253808d8493a18d875ab84cc4c5512ac11dd9e25 | Rust | Weibye/kepler | /crates/kepler/src/shapes/ellipse.rs | UTF-8 | 3,090 | 3.6875 | 4 | [] | no_license | use std::f32::consts::PI;
/// An ellipse defined in XY space with the center as (X,Y) = (0,0)
///
/// https://en.wikipedia.org/wiki/Conic_section#Conic_parameters
pub struct Ellipse {
semi_major: f32,
semi_minor: f32,
eccentricity: f32,
}
impl Ellipse {
// Constructors
pub fn from_major(semi_major... | true |
e2d7059b2aad541f2e3393016ac675ad1f9bf367 | Rust | JPTIZ/rust-poor-game | /game/src/battler.rs | UTF-8 | 3,078 | 3.609375 | 4 | [] | no_license | use std::collections::HashMap;
use std::cmp::{min, max};
use std::slice::Iter;
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub enum Status {
Dead,
Stun,
Poison,
}
impl Status {
pub fn values() -> Iter<'static, Status> {
static STATUS: [Status; 3] = [
Status::Dead,
Stat... | true |
f2b1e6ca72d99709945546aa396f6a8ce342bfc5 | Rust | SSMKittel/music_player | /src/playlist.rs | UTF-8 | 9,583 | 3.25 | 3 | [] | no_license |
use std::path::{Path, PathBuf};
use rand::Rng;
use rand::seq::SliceRandom;
use std::io;
use std::fs;
#[derive(Debug)]
pub struct Playlist {
// playlist songs as originally defined
songs: Vec<PathBuf>,
// current order to play files in (index of songs)
order: Vec<usize>,
// current song to play (... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.