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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c9e44b5801cf976e2496891b01dbc43ae65f22ee | Rust | janev94/POST-Implementation | /src/message_type.rs | UTF-8 | 276 | 2.859375 | 3 | [] | no_license | use message::Message;
#[derive(Serialize, Deserialize, Debug)]
pub enum MessageType<T> {
Message(T),
PartialMessage
}
impl <T> MessageType<T> {
pub fn unmask(&self) -> &str {
match self {
Message => return "message",
PartialMessage => return "partial",
}
}
}
| true |
f34709f09bad877fb10c623e4549d82616351b88 | Rust | khuston/abstreet | /map_model/src/edits/perma.rs | UTF-8 | 11,198 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use crate::edits::{EditCmd, EditIntersection, MapEdits};
use crate::raw::OriginalRoad;
use crate::{
osm, AccessRestrictions, ControlStopSign, Direction, IntersectionID, LaneID, LaneType, Map,
};
use abstutil::{deserialize_btreemap, serialize_btreemap};
use geom::{Speed, Time};
use serde::{Deserialize, Serialize};
u... | true |
64caa908ec79d0615f55adfd560b46f7af32ce6b | Rust | HeroicKatora/oxide-auth | /oxide-auth-axum/src/request.rs | UTF-8 | 4,080 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use oxide_auth::frontends::dev::{NormalizedParameter, QueryParameter, WebRequest};
use axum::{
async_trait,
extract::{Query, Form, FromRequest, FromRequestParts},
http::{header, request::Parts, Request},
body::HttpBody,
BoxError,
};
use crate::{OAuthResponse, WebError};
use std::borrow::Cow;
#[deri... | true |
af34a7a54610355e29e1754715ff310a88781102 | Rust | ehuss/raytracer | /src/vec3.rs | UTF-8 | 9,189 | 3.5625 | 4 | [] | no_license | use std::mem;
use std::ops::*;
use util::*;
use num_traits::Float;
pub use num_traits::Zero;
// TODO:
// - Hash?
// - operators (add/sub/etc) with references to Vec3.
//
// • std::convert:
// From/Into, AsRef/AsMut
// [S;3]
// (S, S, S)
//
pub enum Axis {
X,
Y,
Z,
}
#[derive(Copy, Clone, PartialEq, Parti... | true |
740fcd65f7f524a833da7a876fca72e055efd09b | Rust | elauffenburger/lyrical | /liblyrical/src/lyrics/simplifying.rs | UTF-8 | 2,578 | 3.390625 | 3 | [] | no_license | use super::*;
use regex;
#[derive(Debug)]
pub struct SimplifyingLyricsFetcher<T: LyricsFetcher> {
fetcher: T
}
impl<T: LyricsFetcher> SimplifyingLyricsFetcher<T> {
pub fn new(fetcher: T) -> Self {
SimplifyingLyricsFetcher { fetcher }
}
}
impl<T: LyricsFetcher> LyricsFetcher for SimplifyingLyrics... | true |
2e46b8689f05c444e8124e3207cb31cce4303110 | Rust | bjorn3/rsix | /src/process/mod.rs | UTF-8 | 945 | 2.5625 | 3 | [
"LLVM-exception",
"Apache-2.0",
"MIT"
] | permissive | //! Process-associated operations.
use crate::imp;
#[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id.
mod id;
mod sched;
#[cfg(not(target_os = "wasi"))]
pub use id::{getegid, geteuid, getgid, getpid, getppid, getuid};
pub use sched::sched_yield;
/// `EXIT_SUCCESS` for use with [`exit`].
///
/// [`exit... | true |
ece8b4f5a8593c960b5679b38deaa367f94c8c3e | Rust | mickjohn/motorsport_calendar_api | /src/bcrypt_helper.rs | UTF-8 | 1,193 | 2.921875 | 3 | [] | no_license | // arg parsing
extern crate clap;
// Bcrypt for password hashing
extern crate bcrypt;
use bcrypt::{hash, verify, DEFAULT_COST};
use clap::{App, Arg};
use std::io::{self, Read};
fn main() {
let matches = App::new("Motorsport calendar API - bcrypt helper")
.version("1.0")
.author("Michael A. <mickjohnashe@hotmail... | true |
c74af87513f2eda4fb9177b86ec4e5cdad5e1d1b | Rust | IThawk/rust-project | /rust-demo/iron/examples/around.rs | UTF-8 | 1,964 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate iron;
extern crate time;
use iron::prelude::*;
use iron::StatusCode;
use iron::{AroundMiddleware, Handler};
enum LoggerMode {
Silent,
Tiny,
Large,
}
struct Logger {
mode: LoggerMode,
}
struct LoggerHandler<H: Handler> {
logger: Logger,
handler: H,
}
impl Logger {
fn new(mod... | true |
ee8be2909122af00923d836a6a417430881ab54f | Rust | trinnguyen/gao | /src/semantic.rs | UTF-8 | 529 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::ast::{Ast, FunctionDecl, DataType};
pub struct Validator<'a> {
ast: &'a Ast
}
impl <'a> Validator<'a> {
pub fn new(ast: &'a Ast) -> Self {
Self {
ast
}
}
pub fn validate(&self) {
// make sure function overloads are distinct
// TODO
for ... | true |
f9c59928af72e4a81bea0fc5f9098bbab1ff82c9 | Rust | shaopeng8/akita | /src/mapper.rs | UTF-8 | 3,983 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::convert::TryFrom;
use mysql::{Conn, Transaction};
use crate::{AkitaError, UpdateWrapper, Wrapper, mysql::{PooledConn, R2d2Pool}};
pub enum ConnMut<'c, 't, 'tc> {
Mut(&'c mut Conn),
TxMut(&'t mut Transaction<'tc>),
Owned(Conn),
Pooled(mysql::PooledConn),
R2d2Polled(PooledConn)
}
impl Fr... | true |
35f5aece91c3a00760e6b78ca60675b27737c54a | Rust | ackintosh/sandbox | /rust/leetcode/src/battleships_in_a_board.rs | UTF-8 | 1,188 | 3.71875 | 4 | [] | no_license | // https://leetcode.com/problems/battleships-in-a-board/
struct Solution;
impl Solution {
pub fn count_battleships(board: Vec<Vec<char>>) -> i32 {
let mut answer = 0;
let num_column = board[0].len();
let num_row = board.len();
for r in 0..num_row {
for c in 0..num_col... | true |
06bd124660258275793a99721d2267cf6fe1576d | Rust | estelendur/budget-app | /src/controllers/category.rs | UTF-8 | 1,346 | 2.640625 | 3 | [] | no_license | use rocket::request::LenientForm;
use rocket::response::Redirect;
use rocket_contrib::templates::Template;
use crate::context::Context;
use crate::error::Error;
use crate::models::category::*;
use crate::models::form_values::FormUuid;
use crate::MainDbConn;
use diesel::Connection;
#[get("/categories")]
pub fn categor... | true |
9a2e77c5862ad347a5ac44a787074efb046ea939 | Rust | cutebbb/boundary-check | /src/main.rs | UTF-8 | 1,610 | 2.828125 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use test::Bencher;
fn main() {
}
const BENCH_LEN:usize = 100000;
fn mock_array() -> [i32;BENCH_LEN]{
let a = [1;BENCH_LEN];
a
}
fn mock_vec() -> Vec<i32>{
let vec = vec![1;BENCH_LEN];
vec
}
#[bench]
fn array_unchecked_sum(b : &mut Bencher){
let a = mock_arr... | true |
81358819334242f02e87c4650b6d935240e7b7a0 | Rust | Lomig/Exercism | /rust/armstrong-numbers/src/lib.rs | UTF-8 | 329 | 3.453125 | 3 | [] | no_license | pub fn is_armstrong_number(num: u32) -> bool {
let digits = to_digits(&num);
let power = digits.len() as u32;
num == digits.iter().map(|i| i.pow(power)).sum()
}
fn to_digits(num: &u32) -> Vec<u32> {
num.to_string()
.chars()
.map(|character| character.to_digit(10).unwrap())
.col... | true |
2ce8b6fe12929b61443159b83777f9eb5879a94a | Rust | henculus/blog-rust | /src/users_view.rs | UTF-8 | 1,850 | 2.515625 | 3 | [
"MIT"
] | permissive | use diesel::prelude::*;
use rocket::http::{Cookie, Cookies, SameSite};
use rocket_contrib::json::Json;
use crate::{Database, Id};
use crate::error::Error;
use crate::schema::users::dsl::*;
use crate::user::{Token, User, UserData};
use crate::ViewResult;
#[get("/users")]
pub fn get_users(conn: Database) -> ViewResult<... | true |
4896fbd7cd10124b7ab92da307666faff81c9046 | Rust | rust-malaysia/rust-malaysia.github.io | /assets/2019/09/11/1-tests/tests/src/lib.rs | UTF-8 | 1,048 | 3.109375 | 3 | [] | no_license | #![feature(test)]
extern crate test;
#[test]
fn test_add() {
assert_eq!(add(1, 1), 2);
assert_eq!(add(1, 1), 3);
}
#[test]
#[ignore]
fn test_huh() {
assert_eq!(add(1, 1), 3);
}
#[test]
#[ignore]
fn test_rust_my() {
assert!("rust malaysia".contains("rust"));
}
/// Divide x by y.
///
/// # Examples
/... | true |
d8d8f9efaa2970ce318134ccc47b7c94fe409516 | Rust | kurtlawrence/kserd | /src/nav/mod.rs | UTF-8 | 3,489 | 3.703125 | 4 | [
"MIT"
] | permissive | //! Navigate around a [`Kserd`].
//!
//! # Reading
//! It is cumbersome when trying to loop through a nested `Kserd` structure. There is a [`Navigator`]
//! structure that can be used that flattens the tree structure when constructed to make use of
//! indexing and iterators throughout the `Kserd`.
//!
//! [`Kserd`]: c... | true |
91ea710846058993438d55d2edc6394dff81af3b | Rust | iho/qdrant | /lib/collection/src/operations/config_diff.rs | UTF-8 | 5,132 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::collection_builder::optimizers_builder::OptimizersConfig;
use crate::config::WalConfig;
use crate::operations::types::CollectionResult;
use merge::Merge;
use schemars::JsonSchema;
use segment::types::HnswConfig;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
// Structures for partial ... | true |
e9d88c8bb9740eed784063f0a76231eb1e4c4b78 | Rust | little-dude/xain-fl | /rust/xaynet-client/src/mobile_client/participant/mod.rs | UTF-8 | 2,274 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | //! Provides the logic and functionality for a participant of the PET protocol.
//!
//! See the [client module] documentation since this is a private module anyways.
//!
//! [client module]: ../index.html
use derive_more::From;
use xaynet_core::{
crypto::SigningKeyPair,
mask::MaskConfig,
message::Message,
... | true |
0f99245d023f2a845930ac68cbe32c86fcca3bb1 | Rust | wking/cincinnati | /vendor/rsa/src/key.rs | UTF-8 | 31,476 | 2.609375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use num_bigint::traits::ModInverse;
use num_bigint::Sign::Plus;
use num_bigint::{BigInt, BigUint};
use num_traits::{FromPrimitive, One};
use rand::{rngs::ThreadRng, Rng};
#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
use std::ops::Deref;
use zeroize::Zeroize;
use crate::algorithms::generate_mult... | true |
db98a45539c6fdbeaa5083b51455e5e23f97bbce | Rust | dlukes/rocket-latam-workshop | /9-cfp/src/talk.rs | UTF-8 | 3,466 | 2.875 | 3 | [] | no_license | use std::io;
use diesel;
use diesel::backend::Backend;
use diesel::deserialize::{self, FromSql};
use diesel::prelude::*;
use diesel::result::Error;
use diesel::serialize::{self, Output, ToSql};
use diesel::sql_types::Integer;
use rocket::FromFormValue;
use {Admin, DbConn};
use schema::talks;
use user::User;
/// Talk... | true |
65fbcde83af21280e81416cdaeaa4b018c2316b7 | Rust | toni1606/monty_hall | /src/data_structures/contestant.rs | UTF-8 | 391 | 3.140625 | 3 | [] | no_license | pub struct Contestant {
choice: usize,
changes_door: bool
}
impl Contestant {
pub fn new_alice() -> Contestant {
Contestant {
choice: 1,
changes_door: false
}
}
pub fn new_bob() -> Contestant {
Contestant {
choice: 1,
changes_door: true
}
}
pub fn get_choice(&self) -> usize {
self.choice... | true |
3e654bf6527239f22f4f0f46b427577f43f42d53 | Rust | laopo001/leetcode-rust | /src/word_pattern/mod.rs | UTF-8 | 1,050 | 3.421875 | 3 | [] | no_license | struct Solution;
use std::collections::HashMap;
impl Solution {
pub fn word_pattern(pattern: String, str: String) -> bool {
let mut map: HashMap<char, &str> = HashMap::new();
let mut map2: HashMap<&str, char> = HashMap::new();
let res = true;
let len = pattern.len();
... | true |
d7f682c2336cb7ab584e351b65a44e8d82350ea1 | Rust | fyang93/rust-leetcode | /src/p0051_n_queens.rs | UTF-8 | 4,243 | 3.171875 | 3 | [] | no_license | // bitmask: 记录下一行哪些位置被占用
pub fn solve_n_queens(n: i32) -> Vec<Vec<String>> {
let n = n as usize;
let mut result = vec![];
let mut solutions = vec![];
solve(&mut result, &mut solutions, 0, 0, 0, 0, n);
result
}
fn solve(result: &mut Vec<Vec<String>>, solutions: &mut Vec<usize>, mask_col: i32, mask_4... | true |
3c8a8a7fb4f68147fcece314a9ed465bcf53a456 | Rust | netvl/xml-rs | /src/writer/config.rs | UTF-8 | 6,269 | 3.265625 | 3 | [
"MIT"
] | permissive | //! Contains emitter configuration structure.
use std::borrow::Cow;
use std::io::Write;
use crate::writer::EventWriter;
/// Emitter configuration structure.
///
/// This structure contains various options which control XML document emitter behavior.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct EmitterConfig {
... | true |
9bd9a09242820edb6fe85e1983b5cae7f7965ec3 | Rust | SamuelSchlesinger/rust-proto | /src/context.rs | UTF-8 | 1,936 | 3.609375 | 4 | [] | no_license | use log::debug;
use crate::config::Config;
use crate::error::Error;
/// The dynamic context that the program needs to run. This
/// might include client handles to other programs, a pool
/// of database connections, a logging service, or whatever
/// else. Sadly, it also includes some global variables that
/// we set... | true |
f1732bbae376c0d2c984647371c33d4859542b7a | Rust | nickolay/git-interactive-rebase-tool | /src/runtime/src/installer.rs | UTF-8 | 2,638 | 3.203125 | 3 | [
"BSD-3-Clause",
"GPL-3.0-only",
"Apache-2.0",
"BSD-2-Clause",
"GPL-3.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later"
] | permissive | use std::{
cell::RefCell,
collections::HashMap,
fmt::{Debug, Formatter},
};
use crossbeam_channel::Sender;
use crate::{Notifier, Status, ThreadStatuses};
/// A thread installer that is passed to a `Threadable` when installing the threads into the `Runtime`
pub struct Installer {
sender: Sender<(String, Status)>,... | true |
c1b5cdbce263bf23e1ec1a2df8534fe5c211d047 | Rust | saper150/editor | /src/scroll.rs | UTF-8 | 1,861 | 3.03125 | 3 | [] | no_license | fn lerp(lower: f32, upper: f32, by: f32) -> f32 {
lower * (1.0 - by) + upper * by
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct PointF {
pub x: f32,
pub y: f32,
}
#[derive(Debug)]
pub struct Scroll {
pub base_scroll: PointF,
pub current_scroll: PointF,
pub target_scroll: PointF,
pu... | true |
cba7038776c6e27be5bfc545145b1e917c887e15 | Rust | marinewater/polyline-rust | /src/chunks.rs | UTF-8 | 2,540 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::convert::TryFrom;
pub struct Chunks {
chunks: Vec<u32>
}
impl Chunks {
pub fn new() -> Chunks {
return Chunks {
chunks: vec![]
};
}
/// splices an integer into chunks
pub fn parse(&mut self, element: u32) {
self.slice(element);
}
/// converts ... | true |
92c0e210d331161fa20cc9bb3f2840e0a8ba8bb8 | Rust | bjornomy/rust-oop18 | /src/lib/util/mod.rs | UTF-8 | 367 | 2.734375 | 3 | [] | no_license | pub mod read;
pub mod write;
pub fn valid_name(name: &str) -> bool {
name.chars().all(char::is_alphabetic)
}
pub fn valid_number(number: &str) -> bool {
number.chars().all(char::is_numeric)
}
pub fn valid_address(_address: &str) -> bool {
true
}
pub fn eq_ignore_case(left: &str, right: &str) -> bool {
... | true |
6c83192526d5a4b963d12c259a4fc67b1f02f46f | Rust | RSSchermer/ARWA | /arwa/src/scroll/scroll_behavior.rs | UTF-8 | 2,252 | 2.65625 | 3 | [
"MIT"
] | permissive | #[derive(Clone, Copy, PartialEq, Eq)]
pub enum ScrollBehavior {
Auto,
Smooth,
}
impl Default for ScrollBehavior {
fn default() -> Self {
ScrollBehavior::Auto
}
}
impl From<ScrollBehavior> for web_sys::ScrollBehavior {
fn from(scroll_behaviour: ScrollBehavior) -> web_sys::ScrollBehavior {
... | true |
4cc0382e249e2187c0eb7a4c64e5540fb48e99c2 | Rust | jonathan-lemos/meta | /src/os/unix/xattr.rs | UTF-8 | 908 | 2.578125 | 3 | [] | no_license | use crate::filesystem::xattr::XattrFunctions;
use std::path::Path;
use std::iter::{FromIterator, Map};
use std::io::{Error, Result, ErrorKind};
use xattr::XAttrs;
use std::ffi::OsString;
pub struct UnixXattr();
type Iter = Map<XAttrs, fn(OsString) -> core::result::Result<String, Error>>;
impl XattrFunctions<Iter> fo... | true |
280d40eec7340c78fd394d7427861224daf7d8c5 | Rust | zeta1999/poi | /src/lib.rs | UTF-8 | 38,200 | 3.78125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | #![deny(missing_docs)]
//! # Poi
//! a pragmatic point-free theorem prover assistant
//!
//! ```text
//! === Poi Reduce 0.4 ===
//! Type `help` for more information.
//! > and[not]
//! and[not]
//! or ( and[not] => or )
//! ```
//!
//! To run Poi Reduce from your Terminal, type:
//!
//! ```text
//! cargo install --e... | true |
b67daebaf8b8a9767af0e160190530354bad6441 | Rust | pioneers/hibike_packet | /src/parsing.rs | UTF-8 | 6,735 | 2.84375 | 3 | [] | no_license | //! Parsing messages into device data.
extern crate serde_json;
extern crate byteorder;
use ::utils::{value_error, objectify};
use std::collections::HashMap;
use std::sync::RwLock;
use std::io::Cursor;
use std::io;
use cpython::{Python, PyResult, PyObject, PyBytes, PyList, PyErr, ToPyObject, exc};
use self::byteord... | true |
3c2c0f0b6144fbfd5cda877d2c3b188082e91628 | Rust | parallaxsecond/rust-tss-esapi | /tss-esapi/src/structures/lists/ecc_curves.rs | UTF-8 | 3,449 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2022 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use crate::constants::ecc::EccCurveIdentifier;
use crate::tss2_esys::{TPM2_ECC_CURVE, TPML_ECC_CURVE};
use crate::{Error, Result, WrapperErrorKind};
use log::error;
use std::convert::TryFrom;
use std::ops::Deref;
/// A list of... | true |
28eb3cbe53f849d35ed0dc19d810a1af85ee5c1a | Rust | JochenDeprez/MarsIT-Rust | /2-route_parameters/src/main.rs | UTF-8 | 538 | 2.625 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[get("/user/<name>")]
fn url_parameter(name: String) -> String {
format!("Welcome to the application {}", name)
}
#[get("/user?<name>&<salutation>")]
fn url_query_parameter(name: String, salutation: Option<String>) -> String {
mat... | true |
a5949f1743b86350f9aca0876f0e5cd57c3cbd71 | Rust | gimli-rs/object | /src/read/elf/comdat.rs | UTF-8 | 4,994 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::fmt::Debug;
use core::{iter, slice, str};
use crate::elf;
use crate::endian::{Endianness, U32Bytes};
use crate::read::{self, ComdatKind, ObjectComdat, ReadError, ReadRef, SectionIndex, SymbolIndex};
use super::{ElfFile, FileHeader, SectionHeader, Sym};
/// An iterator over the COMDAT section groups of an `... | true |
01c8250a2e17a3eac75ca50ec2c9cd16c2895366 | Rust | lucklove/ifeedback_class_search | /src/main.rs | UTF-8 | 12,981 | 2.90625 | 3 | [] | no_license | extern crate hyper;
extern crate rustc_serialize;
extern crate mysql;
extern crate url;
use std::io::Read;
use std::collections::HashMap;
use hyper::Client;
use hyper::method::Method;
use hyper::server::{Handler, Server, Request, Response};
use rustc_serialize::json;
use mysql as my;
use hyper::uri::RequestUri::Absolu... | true |
ed39090bb95bc4bffa852baec267e10e7ba89cbc | Rust | RepDota/bk | /src/main.rs | UTF-8 | 11,749 | 2.578125 | 3 | [
"MIT"
] | permissive | use crossterm::{
cursor,
event::{self, DisableMouseCapture, EnableMouseCapture, Event},
queue,
style::{self, Color::Rgb, Colors, Print, SetColors},
terminal,
};
use serde::{Deserialize, Serialize};
use std::{
cmp::min,
collections::HashMap,
env, fs,
io::{self, Write},
iter,
p... | true |
3ac9523146e799372798133030a179cc8acf6381 | Rust | Patryk27/janet | /libs/interface/src/atoms/date_time/atom.rs | UTF-8 | 7,997 | 3.53125 | 4 | [
"MIT"
] | permissive | use crate::{Atom, Date, DateTime, Time};
use nom::branch::alt;
use nom::character::complete::char;
use nom::{IResult, Parser};
impl Atom for DateTime {
fn parse(i: &str) -> IResult<&str, Self> {
let date_and_time = Date::parse
.and(char(' '))
.and(Time::parse)
.map(|((da... | true |
ae4661b8e50684d6219d6fbed333b1fbb04fb706 | Rust | muzudho/casual-logger-on-rust | /examples/toml_cover.rs | UTF-8 | 9,439 | 2.796875 | 3 | [
"MIT"
] | permissive | //! Toml cover check.
//! [TOML v1.0.0-rc.1](https://toml.io/en/v1.0.0-rc.1)
//!
//! Run: `cargo run --example toml_cover`.
use casual_logger::{ArrayOfTable, Log, Table};
fn main() {
Log::set_file_name("toml-cover");
Log::set_retention_days(-1);
Log::remove_old_logs();
// Same key test.
Log::info... | true |
c924eeeada1492a241df84a1e0884d073a55b2b0 | Rust | TerminalStudio/nativeshell | /nativeshell/src/codec/message_channel.rs | UTF-8 | 4,061 | 2.65625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::rc::Rc;
use crate::{
shell::{BinaryMessengerReply, Context, EngineHandle, EngineManager},
Error, Result,
};
use super::MessageCodec;
pub struct MessageChannel<V>
where
V: 'static,
{
context: Rc<Context>,
sender: MessageSender<V>,
}
impl<V> MessageChannel<V> {
pub fn new<F>(
... | true |
36de5279138fba2fafa70654da337b408cb1146e | Rust | killercup/sleep-parser | /src/header.rs | UTF-8 | 6,404 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate byteorder;
use self::byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use failure::Error;
use std::io::Cursor;
/// Algorithm used for hashing the data.
#[derive(Debug, PartialEq)]
pub enum HashType {
/// [BLAKE2b](https://blake2.net/) hashing algorithm.
BLAKE2b,
/// [Ed25519](https://ed25519.cr... | true |
687aa422f49a521f4f9ff39931f487422f8f1fff | Rust | Frozen/rusttest | /src/main.rs | UTF-8 | 2,431 | 2.890625 | 3 | [] | no_license |
#[macro_use]
extern crate structopt;
extern crate postgres;
extern crate chrono;
use chrono::{Duration};
use chrono::naive::NaiveDateTime;
use std::collections::HashMap;
use postgres::{Connection, TlsMode};
//use std::env;
use structopt::StructOpt;
/// A basic example
#[derive(StructOpt, Debug)]
#[structopt(name ... | true |
bc7c0d141a86a566c21edbcfa4de5e82a9fef602 | Rust | steveklabnik/multibuilder | /src/git.rs | UTF-8 | 4,273 | 3.1875 | 3 | [] | no_license | use std::str;
use std::io::fs::PathExtensions;
use std::io::process::{Command, ProcessOutput};
/// Represents a git repository.
#[deriving(Clone)]
pub struct Repo {
pub path: Path
}
#[deriving(Clone, Encodable, Decodable, Show)]
pub struct RemoteBranch {
pub name: String,
pub branch: String
}
/// Represe... | true |
50272d0f71501c089ccf5d6e868c372a9f190937 | Rust | rchaser53/rust-jvm | /src/java_class/custom.rs | UTF-8 | 11,699 | 2.578125 | 3 | [] | no_license | use crate::attribute::code::Code;
use crate::attribute::defs::Attribute;
use crate::constant::ConstantPool;
use crate::field::{Field, FieldDescriptor};
use crate::method::{Method, MethodAccessFlag};
use crate::string_pool::StringPool;
use crate::utils::*;
use std::fmt;
#[derive(Debug)]
pub struct Interface(usize);
#[... | true |
a4ca8a7ec07beaa25c16958466764ce6c9429ead | Rust | lucasavila00/thop | /src/parser/solution.rs | UTF-8 | 2,114 | 3.4375 | 3 | [] | no_license | use super::SolutionFile;
use utils;
impl PartialEq for SolutionFile {
fn eq(&self, other: &SolutionFile) -> bool {
utils::vec_compare(&self.route, &other.route)
&& utils::vec_compare(&self.items, &other.items)
}
}
fn parse_int_list(source: &str) -> Vec<u32> {
let end = source.len() - 1... | true |
f960cf319b1f156167d2d89890af246b693031de | Rust | andrew-serrano/rust | /list_of_integers.rs | UTF-8 | 2,217 | 3.8125 | 4 | [] | no_license | /*
Given a list of integers, use a vector and return the mean (the average value), median (when sorted, the value in the middle position), and mode (the value that occurs most often; a hash map will be helpful here) of the list.
*/
use std::collections::HashMap;
fn main() {
let mut list_of_ints = vec![50, 50... | true |
19fbbc5e3ce9ecad9b799a80971e14fdde729952 | Rust | cottonguard/kyopro-rust | /src/libs/other/coord_comp.rs | UTF-8 | 2,307 | 3.5625 | 4 | [] | no_license | #[derive(Clone, Debug)]
pub struct CoordinateComp<T>(Vec<T>);
impl<T: Ord> CoordinateComp<T> {
pub fn position(&self, key: &T) -> Option<usize> {
let i = self.lower_bound(key);
if self.get(i) == Some(key) {
Some(i)
} else {
None
}
}
pub fn lower_bound(... | true |
ddaf1247753724663cb745f0623bacba7268d5b6 | Rust | naamancurtis/suaide | /src/domain/timeframe.rs | UTF-8 | 623 | 3.359375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use std::convert::From;
#[derive(Debug, Serialize, Deserialize, Eq, Ord, PartialOrd, PartialEq, Hash, Copy, Clone)]
pub enum Timeframe {
Today,
Yesterday,
Week,
LastWeek,
Month,
}
impl From<&str> for Timeframe {
fn from(s: &str) -> Self {
match s {
... | true |
aff31094ad5957267223d680856782885f63e9ec | Rust | sivadeilra/unsafety | /src/lib.rs | UTF-8 | 9,398 | 3.875 | 4 | [
"MIT"
] | permissive | //! Provides annotations for describing and auditing usages of `unsafe` code in Rust.
//!
//! This crate has no effect on the compilation or runtime behavior of Rust code. Its
//! purpose is to allow developers to annotate Rust code with information about _why_
//! unsafe code is used, and to enable automated tools for... | true |
d7351d7181de23e69a9908860a9a7e11ecb9c785 | Rust | ChinX/myrust | /map_demo/src/main.rs | UTF-8 | 1,413 | 3.890625 | 4 | [] | no_license | use std::collections::HashMap;
fn main() {
println!("Hello, world!");
let mut scores = HashMap::new();
// 哈希 map 是同质的:所有的键必须是相同类型,值也 必须都是相同类型
scores.insert("blue", 10);
scores.insert("yello", 20);
// scores.insert(String::from("red"), 20); // xpected `&str`, found struct `std::string::String`
... | true |
acb671c7dc8ff24dd52dd878fb0194de94d11bc4 | Rust | udoprog/genco | /src/lang/c.rs | UTF-8 | 3,731 | 3.453125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Specialization for C code generation.
use crate as genco;
use crate::fmt;
use crate::quote_in;
use crate::tokens::{quoted, ItemStr};
use std::collections::BTreeSet;
use std::fmt::Write as _;
/// Tokens container specialization for C.
pub type Tokens = crate::Tokens<C>;
impl_lang! {
/// Language specializatio... | true |
8478490a63d9fbed4c905fb2bb7c46d0c29df2d8 | Rust | JoNil/pi-finder | /src/main.rs | UTF-8 | 5,239 | 2.65625 | 3 | [] | no_license | use gtk::{
self,
gdk::EventMask,
gio,
glib::timeout_add,
prelude::{
ApplicationExt, ApplicationExtManual, BoxExt, ContainerExt, Continue, EntryExt,
GtkWindowExt, LabelExt, WidgetExt, WidgetExtManual,
},
Inhibit,
};
use items::Item;
use once_cell::sync::Lazy;
use std::{
ce... | true |
3ff997a8bdcb891c17b6de7742c4919b82c8c2cd | Rust | dennisss/dacha | /pkg/math/src/big/secure/montgomery.rs | UTF-8 | 6,527 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | use crate::big::secure::modulo::SecureModulo;
use crate::big::secure::uint::*;
use crate::integer::Integer;
/// Context for performing modular arithmetic with a fixed modulus.
///
/// This assumes that the modulus is an odd number. This makes it easy to choose
/// a value R which is coprime to the modulus in constant ... | true |
1586a586dae26bb5a040b067d65b7d2dfe7b6bad | Rust | AaronShah2/SGDA_Game_Jam_Proj | /src/states/loading.rs | UTF-8 | 2,201 | 2.546875 | 3 | [] | no_license | use crate::{
resources::{
audio::initialize_audio, prefabs::initialize_prefabs, sprites::initialize_sprite_sheets,
},
states::MenuState,
};
use amethyst::{assets::ProgressCounter, prelude::*};
#[derive(Default)]
pub struct LoadingState {
counters: Vec<ProgressCounter>,
}
impl SimpleState for ... | true |
ea34d632f6b60a3cd268794b9f7b678e1fccd1da | Rust | dermesser/yup-oauth2 | /examples/custom_client.rs | UTF-8 | 2,323 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! This example demonstrates how to use the same connection pool for both obtaining the tokens and
//! using the API that these tokens authorize. In most cases e.g. obtaining the service account key
//! will already establish a keep-alive http connection, so the succeeding API call should be much
//! faster.
//!
//! I... | true |
8d9c415a9b11ad4113b8458fd2a82c4341292495 | Rust | harryfei/librice | /src/stun/pacer.rs | UTF-8 | 5,043 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or di... | true |
d51ebf82ee947102bdc41c4ecf63ed55e5288dbc | Rust | blockspacer/fuchsia | /src/media/codecs/stress/src/elementary_stream.rs | UTF-8 | 2,321 | 2.671875 | 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_media::FormatDetails;
pub trait ElementaryStream {
fn format_details(&self, version_ordinal: u64) -> FormatDetails;
/// Whether ... | true |
69210b0badde3eb819da7889445623a021b9f728 | Rust | CrackerCat/linux-vm | /src/mm/paging.rs | UTF-8 | 12,211 | 2.921875 | 3 | [
"MIT"
] | permissive | use crate::vm::*;
use super::phys_allocator::PhysAllocator;
const PAGE_MASK: u64 = 0x000F_FFFF_FFFF_F000;
const PAGE_PRESENT: u64 = 1;
const PAGE_WRITE: u64 = 1 << 1;
const PAGE_USER: u64 = 1 << 2;
const PAGE_SIZE: u64 = 1 << 7;
const PAGE_XD: u64 = 1 << 63;
const HIERARCHY_DEPTH: u64... | true |
2f9dbb9c71e7a760b393ce214a5f0e9fb679dafe | Rust | DeltaManiac/roux.rs | /src/responses/mod.rs | UTF-8 | 967 | 3.421875 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
/// Basic structure of a Reddit response.
/// See: https://github.com/reddit-archive/reddit/wiki/JSON
#[derive(Deserialize, Debug)]
pub struct BasicThing<T> {
/// An identifier that specifies the type of object that this is.
pub kind: String,
/// The data contained by this struct. T... | true |
1309d3ca8917f8442d590b8c9c12d94079e25721 | Rust | csixteen/LeetCode | /Problems/Algorithms/src/Rust/sort-colors/src/lib.rs | UTF-8 | 2,664 | 3.640625 | 4 | [
"MIT"
] | permissive | // https://leetcode.com/problems/sort-colors/
#![allow(dead_code)]
struct Solution;
const COLOR_A: i32 = 0;
const COLOR_B: i32 = 1;
const COLOR_C: i32 = 2;
impl Solution {
pub fn sort_colors(nums: &mut Vec<i32>) {
let mut a_counter: usize = 0;
let mut b_counter: usize = 0;
let mut c_coun... | true |
33cf90e948b1b99c99f2f9bc35bef68d0c9303c4 | Rust | youngqqcn/RustNotes | /rust-by-example/9-函数/5-闭包作为函数输入参数.rs | UTF-8 | 1,509 | 3.53125 | 4 | [] | no_license | // Author: yqq
// Date: 2022-11-07 22:43:56
// Description: 闭包作为函数输入参数
/*
Fn:表示捕获方式为通过引用(&T)的闭包
FnMut:表示捕获方式为通过可变引用(&mut T)的闭包
FnOnce:表示捕获方式为通过值(T)的闭包
在满足使用需求的情况下, 编译器会使用权限最小的?
*/
// 该函数将闭包作为参数并调用它。
fn apply<F>(f: F) where F: FnOnce() { // 闭包没有输入值和返回值。
// ^ 试一试:将 `FnOnce` 换成 `Fn` 或 `FnMut`。
f();
}
// 输... | true |
4f8b4aec60e0f8dc5fe14f3a20f22c98f94dac59 | Rust | last-Battle/do-think | /rust-main/rust-2021-3-5/Advanced/day16_cargo/open_cargo2_crypto/src/main.rs | UTF-8 | 307 | 2.703125 | 3 | [] | no_license | extern crate crypto;
use crypto::digest::Digest;
use crypto::sha3::Sha3;
fn main() {
// 1. create hash obj
let mut hasher = Sha3::sha3_256();
// 2. input string to conv
hasher.input_str("hello world!");
// 3. get hash value
let r = hasher.result_str();
println!("r: {}", r);
}
| true |
59c8ae49fd80647607a8bc8acafab8b301d04d15 | Rust | mkl-/wsdclient | /src/lib.rs | UTF-8 | 1,708 | 2.578125 | 3 | [
"MIT"
] | permissive | #![feature(custom_attribute)]
#![feature(plugin)]
//! Crate for working with [https://www.websequencediagrams.com/](https://www.websequencediagrams.com/)
//! public [RESTful API](https://www.websequencediagrams.com/embedding.html)
//! This service allows to create sequence diagrams from simple text.
//! Note: this lib... | true |
04650ddbb4e29265b67cf1a538a040c55379c3e6 | Rust | sharksforarms/deku | /src/impls/hashmap.rs | UTF-8 | 12,323 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{ctx::*, DekuError, DekuRead, DekuWrite};
use bitvec::prelude::*;
use std::collections::HashMap;
use std::hash::{BuildHasher, Hash};
/// Read `K, V`s into a hashmap until a given predicate returns true
/// * `capacity` - an optional capacity to pre-allocate the hashmap with
/// * `ctx` - The context require... | true |
6896200b26a28183abef81c9f7d9e0f86ff205ec | Rust | spacemeshos/svm | /crates/host/types/src/template/code.rs | UTF-8 | 2,269 | 3.375 | 3 | [
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | use crate::{GasMode, SectionKind, SectionLike};
const EXEC_FLAGS: u64 = 0x01;
/// Contains the `Template` Code along other properties
#[derive(Debug, Clone, PartialEq)]
pub struct CodeSection {
kind: CodeKind,
svm_version: u32,
code: Vec<u8>,
flags: u64,
gas_mode: GasMode,
}
impl CodeSection {
... | true |
73485d76b247903697181b52eab6a2ebe2365aca | Rust | dtantsur/rust-openstack | /src/compute/block_device_mapping.rs | UTF-8 | 8,118 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018-2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// 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 |
8d14606bac4f2df821f469812c46579b5bd34569 | Rust | lakshayg/iss-notify | /src/blinkt_compat/blinkt_real.rs | UTF-8 | 1,113 | 2.859375 | 3 | [] | no_license | extern crate blinkt;
use self::blinkt::Blinkt;
use super::blinkt_common::{BlinktT, Result};
use log::error;
pub struct BlinktReal {
blinkt: Blinkt,
}
impl BlinktReal {
pub fn new() -> Result<Self> {
Blinkt::new()
.map(|blinkt| Self { blinkt })
.map_err(|e| error!("Blinkt::new ... | true |
c02b0a30febcdbf9b3d8521c1579562bfd07c8a6 | Rust | PSL9902/localizer | /src/structs/serializer.rs | UTF-8 | 2,937 | 3.09375 | 3 | [] | no_license | use crate::{enums::SerializeForm, structs::LangsDictionary, traits::Serializer, Error, prelude::format};
impl Serializer for StandartSerializer {
fn serialize(
&self,
string: &str,
serialize_format: &SerializeForm,
) -> Result<LangsDictionary, Error> {//Option<LangsDictionary> {//
... | true |
48c07c18d418df1e797d6db4290659f096b6c5f3 | Rust | InputUsername/rust-expr | /src/eval.rs | UTF-8 | 1,671 | 3.46875 | 3 | [] | no_license | use std::collections::HashMap;
use parse::Expr;
/// Combine two Options into a single Option by applying a function to their contents.
fn combine<T, F>(lhs: Option<T>, rhs: Option<T>, f: F) -> Option<T>
where F: Fn(T, T) -> T
{
lhs.and_then(|a| rhs.map(|b| f(a, b)))
}
/// Recursively evaluate an Expr.
pub fn... | true |
1e64efa0225bc892831005a8ca2e7f8680396201 | Rust | warrenbiltz/adventofcode | /2020/day5/day5.rs | UTF-8 | 1,580 | 3.21875 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn decode(line: &str) -> (i32, i32, i32) {
let seat = line.chars().collect::<Vec<char>>();
let mut row = 127_i32;
let mut col = 7_i32;
let mut partition = 64;
let mut i = 0;
while i < 7 {
if seat[i] == 'F' {
row -= partiti... | true |
7f187150f76651a4185a9fb630e31d5f96bf5253 | Rust | YoEight/googapis | /googapis/genproto/google.cloud.dialogflow.v2.rs | UTF-8 | 196,453 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// Represents a single validation error.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValidationError {
/// The severity of the error.
#[prost(enumeration = "validation_error::Severity", tag = "1")]
pub severity: i32,
/// The names of the entries that the error is associated with.
/// F... | true |
62f5edb5d605e6800daf5e032c508e688d48b762 | Rust | 1frag/rust_basic | /codeforces/src/main.rs | UTF-8 | 9,692 | 3 | 3 | [] | no_license | use std::env;
use std::fmt::Debug;
use std::io;
use std::str::FromStr;
fn read_i32() -> i32 {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
return input.trim().parse().unwrap();
}
fn read_vec_ixx<T>() -> Vec<T>
where
<T as FromStr>::Err: Debug,
T: FromStr,
... | true |
82bf04e174add0555dc028745d2630f91a94cd32 | Rust | psinghal20/linkerd2-proxy | /linkerd/proxy/http/src/add_header.rs | UTF-8 | 6,101 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use futures::{try_ready, Future, Poll};
use http::header::{AsHeaderName, HeaderValue};
use std::{fmt, marker::PhantomData};
use tracing::trace;
/// A function used to get the header value for a given Stack target.
type GetHeader<T> = fn(&T) -> Option<HeaderValue>;
/// Wraps HTTP `Service` `MakeAddHeader<T>`s so that ... | true |
d74ee4e97b0f022c84899419df894a7f5af78dd8 | Rust | danielhuang/aoc-2020 | /src/bin/12.rs | UTF-8 | 1,171 | 3.140625 | 3 | [] | no_license | use aoc::Coordinate;
fn get_input() -> Vec<&'static str> {
let input = include_str!("12.txt");
input.lines().collect()
}
fn rotate_once_right(coordinate: Coordinate) -> Coordinate {
Coordinate(coordinate.1, -coordinate.0)
}
#[util::bench]
fn main() -> i64 {
let input = get_input();
let mut pos = Coordinate(0, ... | true |
c05ce416a53ab59879b919c83f4fbaae3c8446c0 | Rust | toddnguyen47/serial-port-reader-writer | /src/parse_config.rs | UTF-8 | 3,425 | 3.421875 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use serialport::{DataBits, FlowControl, Parity, StopBits};
use std::env;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::time::Duration;
#[derive(Deserialize)]
struct ConfigToml {
serial: Serial,
}
/// The name of the struct has to match the name of the section,
/// ... | true |
ccb4583e0f042789d1375d425386e56c7137f0ff | Rust | juzi5201314/coolq-sdk-rust | /src/lib.rs | UTF-8 | 4,466 | 2.640625 | 3 | [
"MIT"
] | permissive | #![allow(non_upper_case_globals)]
#![allow(unused_variables)]
#![doc(html_root_url = "https://docs.rs/coolq-sdk-rust/latest")]
#![cfg_attr(docsrs, feature(doc_cfg))]
//! 使用Rust编写的酷q sdk。
//!
//! ## Get started
//! ```toml
//! coolq-sdk-rust = "0.1"
//! ```
//!
//!
//! ## Features
//!
//! * `enhanced-cqcode`: 开启 [增强cq... | true |
0e8e1b4e744ba4955ee21c7513092457e98756fb | Rust | hbina/gits | /src/main.rs | UTF-8 | 303 | 2.578125 | 3 | [] | no_license | fn main() {
let result = std::process::Command::new("git")
.args(&["-c","color.status=always","status"])
.output()
.expect("failed to execute process")
.stdout;
println!(
"{}",
String::from_utf8(result).expect("unable to parse string.")
);
}
| true |
f41f192dc1c424f0d1fb3b6bf2d716f2591e566e | Rust | szabgab/slides | /rust/examples/other/age_limit_18.rs | UTF-8 | 532 | 3.71875 | 4 | [] | no_license | use std::io;
use std::io::Write;
fn main() {
let mut age = String::new();
print!("How old are you? ");
io::stdout().flush().expect("Oups");
io::stdin()
.read_line(&mut age)
.expect("Faild to get input");
let age: f32 = age.trim().parse().expect(&format!("Could not convert '{age}'... | true |
6aed45f9f50c79859d4599486016f8c312b1243c | Rust | secti6n/porus | /src/collections/flist.rs | UTF-8 | 2,198 | 2.953125 | 3 | [
"MIT"
] | permissive | use core::ptr::null_mut;
use super::super::traits::{Allocator, Bounded, Collection, Stack};
use super::super::storage::SystemAllocator;
pub struct ForwardListNode<T> {
next: *mut ForwardListNode<T>,
data: T,
}
pub struct ForwardList<T, A : Allocator<Item=ForwardListNode<T>> = SystemAllocator<ForwardListNode... | true |
5615a53e913ccb7eca512eb9735fadeff32ee0c9 | Rust | codecrafters-io/languages | /compiled_starters/redis-starter-rust/src/main.rs | UTF-8 | 611 | 2.765625 | 3 | [
"MIT"
] | permissive | #[allow(unused_imports)]
use std::env;
#[allow(unused_imports)]
use std::fs;
#[allow(unused_imports)]
use std::net::TcpListener;
fn main() {
// You can use print statements as follows for debugging, they'll be visible when running tests.
println!("Logs from your program will appear here!");
// Uncomment t... | true |
b03e727812930e6a6a5754e16f90849eb50b2bdb | Rust | RustyYato/double-buffer-v1 | /double-buffer/src/atomic.rs | UTF-8 | 2,178 | 2.53125 | 3 | [] | no_license | use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use crate::Strategy;
pub type BufferData<B, E = ()> = crate::BufferData<AtomicBool, AtomicStrategy, B, E>;
crate::__imp_make_newtype! {
crate::atomic::AtomicStrategy, core::convert::Infallible, ArcInner, std::sync::Arc
}
#[derive(Default)]
pub struct ... | true |
33c1ca3f455a4d1cd325cde4b073e10da1159dfe | Rust | 3for/halo | /src/circuits.rs | UTF-8 | 13,514 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use crate::fields::Field;
use std::marker::PhantomData;
use std::ops::{Add, Mul, Neg, Sub};
#[derive(Copy, Clone, Debug)]
pub enum Variable {
A(usize),
B(usize),
C(usize),
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum SynthesisError {
AssignmentMissing,
DivisionByZero,
Unsatisfiable,
... | true |
c1a4c8ef07961b8eb78c3d68358799f0e32d79e6 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/clap/examples/tutorial_derive/04_04_custom.rs | UTF-8 | 2,169 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use
clap
:
:
error
:
:
ErrorKind
;
use
clap
:
:
{
CommandFactory
Parser
}
;
#
[
derive
(
Parser
)
]
#
[
command
(
author
version
about
long_about
=
None
)
]
struct
Cli
{
/
/
/
set
version
manually
#
[
arg
(
long
value_name
=
"
VER
"
)
]
set_ver
:
Option
<
String
>
/
/
/
auto
inc
major
#
[
arg
(
long
)
]
major
:
bool
/
... | true |
cff26a6291ee0d85e1d03aca4459f92b3b65d727 | Rust | marcelodasilva/challenges-hacktoberfest | /challenges/1/Rust/pucklamotzer09/src/main.rs | UTF-8 | 320 | 3.734375 | 4 | [] | no_license | extern crate rand;
use rand::Rng;
fn main() {
let mut integer = [1,2,3,4,5,6,7,8,9,10];
let mut i = 0;
while i < 10 {
integer[i] = rand::thread_rng().gen_range(1,1000);
i+=1;
}
let mut sum = 0;
for i in integer.iter() {
sum += i;
}
println!("Sum: {}",sum);
}
| true |
41f26ec8a89eb8eb46cf19fb7043d2b1de0a8fdb | Rust | aleics/rsmath | /src/linspace/quat.rs | UTF-8 | 6,249 | 3.859375 | 4 | [
"Apache-2.0"
] | permissive | use num::Num;
use num::pow;
use std::fmt;
use std::ops::{Add, Sub, Mul, Neg};
/// Quaternion represents a three dimensional component (x, y, z) with a definied
/// amount of rotation (w).
///
/// # Remarks
///
/// This struct is implemented to be used with numerical types.
#[derive(Clone, Copy)]
pub struct Quat<N: Cop... | true |
c11c3290250894cebf3154638ba4ec7242db404f | Rust | ganmacs/msgpack-rs | /msgpack-value/src/unpacker.rs | UTF-8 | 2,073 | 2.625 | 3 | [] | no_license | use std::io;
use crate::{unpack, unpack_value_ref, RefValue, Value};
use msgpack::{BufferedRead, InnerBuf, UnpackError};
pub struct RefUnpackFeeder<'a, R>(&'a mut R);
impl<'a, R> Iterator for RefUnpackFeeder<'a, R>
where
R: BufferedRead<'a>,
{
type Item = RefValue<'a>;
fn next(&mut self) -> Option<Self:... | true |
5f777148cad1c5daf8043eb33953ebd3cb35d50c | Rust | devguardio/carrier | /rust/src/util.rs | UTF-8 | 989 | 2.609375 | 3 | [] | no_license | use std::mem;
use error::Error;
use carrier::carrier_sha256 as sha256;
pub struct Defer<F: FnOnce()> {
f: Option<F>,
}
impl<F: FnOnce()> Drop for Defer<F> {
fn drop(&mut self) {
if let Some(f) = mem::replace(&mut self.f, None) {
f();
}
}
}
pub fn defer<F: FnOnce()>(f: F) -> De... | true |
24121d83d64100a898f01980a156f6736f770f8e | Rust | 0xpr03/ts3_query | /src/data.rs | UTF-8 | 26,727 | 2.546875 | 3 | [] | no_license | use crate::raw::*;
use crate::Result;
use std::collections::HashMap;
// Ts3 uses just whatever is available in the DB system, could be i32 or i64, though every foreign key is unsigned..
pub type ServerId = u64;
pub type ServerGroupID = u64;
pub type ChannelId = u64;
/// Temporary, per connection ID of a client, reused... | true |
2da1af83567137a0903f686a54b8fc005ba49198 | Rust | dragfire/lc | /examples/number-of-islands.rs | UTF-8 | 1,547 | 3.265625 | 3 | [] | no_license | /*
* @lc app=leetcode id=200 lang=rust
*
* [200] Number of Islands
*
* https://leetcode.com/problems/number-of-islands/description/
*
* algorithms
* Medium (46.44%)
* Likes: 5610
* Dislikes: 193
* Total Accepted: 729.1K
* Total Submissions: 1.6M
* Testcase Example: '[["1","1","1","1","0"],["1","1","... | true |
065f10709de5e6244e77dc3ca86a82fc5f7ec0ea | Rust | alesgenova/pitch-detection | /src/detector/internals.rs | UTF-8 | 10,583 | 2.828125 | 3 | [
"MIT"
] | permissive | use rustfft::FftPlanner;
use crate::utils::buffer::ComplexComponent;
use crate::utils::buffer::{copy_complex_to_real, square_sum};
use crate::utils::buffer::{copy_real_to_complex, BufferPool};
use crate::utils::peak::choose_peak;
use crate::utils::peak::correct_peak;
use crate::utils::peak::detect_peaks;
use crate::ut... | true |
ddd2d220522e69f1140bf015e74878b37b923c32 | Rust | ytakhs/artichoke | /artichoke-core/src/prng.rs | UTF-8 | 2,198 | 3.328125 | 3 | [
"MIT"
] | permissive | //! Interpreter global psuedorandom number generator.
/// Interpreter global psuedorandom number generator.
///
/// Implementors of this trait back the `Random::DEFAULT` PRNG.
pub trait Prng {
/// Concrete type for PRNG errors.
type Error;
/// Cocnrete type representing the internal state of all PRNG back... | true |
a546a7fdad12ceddf61729eb7b9c662945170b4e | Rust | jackpot51/friar | /src/viewport.rs | UTF-8 | 994 | 3.453125 | 3 | [
"MIT"
] | permissive | use perspective::Perspective;
use position::Position;
use reference::Reference;
use screen::Screen;
//TODO: Turn into trait
pub struct Viewport<'r, R: Reference + 'r> {
perspective: &'r Perspective<'r, R>,
x: f64,
y: f64,
z: f64,
}
impl<'r, R: Reference> Viewport<'r, R> {
/// Create new Viewport
... | true |
ba34ad3a0f687664abd0d309720a5c106c30ff52 | Rust | age-rs/game_clock | /examples/simple.rs | UTF-8 | 473 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use game_clock::Time;
use std::time::Duration;
fn main() {
let mut time = Time::default();
time.set_fixed_time(Duration::from_secs_f64(1.0 / 20.0));
let step = 1.0 / 60.0;
for _ in 0..60 {
time.advance_frame(Duration::from_secs_f64(step));
{} // Run dynamic frame (ie. game logic, render... | true |
6084f32aaae78d501c4773261fe55ea3d5d385c0 | Rust | yeliknewo/rl-game-4 | /src/art/src/lib.rs | UTF-8 | 1,205 | 2.703125 | 3 | [] | no_license | extern crate dependencies;
extern crate graphics;
use dependencies::gfx::state::{Rasterizer};
use graphics::{Packet, Vertex};
pub fn make_square_render() -> Packet {
let vertices = vec!(
Vertex::new([0.0, 0.0, 0.0], [1.0, 1.0]),
Vertex::new([0.0, 1.0, 0.0], [1.0, 0.0]),
Vertex::new([1.0, 1... | true |
755f3ee1e7057f7b5540fe8da981afaa84d52c52 | Rust | mikedilger/float-cmp | /src/macros.rs | UTF-8 | 5,500 | 2.90625 | 3 | [
"MIT"
] | permissive |
#[macro_export]
macro_rules! approx_eq {
($typ:ty, $lhs:expr, $rhs:expr) => {
{
let m = <$typ as $crate::ApproxEq>::Margin::default();
<$typ as $crate::ApproxEq>::approx_eq($lhs, $rhs, m)
}
};
($typ:ty, $lhs:expr, $rhs:expr $(, $set:ident = $val:expr)*) => {
... | true |
0bc1f588581350cca8b7a2c3174d49e9540d42d6 | Rust | msadowski20/broot | /src/skin/skin_entry.rs | UTF-8 | 5,829 | 3.171875 | 3 | [
"MIT"
] | permissive | /// Manage conversion of a user provided string
/// defining foreground and background colors into
/// a string with TTY colors
use {
crate::errors::InvalidSkinError,
crossterm::style::{
Attribute::{self, *},
Attributes,
Color::{self, *},
},
std::result::Result,
super::*,
... | true |
213c72730c7951e1359c731c1074bb904ec08d44 | Rust | cipepser/programming-rust-sample | /chap18/network/src/main.rs | UTF-8 | 1,261 | 3.046875 | 3 | [] | no_license | extern crate reqwest;
use std::net::TcpListener;
use std::io::{self, Write};
use std::error::Error;
use std::thread::spawn;
fn echo_main(addr: &str) -> io::Result<()> {
let listener = TcpListener::bind(addr)?;
println!("listening on {}", addr);
loop {
let (mut stream, addr) = listener.accept()?;
... | true |
a028738946be0764cbaab0b195647aaa99eaab5b | Rust | adrianromero/rustexamples | /examples/javascript.rs | UTF-8 | 1,060 | 3 | 3 | [] | no_license | // Rust Examples is a collection of small portions of code written in Rust
// Copyright (C) 2022 Adrián Romero Corchado.
use boa::prelude::{JsResult, JsString, JsValue};
use boa::Context;
fn main() {
let scenario = r#"
function suma(a, b){
return a + b;
}
const c =[3,3,3,2];
print... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.